From 04f0761d71a9c1dac4ef475d8f144793ddd74f89 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 15 Jul 2007 21:57:42 +0000 Subject: [PATCH] get the mac os build building again --- macosx/InfoWindowController.m | 3 +++ macosx/Torrent.h | 4 ++++ macosx/Torrent.m | 22 ++++++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 78fa11009..7b3b315d9 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -445,7 +445,10 @@ - (void) updateInfoFiles { if ([fTorrents count] == 1) + { + [[fTorrents objectAtIndex: 0] updateFileStat]; [fFileOutline reloadData]; + } } - (void) updateInfoSettings diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 4218af59a..fa9589f78 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -53,6 +53,7 @@ NSImage * fIcon, * fIconFlipped, * fIconSmall; NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString; + tr_file_stat_t * fileStat; NSArray * fFileList, * fFlatFileList; int fUploadLimit, fDownloadLimit; @@ -201,6 +202,9 @@ - (NSArray *) fileList; - (int) fileCount; +- (void) updateFileStat; + +//methods require fileStats to have been updated recently to be accurate - (float) fileProgress: (int) index; - (int) checkForFiles: (NSIndexSet *) indexSet; - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 3cdc2a753..f0515635e 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -170,6 +170,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (void) dealloc { + if (fileStat) + tr_torrentFilesFree(fileStat, [self fileCount]); + [fDownloadFolder release]; [fIncompleteFolder release]; @@ -1281,9 +1284,21 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 return fInfo->fileCount; } +- (void) updateFileStat +{ + if (fileStat) + tr_torrentFilesFree(fileStat, [self fileCount]); + + int count; + fileStat = tr_torrentFiles(fHandle, &count); +} + - (float) fileProgress: (int) index { - return tr_torrentFileCompletion(fHandle, index); + if (!fileStat) + [self updateFileStat]; + + return fileStat[index].progress; } - (int) checkForFiles: (NSIndexSet *) indexSet @@ -1308,9 +1323,12 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 if ([self fileCount] <= 1 || [self isComplete]) return NO; + if (!fileStat) + [self updateFileStat]; + int index; for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) - if (tr_torrentGetFileStatus(fHandle, index) != TR_CP_COMPLETE) + if (fileStat[index].completionStatus != TR_CP_COMPLETE) return YES; return NO; }