From e40a7d5359092379abff8ff7c8a77111748ce764 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 8 Jun 2014 22:16:01 +0000 Subject: [PATCH] (trunk) replace the tr_metainfo_builder.isSingleFile and tr_info.isMultifile fields an 'isFolder' bool in both structs. This makes the variable naming more uniform. It also clarifies the information we're really trying to convey -- previously, isSingleFile was false whenever the torrent held a directory tree, even if there was only a single file in the tree. Sync the Mac OS X client's use to match the libtransmission variable names. --- libtransmission/makemeta.c | 12 ++++++------ libtransmission/makemeta.h | 2 +- libtransmission/transmission.h | 2 +- macosx/Controller.m | 2 +- macosx/CreatorWindowController.m | 2 +- macosx/DragOverlayWindow.m | 2 +- macosx/QuickLookPlugin/GeneratePreviewForURL.m | 6 +++--- macosx/Torrent.m | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libtransmission/makemeta.c b/libtransmission/makemeta.c index 01b2e0fdc..0d7198884 100644 --- a/libtransmission/makemeta.c +++ b/libtransmission/makemeta.c @@ -126,7 +126,7 @@ tr_metaInfoBuilderCreate (const char * topFileArg) { struct stat sb; stat (topFile, &sb); - ret->isSingleFile = !S_ISDIR (sb.st_mode); + ret->isFolder = S_ISDIR (sb.st_mode); } /* build a list of files containing topFile and, @@ -334,11 +334,7 @@ makeInfoDict (tr_variant * dict, tr_variantDictReserve (dict, 5); - if (builder->isSingleFile) - { - tr_variantDictAddInt (dict, TR_KEY_length, builder->files[0].size); - } - else /* root node is a directory */ + if (builder->isFolder) /* root node is a directory */ { uint32_t i; tr_variant * list = tr_variantDictAddList (dict, TR_KEY_files, @@ -351,6 +347,10 @@ makeInfoDict (tr_variant * dict, getFileInfo (builder->top, &builder->files[i], length, pathVal); } } + else + { + tr_variantDictAddInt (dict, TR_KEY_length, builder->files[0].size); + } base = tr_basename (builder->top); tr_variantDictAddStr (dict, TR_KEY_name, base); diff --git a/libtransmission/makemeta.h b/libtransmission/makemeta.h index 8c7e3e77c..ba9c24ae8 100644 --- a/libtransmission/makemeta.h +++ b/libtransmission/makemeta.h @@ -45,7 +45,7 @@ typedef struct tr_metainfo_builder uint32_t fileCount; uint32_t pieceSize; uint32_t pieceCount; - bool isSingleFile; + bool isFolder; /** *** These are set inside tr_makeMetaInfo () diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 39b00c479..f2f0266fb 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -1836,7 +1836,7 @@ struct tr_info /* Flags */ bool isPrivate; - bool isMultifile; + bool isFolder; }; static inline bool tr_torrentHasMetadata (const tr_torrent * tor) diff --git a/macosx/Controller.m b/macosx/Controller.m index 60d716fd4..f7518596b 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -953,7 +953,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy //determine to show the options window const BOOL showWindow = type == ADD_SHOW_OPTIONS || ([fDefaults boolForKey: @"DownloadAsk"] - && (info.isMultifile || ![fDefaults boolForKey: @"DownloadAskMulti"]) + && (info.isFolder || ![fDefaults boolForKey: @"DownloadAskMulti"]) && (type != ADD_AUTO || ![fDefaults boolForKey: @"DownloadAskManual"])); tr_metainfoFree(&info); diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index 95eaef70f..c702c4461 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -150,7 +150,7 @@ [fNameField setStringValue: name]; [fNameField setToolTip: [fPath path]]; - const BOOL multifile = !fInfo->isSingleFile; + const BOOL multifile = fInfo->isFolder; NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: multifile ? NSFileTypeForHFSTypeCode(kGenericFolderIcon) : [fPath pathExtension]]; diff --git a/macosx/DragOverlayWindow.m b/macosx/DragOverlayWindow.m index f1e5f5953..9b87e88dc 100644 --- a/macosx/DragOverlayWindow.m +++ b/macosx/DragOverlayWindow.m @@ -110,7 +110,7 @@ if (count == 1) { name = [NSString stringWithUTF8String: info.name]; - folder = info.isMultifile; + folder = info.isFolder; } } tr_metainfoFree(&info); diff --git a/macosx/QuickLookPlugin/GeneratePreviewForURL.m b/macosx/QuickLookPlugin/GeneratePreviewForURL.m index c1c68b2a2..72cafeabc 100644 --- a/macosx/QuickLookPlugin/GeneratePreviewForURL.m +++ b/macosx/QuickLookPlugin/GeneratePreviewForURL.m @@ -60,13 +60,13 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, NSMutableDictionary * allImgProps = [NSMutableDictionary dictionary]; NSString * name = [NSString stringWithUTF8String: inf.name]; - NSString * fileTypeString = inf.isMultifile ? NSFileTypeForHFSTypeCode(kGenericFolderIcon) : [name pathExtension]; + NSString * fileTypeString = inf.isFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon) : [name pathExtension]; const NSUInteger width = 32; [htmlString appendFormat: @"

%@

", generateIconData(fileTypeString, width, allImgProps), width, width, name]; NSString * fileSizeString = [NSString stringForFileSize: inf.totalSize]; - if (inf.isMultifile) + if (inf.isFolder) { NSString * fileCountString; if (inf.fileCount == 1) @@ -132,7 +132,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, [lists addObject: listSection]; } - if (inf.isMultifile) + if (inf.isFolder) { NSMutableString * listSection = [NSMutableString string]; [listSection appendString: @""]; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index f6dbd935a..f5b295234 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -642,7 +642,7 @@ int trashDataFile(const char * filename) - (BOOL) isFolder { - return fInfo->isMultifile; + return fInfo->isFolder; } - (uint64_t) size