Changeset 5272


Ignore:
Timestamp:
Mar 17, 2008, 9:12:07 PM (14 years ago)
Author:
livings124
Message:

simplify the remaining disk space checking code

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r5258 r5272  
    22242224                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
    22252225                                GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
     2226                                GCC_WARN_UNUSED_VARIABLE = NO;
    22262227                                MACOSX_DEPLOYMENT_TARGET = 10.4;
    22272228                                PREBINDING = NO;
     
    22402241                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
    22412242                                GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
     2243                                GCC_WARN_UNUSED_VARIABLE = NO;
    22422244                                MACOSX_DEPLOYMENT_TARGET = 10.4;
    22432245                                PREBINDING = NO;
  • trunk/macosx/Torrent.m

    r5271 r5272  
    537537   
    538538    NSFileManager * fileManager = [NSFileManager defaultManager];
     539    NSString * downloadFolder = [self downloadFolder];
     540    BOOL onLeopard = [NSApp isOnLeopardOrBetter];
    539541   
    540542    NSString * volumeName;
    541     if ((volumeName = [[fileManager componentsToDisplayForPath: [self downloadFolder]] objectAtIndex: 0]))
    542     {
    543         NSDictionary * systemAttributes = [fileManager fileSystemAttributesAtPath: [self downloadFolder]];
     543    if ((volumeName = [[fileManager componentsToDisplayForPath: downloadFolder] objectAtIndex: 0]))
     544    {
     545        NSDictionary * systemAttributes = onLeopard ? [fileManager attributesOfFileSystemForPath: downloadFolder error: NULL]
     546                                            : [fileManager fileSystemAttributesAtPath: downloadFolder];
    544547        uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], neededSpace = 0;
    545548       
     
    554557                tr_file * file = &fInfo->files[i];
    555558               
    556                 NSString * path = [[self downloadFolder] stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]];
    557                 if ([fileManager fileExistsAtPath: path])
    558                 {
    559                     NSDictionary * fileAttributes = [NSApp isOnLeopardOrBetter] ? [fileManager attributesOfItemAtPath: path error: NULL]
     559                neededSpace += file->length;
     560               
     561                NSString * path = [downloadFolder stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]];
     562                NSDictionary * fileAttributes = onLeopard ? [fileManager attributesOfItemAtPath: path error: NULL]
    560563                                                    : [fileManager fileAttributesAtPath: path traverseLink: NO];
    561                     if (!fileAttributes)
    562                     {
    563                         NSLog(@"Problems getting file information for \"%@\".", path);
    564                         continue;
    565                     }
    566                    
    567                     neededSpace += file->length - [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue];
    568                 }
    569                 else
    570                     neededSpace += file->length;
     564                if (fileAttributes)
     565                    neededSpace -= [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue];
    571566            }
    572567        }
Note: See TracChangeset for help on using the changeset viewer.