573
574
575
576
577
578
579
580
|
@"file", fileName,
@"error", error)];
return -1;
}
return length;
}
@end
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
|
@"file", fileName,
@"error", error)];
return -1;
}
return length;
}
- (OFString *)safeLocalPathForPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
path = [path stringByStandardizingPath];
#if defined(OF_WINDOWS) || defined(OF_MSDOS)
if ([path containsString: @":"] || [path hasPrefix: @"\\"]) {
#elif defined(OF_AMIGAOS)
if ([path containsString: @":"] || [path hasPrefix: @"/"]) {
#else
if ([path hasPrefix: @"/"]) {
#endif
objc_autoreleasePoolPop(pool);
return nil;
}
if ([path length] == 0) {
objc_autoreleasePoolPop(pool);
return nil;
}
/*
* After -[stringByStandardizingPath], everything representing parent
* directory should be at the beginning, so in theory checking the
* first component should be enough. But it does not hurt being
* paranoid and checking all components, just in case.
*/
for (OFString *component in [path pathComponents]) {
#ifdef OF_AMIGAOS
if ([component length] == 0 || [component isEqual: @"/"]) {
#else
if ([component length] == 0 || [component isEqual: @".."]) {
#endif
objc_autoreleasePoolPop(pool);
return nil;
}
}
[path retain];
objc_autoreleasePoolPop(pool);
return [path autorelease];
}
@end
|