From 470ee010f2eab10f7be955128fb446bc0fe31a3a Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 25 Apr 2020 10:35:15 -0400 Subject: [PATCH] Revert "Merge pull request #1039 from MaddTheSane/patch-4" This reverts commit c0c463d66042dc0a5299e9228d0dbb3cfe99e214, reversing changes made to cd2587a43518f8d26fb1c10c8397cc733c71e273. --- macosx/BlocklistDownloader.m | 2 +- macosx/Controller.m | 22 +++++++++---------- macosx/CreatorWindowController.m | 4 ++-- macosx/DragOverlayWindow.m | 2 +- macosx/PrefsController.m | 3 +-- .../QuickLookPlugin/GeneratePreviewForURL.m | 2 +- macosx/Torrent.m | 14 ++++++------ 7 files changed, 23 insertions(+), 26 deletions(-) diff --git a/macosx/BlocklistDownloader.m b/macosx/BlocklistDownloader.m index 31c995e80..683e4dfbe 100644 --- a/macosx/BlocklistDownloader.m +++ b/macosx/BlocklistDownloader.m @@ -132,7 +132,7 @@ BlocklistDownloader * fBLDownloader = nil; [self decompressBlocklist]; dispatch_async(dispatch_get_main_queue(), ^{ - const int count = tr_blocklistSetContent([(Controller *)[NSApp delegate] sessionHandle], [fDestination fileSystemRepresentation]); + const int count = tr_blocklistSetContent([(Controller *)[NSApp delegate] sessionHandle], [fDestination UTF8String]); //delete downloaded file [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL]; diff --git a/macosx/Controller.m b/macosx/Controller.m index 0a472aef8..7087ca7a9 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -343,13 +343,13 @@ static void removeKeRangerRansomware() tr_variantDictAddStr(&settings, TR_KEY_blocklist_url, [[fDefaults stringForKey: @"BlocklistURL"] UTF8String]); tr_variantDictAddBool(&settings, TR_KEY_dht_enabled, [fDefaults boolForKey: @"DHTGlobal"]); tr_variantDictAddStr(&settings, TR_KEY_download_dir, [[[fDefaults stringForKey: @"DownloadFolder"] - stringByExpandingTildeInPath] fileSystemRepresentation]); + stringByExpandingTildeInPath] UTF8String]); tr_variantDictAddBool(&settings, TR_KEY_download_queue_enabled, [fDefaults boolForKey: @"Queue"]); tr_variantDictAddInt(&settings, TR_KEY_download_queue_size, [fDefaults integerForKey: @"QueueDownloadNumber"]); tr_variantDictAddInt(&settings, TR_KEY_idle_seeding_limit, [fDefaults integerForKey: @"IdleLimitMinutes"]); tr_variantDictAddBool(&settings, TR_KEY_idle_seeding_limit_enabled, [fDefaults boolForKey: @"IdleLimitCheck"]); tr_variantDictAddStr(&settings, TR_KEY_incomplete_dir, [[[fDefaults stringForKey: @"IncompleteDownloadFolder"] - stringByExpandingTildeInPath] fileSystemRepresentation]); + stringByExpandingTildeInPath] UTF8String]); tr_variantDictAddBool(&settings, TR_KEY_incomplete_dir_enabled, [fDefaults boolForKey: @"UseIncompleteDownloadFolder"]); tr_variantDictAddBool(&settings, TR_KEY_lpd_enabled, [fDefaults boolForKey: @"LocalPeerDiscoveryGlobal"]); tr_variantDictAddInt(&settings, TR_KEY_message_level, TR_LOG_DEBUG); @@ -382,7 +382,7 @@ static void removeKeRangerRansomware() tr_variantDictAddInt(&settings, TR_KEY_seed_queue_size, [fDefaults integerForKey: @"QueueSeedNumber"]); tr_variantDictAddBool(&settings, TR_KEY_start_added_torrents, [fDefaults boolForKey: @"AutoStartDownload"]); tr_variantDictAddBool(&settings, TR_KEY_script_torrent_done_enabled, [fDefaults boolForKey: @"DoneScriptEnabled"]); - tr_variantDictAddStr(&settings, TR_KEY_script_torrent_done_filename, [[fDefaults stringForKey: @"DoneScriptPath"] fileSystemRepresentation]); + tr_variantDictAddStr(&settings, TR_KEY_script_torrent_done_filename, [[fDefaults stringForKey: @"DoneScriptPath"] UTF8String]); tr_variantDictAddBool(&settings, TR_KEY_utp_enabled, [fDefaults boolForKey: @"UTPGlobal"]); // TODO: Add to GUI @@ -424,7 +424,7 @@ static void removeKeRangerRansomware() fLib = tr_sessionInit(configDir, YES, &settings); tr_variantFree(&settings); - fConfigDirectory = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: configDir length: strlen(configDir)]; + fConfigDirectory = [[NSString alloc] initWithUTF8String: configDir]; [NSApp setDelegate: self]; @@ -922,7 +922,7 @@ static void removeKeRangerRansomware() { //ensure torrent doesn't already exist tr_ctor * ctor = tr_ctorNew(fLib); - tr_ctorSetMetainfoFromFile(ctor, [torrentPath fileSystemRepresentation]); + tr_ctorSetMetainfoFromFile(ctor, [torrentPath UTF8String]); tr_info info; const tr_parse_result result = tr_torrentParse(ctor, &info); @@ -2842,7 +2842,7 @@ static void removeKeRangerRansomware() continue; tr_ctor * ctor = tr_ctorNew(fLib); - tr_ctorSetMetainfoFromFile(ctor, [fullFile fileSystemRepresentation]); + tr_ctorSetMetainfoFromFile(ctor, [fullFile UTF8String]); switch (tr_torrentParse(ctor, NULL)) { @@ -3130,7 +3130,7 @@ static void removeKeRangerRansomware() { torrent = YES; tr_ctor * ctor = tr_ctorNew(fLib); - tr_ctorSetMetainfoFromFile(ctor, [file fileSystemRepresentation]); + tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); if (tr_torrentParse(ctor, NULL) == TR_PARSE_OK) { if (!fOverlayWindow) @@ -3192,7 +3192,7 @@ static void removeKeRangerRansomware() { torrent = YES; tr_ctor * ctor = tr_ctorNew(fLib); - tr_ctorSetMetainfoFromFile(ctor, [file fileSystemRepresentation]); + tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); if (tr_torrentParse(ctor, NULL) == TR_PARSE_OK) [filesToOpen addObject: file]; tr_ctorFree(ctor); @@ -4588,10 +4588,8 @@ static void removeKeRangerRansomware() - (void) rpcAddTorrentStruct: (struct tr_torrent *) torrentStruct { NSString * location = nil; - if (tr_torrentGetDownloadDir(torrentStruct) != NULL) { - const char * tmpLoc = tr_torrentGetDownloadDir(torrentStruct); - location = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: tmpLoc length: strlen(tmpLoc)]; - } + if (tr_torrentGetDownloadDir(torrentStruct) != NULL) + location = @(tr_torrentGetDownloadDir(torrentStruct)); Torrent * torrent = [[Torrent alloc] initWithTorrentStruct: torrentStruct location: location lib: fLib]; diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index 82d1e320b..8dba93886 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -76,7 +76,7 @@ NSMutableSet *creatorWindowControllerSet = nil; fStarted = NO; fPath = path; - fInfo = tr_metaInfoBuilderCreate([fPath fileSystemRepresentation]); + fInfo = tr_metaInfoBuilderCreate([[fPath path] UTF8String]); if (fInfo->fileCount == 0) { @@ -536,7 +536,7 @@ NSMutableSet *creatorWindowControllerSet = nil; [[self window] setRestorable: NO]; [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil]; - tr_makeMetaInfo(fInfo, [fLocation fileSystemRepresentation], trackerInfo, [fTrackers count], [[fCommentView string] UTF8String], [fPrivateCheck state] == NSOnState); + tr_makeMetaInfo(fInfo, [[fLocation path] UTF8String], trackerInfo, [fTrackers count], [[fCommentView string] UTF8String], [fPrivateCheck state] == NSOnState); tr_free(trackerInfo); fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(checkProgress) userInfo: nil repeats: YES]; diff --git a/macosx/DragOverlayWindow.m b/macosx/DragOverlayWindow.m index 6d02fb2da..987aa027c 100644 --- a/macosx/DragOverlayWindow.m +++ b/macosx/DragOverlayWindow.m @@ -92,7 +92,7 @@ || [[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame) { tr_ctor * ctor = tr_ctorNew(fLib); - tr_ctorSetMetainfoFromFile(ctor, [file fileSystemRepresentation]); + tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); tr_info info; if (tr_torrentParse(ctor, &info) == TR_PARSE_OK) { diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index a9595994d..5be411dd0 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -1320,8 +1320,7 @@ const BOOL doneScriptEnabled = tr_sessionIsTorrentDoneScriptEnabled(fHandle); [fDefaults setBool: doneScriptEnabled forKey: @"DoneScriptEnabled"]; - const char * doneScriptCStr = tr_sessionGetTorrentDoneScript(fHandle); - NSString * doneScriptPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: doneScriptCStr length: strlen(doneScriptCStr)]; + NSString * doneScriptPath = @(tr_sessionGetTorrentDoneScript(fHandle)); [fDefaults setObject: doneScriptPath forKey: @"DoneScriptPath"]; //update gui if loaded diff --git a/macosx/QuickLookPlugin/GeneratePreviewForURL.m b/macosx/QuickLookPlugin/GeneratePreviewForURL.m index 7f2420426..461617cbb 100644 --- a/macosx/QuickLookPlugin/GeneratePreviewForURL.m +++ b/macosx/QuickLookPlugin/GeneratePreviewForURL.m @@ -45,7 +45,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, //try to parse the torrent file tr_info inf; tr_ctor * ctor = tr_ctorNew(NULL); - tr_ctorSetMetainfoFromFile(ctor, [(__bridge NSURL *)url fileSystemRepresentation]); + tr_ctorSetMetainfoFromFile(ctor, [[(__bridge NSURL *)url path] UTF8String]); const int err = tr_torrentParse(ctor, &inf); tr_ctorFree(ctor); if (err) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index d89bc8c61..83db10b5a 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -264,7 +264,7 @@ bool trashDataFile(const char * filename, tr_error ** error) //if data existed in original download location, unexclude it before changing the location [self setTimeMachineExclude: NO]; - tr_torrentSetDownloadDir(fHandle, [folder fileSystemRepresentation]); + tr_torrentSetDownloadDir(fHandle, [folder UTF8String]); fDownloadFolderDetermination = determinationType; } @@ -562,7 +562,7 @@ bool trashDataFile(const char * filename, tr_error ** error) } volatile int status; - tr_torrentSetLocation(fHandle, [folder fileSystemRepresentation], YES, NULL, &status); + tr_torrentSetLocation(fHandle, [folder UTF8String], YES, NULL, &status); while (status == TR_LOC_MOVING) //block while moving (for now) [NSThread sleepForTimeInterval: 0.05]; @@ -846,7 +846,7 @@ bool trashDataFile(const char * filename, tr_error ** error) NSDictionary * contextInfo = @{ @"Torrent" : self, @"Nodes" : @[ node ], @"CompletionHandler" : [completionHandler copy] }; NSString * oldPath = [[node path] stringByAppendingPathComponent: [node name]]; - tr_torrentRenamePath(fHandle, [oldPath fileSystemRepresentation], [newName UTF8String], renameCallback, (__bridge_retained void *)(contextInfo)); + tr_torrentRenamePath(fHandle, [oldPath UTF8String], [newName UTF8String], renameCallback, (__bridge_retained void *)(contextInfo)); } - (CGFloat) progress @@ -1662,13 +1662,13 @@ bool trashDataFile(const char * filename, tr_error ** error) tr_ctorSetPaused(ctor, TR_FORCE, YES); if (downloadFolder) - tr_ctorSetDownloadDir(ctor, TR_FORCE, [downloadFolder fileSystemRepresentation]); + tr_ctorSetDownloadDir(ctor, TR_FORCE, [downloadFolder UTF8String]); if (incompleteFolder) - tr_ctorSetIncompleteDir(ctor, [incompleteFolder fileSystemRepresentation]); + tr_ctorSetIncompleteDir(ctor, [incompleteFolder UTF8String]); tr_parse_result result = TR_PARSE_ERR; if (path) - result = tr_ctorSetMetainfoFromFile(ctor, [path fileSystemRepresentation]); + result = tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); if (result != TR_PARSE_OK && magnetAddress) result = tr_ctorSetMetainfoFromMagnetLink(ctor, [magnetAddress UTF8String]); @@ -1853,7 +1853,7 @@ bool trashDataFile(const char * filename, tr_error ** error) { NSString * dataLocation = [[self currentDirectory] stringByAppendingPathComponent: [self name]]; FSRef ref; - if (FSPathMakeRef((const UInt8 *)[dataLocation fileSystemRepresentation], &ref, NULL) == noErr) + if (FSPathMakeRef((const UInt8 *)[dataLocation UTF8String], &ref, NULL) == noErr) { if (LSSetItemAttribute(&ref, kLSRolesAll, kLSItemQuarantineProperties, (__bridge CFTypeRef)(quarantineProperties)) != noErr) NSLog(@"Failed to quarantine: %@", dataLocation);