Changeset 5282 for trunk/macosx/Torrent.m
- Timestamp:
- Mar 18, 2008, 3:20:27 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Torrent.m
r5273 r5282 548 548 uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], neededSpace = 0; 549 549 550 [self updateFileStat]; 551 552 //determine amount needed 553 int i; 554 for (i = 0; i < [self fileCount]; i++) 550 //if the size left is less then remaining space, then there is enough space regardless of preallocation 551 if (remainingSpace < [self sizeLeft]) 555 552 { 556 if (tr_torrentGetFileDL(fHandle, i)) 553 [self updateFileStat]; 554 555 //determine amount needed 556 int i; 557 for (i = 0; i < [self fileCount]; i++) 557 558 { 558 tr_file * file = &fInfo->files[i]; 559 if (tr_torrentGetFileDL(fHandle, i)) 560 { 561 tr_file * file = &fInfo->files[i]; 562 563 neededSpace += file->length; 564 565 NSString * path = [downloadFolder stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]]; 566 NSDictionary * fileAttributes = onLeopard ? [fileManager attributesOfItemAtPath: path error: NULL] 567 : [fileManager fileAttributesAtPath: path traverseLink: NO]; 568 if (fileAttributes) 569 neededSpace -= [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue]; 570 } 571 } 572 573 if (remainingSpace < neededSpace) 574 { 575 NSAlert * alert = [[NSAlert alloc] init]; 576 [alert setMessageText: [NSString stringWithFormat: 577 NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.", 578 "Torrent file disk space alert -> title"), [self name]]]; 579 [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused." 580 " Clear up space on %@ or deselect files in the torrent inspector to continue.", 581 "Torrent file disk space alert -> message"), volumeName]]; 582 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")]; 583 [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")]; 559 584 560 neededSpace += file->length; 585 if (onLeopard) 586 [alert setShowsSuppressionButton: YES]; 587 else 588 [alert addButtonWithTitle: NSLocalizedString(@"Always Download", "Torrent file disk space alert -> button")]; 589 590 NSInteger result = [alert runModal]; 591 if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn)) 592 [fDefaults setBool: NO forKey: @"WarningRemainingSpace"]; 593 [alert release]; 561 594 562 NSString * path = [downloadFolder stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]]; 563 NSDictionary * fileAttributes = onLeopard ? [fileManager attributesOfItemAtPath: path error: NULL] 564 : [fileManager fileAttributesAtPath: path traverseLink: NO]; 565 if (fileAttributes) 566 neededSpace -= [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue]; 595 return result != NSAlertFirstButtonReturn; 567 596 } 568 }569 570 if (remainingSpace < neededSpace)571 {572 NSAlert * alert = [[NSAlert alloc] init];573 [alert setMessageText: [NSString stringWithFormat:574 NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.",575 "Torrent file disk space alert -> title"), [self name]]];576 [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused."577 " Clear up space on %@ or deselect files in the torrent inspector to continue.",578 "Torrent file disk space alert -> message"), volumeName]];579 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")];580 [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")];581 582 if (onLeopard)583 [alert setShowsSuppressionButton: YES];584 else585 [alert addButtonWithTitle: NSLocalizedString(@"Always Download", "Torrent file disk space alert -> button")];586 587 NSInteger result = [alert runModal];588 if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn))589 [fDefaults setBool: NO forKey: @"WarningRemainingSpace"];590 [alert release];591 592 return result != NSAlertFirstButtonReturn;593 597 } 594 598 }
Note: See TracChangeset
for help on using the changeset viewer.