Changeset 4284
- Timestamp:
- 06/10/06 01:12:50 (3 years ago)
- Files:
-
- WiredClient/trunk/WCFile.m (modified) (1 diff)
- WiredClient/trunk/WCTransfer.h (modified) (1 diff)
- WiredClient/trunk/WCTransfer.m (modified) (5 diffs)
- WiredClient/trunk/WCTransfers.m (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/WCFile.m
r4183 r4284 366 366 367 367 - (BOOL)isEqual:(id)object { 368 if(![self isKindOfClass: object])368 if(![self isKindOfClass:[object class]]) 369 369 return NO; 370 370 WiredClient/trunk/WCTransfer.h
r4272 r4284 145 145 - (NSString *)status; 146 146 147 - (BOOL)containsPairWithPath:(NSString *)value; 148 - (void)removePairWithPath:(NSString *)value; 149 - (unsigned int)numberOfPairs; 147 - (BOOL)containsPath:(NSString *)path; 148 - (BOOL)containsFile:(WCFile *)file; 149 - (void)removeFile:(WCFile *)file; 150 - (unsigned int)numberOfFiles; 150 151 151 152 - (void)addPath:(NSString *)path; WiredClient/trunk/WCTransfer.m
r4272 r4284 546 546 #pragma mark - 547 547 548 - (BOOL)containsPairWithPath:(NSString *)path { 549 NSEnumerator *enumerator; 550 WCFile *file; 551 552 enumerator = [_files objectEnumerator]; 553 554 while((file = [enumerator nextObject])) { 555 if([[file path] isEqualToString:path]) 556 return YES; 548 - (BOOL)containsPath:(NSString *)path { 549 return [_paths containsObject:path]; 550 } 551 552 553 554 - (BOOL)containsFile:(WCFile *)file { 555 return [_files containsObject:file]; 556 } 557 558 559 560 - (void)removeFile:(WCFile *)file { 561 unsigned int index; 562 563 index = [_files indexOfObject:file]; 564 565 if(index != NSNotFound) { 566 [_files removeObjectAtIndex:index]; 567 [_paths removeObjectAtIndex:index]; 557 568 } 558 559 return NO; 560 } 561 562 563 564 - (void)removePairWithPath:(NSString *)path { 565 NSEnumerator *enumerator; 566 WCFile *file; 567 int i = 0; 568 569 enumerator = [_files objectEnumerator]; 570 571 while((file = [enumerator nextObject])) { 572 if([[file path] isEqualToString:path]) { 573 [_files removeObjectAtIndex:i]; 574 [_paths removeObjectAtIndex:i]; 575 } 576 577 i++; 578 } 579 } 580 581 582 583 - (unsigned int)numberOfPairs { 584 return [_paths count]; 569 } 570 571 572 573 - (unsigned int)numberOfFiles { 574 return [_files count]; 585 575 } 586 576 … … 597 587 598 588 - (void)removeFirstPath { 599 [_paths removeObjectAtIndex:0]; 589 if([_paths count] > 0) 590 [_paths removeObjectAtIndex:0]; 600 591 } 601 592 … … 603 594 604 595 - (NSString *)firstPath { 596 if([_paths count] == 0) 597 return NULL; 598 605 599 return [_paths objectAtIndex:0]; 606 600 } … … 617 611 618 612 - (void)removeFirstFile { 619 [_files removeObjectAtIndex:0]; 613 if([_files count] > 0) 614 [_files removeObjectAtIndex:0]; 620 615 } 621 616 … … 623 618 624 619 - (WCFile *)firstFile { 620 if([_files count] == 0) 621 return NULL; 622 625 623 return [_files objectAtIndex:0]; 626 624 } WiredClient/trunk/WCTransfers.m
r4272 r4284 234 234 235 235 while((eachTransfer = [enumerator nextObject])) { 236 if([eachTransfer state] != WCTransferFinished) { 237 if((![eachTransfer isFolder] && [eachTransfer containsPairWithPath:path]) || 238 ( [eachTransfer isFolder] && [path hasPrefix:[eachTransfer virtualPath]])) { 236 if([eachTransfer isFolder]) { 237 if([path hasPrefix:[eachTransfer virtualPath]]) 239 238 transfer = eachTransfer; 240 241 break; 242 } 243 } 239 } else { 240 if([eachTransfer containsFile:[WCFile fileWithPath:path]]) 241 transfer = eachTransfer; 242 } 243 244 if(transfer) 245 break; 244 246 } 245 247 … … 478 480 [transfer removeFirstPath]; 479 481 480 if([transfer numberOf Pairs] == 0) {482 if([transfer numberOfFiles] == 0) { 481 483 [transfer setState:WCTransferFinished]; 482 484 [[transfer progressIndicator] setDoubleValue:1.0]; … … 623 625 unsigned int count; 624 626 BOOL isDirectory, hasResourceFork; 625 626 if([self _transferWithPath:path]) { 627 error = [WCError errorWithDomain:WCWiredClientErrorDomain code:WCWiredClientTransferExists argument:path]; 627 628 remotePath = [[destination path] stringByAppendingPathComponent:[path lastPathComponent]]; 629 630 if([self _transferWithPath:remotePath]) { 631 error = [WCError errorWithDomain:WCWiredClientErrorDomain code:WCWiredClientTransferExists argument:remotePath]; 628 632 [self _presentError:error]; 629 633 … … 639 643 [transfer setURL:url]; 640 644 641 remotePath = [[destination path] stringByAppendingPathComponent:[path lastPathComponent]];642 643 645 if([[NSFileManager defaultManager] directoryExistsAtPath:path]) { 644 646 [[self connection] sendCommand:WCFolderCommand withArgument:remotePath]; … … 701 703 count = [self _numberOfWorkingTransfersWithType:WCTransferUpload]; 702 704 705 if([transfer state] == WCTransferListing) 706 count--; 707 703 708 if(count == 0) 704 709 [self showWindow:self]; … … 1311 1316 _listing--; 1312 1317 1313 if([transfer numberOf Pairs] > 0) {1318 if([transfer numberOfFiles] > 0) { 1314 1319 [self _requestDownload:transfer first:YES]; 1315 1320 } else { … … 1347 1352 1348 1353 if([file type] == WCFileFile) { 1349 if([transfer contains PairWithPath:[file path]]) {1354 if([transfer containsFile:file]) { 1350 1355 [transfer setTransferred:[transfer transferred] + [file size]]; 1351 1356 [transfer setTransferredFiles:[transfer transferredFiles] + 1]; 1352 [transfer remove PairWithPath:[file path]];1357 [transfer removeFile:file]; 1353 1358 } 1354 1359 } … … 1365 1370 path = [fields safeObjectAtIndex:0]; 1366 1371 free = [fields safeObjectAtIndex:1]; 1367 1368 1372 transfer = [self _transferWithPath:path]; 1369 1373 … … 1373 1377 _listing--; 1374 1378 1375 if([transfer numberOf Pairs] > 0) {1379 if([transfer numberOfFiles] > 0) { 1376 1380 [self _requestUpload:transfer first:YES]; 1377 1381 } else {
