Changeset 8497


Ignore:
Timestamp:
May 23, 2009, 7:01:57 PM (12 years ago)
Author:
livings124
Message:

a little simplification in the auto-import code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r8496 r8497  
    24502450    [fAutoImportedNames setArray: importedNames];
    24512451   
    2452     for (NSInteger i = [newNames count] - 1; i >= 0; i--)
    2453     {
    2454         NSString * file = [newNames objectAtIndex: i],
    2455                 * fullFile = [path stringByAppendingPathComponent: file];
    2456        
    2457         if ([[[NSWorkspace sharedWorkspace] typeOfFile: fullFile error: NULL] isEqualToString: @"org.bittorrent.torrent"]
    2458             && ![file hasPrefix: @"."])
    2459             [newNames replaceObjectAtIndex: i withObject: fullFile];
    2460         else
    2461             [newNames removeObjectAtIndex: i];
    2462     }
    2463    
    24642452    for (NSString * file in newNames)
    24652453    {
     2454        if ([file hasPrefix: @"."])
     2455            continue;
     2456       
     2457        NSString * fullFile = [path stringByAppendingPathComponent: file];
     2458       
     2459        if (![[[NSWorkspace sharedWorkspace] typeOfFile: fullFile error: NULL] isEqualToString: @"org.bittorrent.torrent"])
     2460            continue;
     2461       
    24662462        tr_ctor * ctor = tr_ctorNew(fLib);
    2467         tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
     2463        tr_ctorSetMetainfoFromFile(ctor, [fullFile UTF8String]);
    24682464       
    24692465        switch (tr_torrentParse(ctor, NULL))
    24702466        {
    24712467            case TR_OK:
    2472                 [self openFiles: [NSArray arrayWithObject: file] addType: ADD_AUTO forcePath: nil];
     2468                [self openFiles: [NSArray arrayWithObject: fullFile] addType: ADD_AUTO forcePath: nil];
    24732469               
    24742470                [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added", "Growl notification title")
    2475                     description: [file lastPathComponent] notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO
     2471                    description: file notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO
    24762472                    clickContext: nil];
    24772473                break;
    24782474           
    24792475            case TR_EINVALID:
    2480                 [fAutoImportedNames removeObject: [file lastPathComponent]];
     2476                [fAutoImportedNames removeObject: file];
    24812477        }
    24822478       
Note: See TracChangeset for help on using the changeset viewer.