IsFileOnARemoteVolume
IsFileOnARemoteVolume
- Subject: IsFileOnARemoteVolume
- From: "gMail.com" <email@hidden>
- Date: Thu, 11 Mar 2010 15:53:52 +0100
- Thread-topic: IsFileOnARemoteVolume
I am trying to code my own API isFileOnARemoteVolume since I didn't find
anything similar on Cocoa. If any, please let me know.
I use statfs to detect whether the filePath I pass as variable is on a
remote volume. Anyway, this wont work in case of broken symlinks.
So I have used a dirty trick to get the volumePath then I pass the
volumePath to the function statfs. Did I do right? Is a better or faster
way?
- (BOOL)isFileOnARemoteVolume:(NSString*)filePath
{
if([filePath length] == 0 ||
[filePath characterAtIndex:0] != '/') return NO;
NSMutableString *volumePath = [NSMutableString
stringWithString:@"/"];
if([filePath startsWith:@"/Volumes"]){
NSArray *comps = [filePath componentsSeparatedByString:@"/"];
[volumePath appendString:[comps objectAtIndex:1]];
[volumePath appendString:@"/"];
[volumePath appendString:[comps objectAtIndex:2]];
}
const char *cPathVolume = [mManager
fileSystemRepresentationWithPath:volumePath];
struct statfs stf;
if(statfs(cPathVolume, &stf) != 0) return NO;
BOOL isRemoteVolume = ((stf.f_flags & MNT_LOCAL) == 0);
return isRemoteVolume;
}
On the previous version of this method I used FSGetVolParms then
(volParms.vMServerAdr != 0) but now I would like to avoid to use the Carbon
routines.
Regards
--
Leonardo
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden