NSFileManager -fileExistsAtPath and quoting pathnames with spaces
NSFileManager -fileExistsAtPath and quoting pathnames with spaces
- Subject: NSFileManager -fileExistsAtPath and quoting pathnames with spaces
- From: Greg Anderson <email@hidden>
- Date: Thu, 28 Aug 2003 16:35:34 -0500
Through some testing, it seems that the NSString that gets passed to
-fileExistsAtPath needs to be single-quoted if it has spaces in the
pathname. For example, assuming you have a file that exists at:
/Users/theuser/Documents/My Cool Doc.txt
[NSFileManager defaultManager]
fileExistsAtPath:@"/Users/theuser/Documents/My Cool Doc.txt"
will return false. It returns false if you escape out the spaces, too.
But this call:
[NSFileManager defaultManager]
fileExistsAtPath:@"'/Users/theuser/Documents/My Cool Doc.txt'"
will return true. My question is, why does this string need to be
quoted at all? Shouldn't the NSFileManager know that if you're passing
a string in to this method that the entire thing should be a path, and
take care of things like spaces in filenames automagically? I couldn't
find anything in the documentation specifying a requirement for quoting
the pathname, but for now I'll just make sure to surround paths with
single quote marks. If anyone can enlighten me (or point out my error
in thinking) I'd appreciate it.
Greg
---
Greg T. Anderson
Expert Wearer of Pants
http://homepage.mac.com/torgo
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.