mirror of
https://github.com/transmission/transmission
synced 2025-02-03 04:53:27 +00:00
replace some file extension checks with Uniform Type Identifier checks
This commit is contained in:
parent
a1b2c6d640
commit
4fb2e39d59
1 changed files with 11 additions and 8 deletions
|
@ -2437,7 +2437,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
path = [path stringByExpandingTildeInPath];
|
path = [path stringByExpandingTildeInPath];
|
||||||
|
|
||||||
NSArray * importedNames;
|
NSArray * importedNames;
|
||||||
if (!(importedNames = [[NSFileManager defaultManager] directoryContentsAtPath: path]))
|
if (!(importedNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: path error: NULL]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//only check files that have not been checked yet
|
//only check files that have not been checked yet
|
||||||
|
@ -2447,15 +2447,17 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
[newNames removeObjectsInArray: fAutoImportedNames];
|
[newNames removeObjectsInArray: fAutoImportedNames];
|
||||||
else
|
else
|
||||||
fAutoImportedNames = [[NSMutableArray alloc] init];
|
fAutoImportedNames = [[NSMutableArray alloc] init];
|
||||||
[fAutoImportedNames setArray: importedNames];
|
|
||||||
|
|
||||||
for (NSInteger i = [newNames count] - 1; i >= 0; i--)
|
for (NSInteger i = [newNames count] - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
NSString * file = [newNames objectAtIndex: i];
|
NSString * file = [newNames objectAtIndex: i],
|
||||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
|
* fullFile = [path stringByAppendingPathComponent: file];
|
||||||
[newNames removeObjectAtIndex: i];
|
|
||||||
|
if ([[[NSWorkspace sharedWorkspace] typeOfFile: fullFile error: NULL] isEqualToString: @"org.bittorrent.torrent"]
|
||||||
|
&& ![file hasPrefix: @"."])
|
||||||
|
[newNames replaceObjectAtIndex: i withObject: fullFile];
|
||||||
else
|
else
|
||||||
[newNames replaceObjectAtIndex: i withObject: [path stringByAppendingPathComponent: file]];
|
[newNames removeObjectAtIndex: i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NSString * file in newNames)
|
for (NSString * file in newNames)
|
||||||
|
@ -2694,12 +2696,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
NSPasteboard * pasteboard = [info draggingPasteboard];
|
NSPasteboard * pasteboard = [info draggingPasteboard];
|
||||||
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
||||||
{
|
{
|
||||||
|
#warning simplify
|
||||||
//check if any torrent files can be added
|
//check if any torrent files can be added
|
||||||
BOOL torrent = NO;
|
BOOL torrent = NO;
|
||||||
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
||||||
for (NSString * file in files)
|
for (NSString * file in files)
|
||||||
{
|
{
|
||||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
|
if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
|
||||||
{
|
{
|
||||||
tr_ctor * ctor = tr_ctorNew(fLib);
|
tr_ctor * ctor = tr_ctorNew(fLib);
|
||||||
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
||||||
|
@ -2763,7 +2766,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
||||||
for (NSString * file in files)
|
for (NSString * file in files)
|
||||||
{
|
{
|
||||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
|
if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
|
||||||
{
|
{
|
||||||
tr_ctor * ctor = tr_ctorNew(fLib);
|
tr_ctor * ctor = tr_ctorNew(fLib);
|
||||||
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
||||||
|
|
Loading…
Reference in a new issue