Changeset 8495


Ignore:
Timestamp:
May 23, 2009, 6:53:09 PM (12 years ago)
Author:
livings124
Message:

replace some file extension checks with Uniform Type Identifier checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r8461 r8495  
    24382438   
    24392439    NSArray * importedNames;
    2440     if (!(importedNames = [[NSFileManager defaultManager] directoryContentsAtPath: path]))
     2440    if (!(importedNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: path error: NULL]))
    24412441        return;
    24422442   
     
    24482448    else
    24492449        fAutoImportedNames = [[NSMutableArray alloc] init];
    2450     [fAutoImportedNames setArray: importedNames];
    24512450   
    24522451    for (NSInteger i = [newNames count] - 1; i >= 0; i--)
    24532452    {
    2454         NSString * file = [newNames objectAtIndex: i];
    2455         if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
     2453        NSString * file = [newNames objectAtIndex: i],
     2454                * fullFile = [path stringByAppendingPathComponent: file];
     2455       
     2456        if ([[[NSWorkspace sharedWorkspace] typeOfFile: fullFile error: NULL] isEqualToString: @"org.bittorrent.torrent"]
     2457            && ![file hasPrefix: @"."])
     2458            [newNames replaceObjectAtIndex: i withObject: fullFile];
     2459        else
    24562460            [newNames removeObjectAtIndex: i];
    2457         else
    2458             [newNames replaceObjectAtIndex: i withObject: [path stringByAppendingPathComponent: file]];
    24592461    }
    24602462   
     
    26952697    if ([[pasteboard types] containsObject: NSFilenamesPboardType])
    26962698    {
     2699        #warning simplify
    26972700        //check if any torrent files can be added
    26982701        BOOL torrent = NO;
     
    27002703        for (NSString * file in files)
    27012704        {
    2702             if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
     2705            if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
    27032706            {
    27042707                tr_ctor * ctor = tr_ctorNew(fLib);
     
    27642767        for (NSString * file in files)
    27652768        {
    2766             if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
     2769            if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
    27672770            {
    27682771                tr_ctor * ctor = tr_ctorNew(fLib);
Note: See TracChangeset for help on using the changeset viewer.