discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stringByDeletingLastPathComponent


From: Robert J. Slover
Subject: Re: stringByDeletingLastPathComponent
Date: Sat, 28 Mar 2009 18:02:42 -0400

I'd agree with the original poster in expecting @"//host". According to POSIX, a pair of slashes at the beginning of the path are to be interpreted in an implementation-defined manner (more than 2 get reduced to one). In the few places I've had to write code that processes paths in ordinary C, I leave a pair of slashes at the beginning alone, and also use this to turn off other behaviors (such as resolving symlinks when returning a canonical path). In that way, I can safely use the routines on UNC paths and with other paths that seem to follow the POSIX spec (such as paths relative to a Perforce depot). I think this behavior is a little safer, leaving full resolution of paths that indicate some sort of "specialness" up to whatever it eventually gets handed off to. In any event, reducing a pair of slashes at the beginning of a POSIX path to a single slash removes potentially important information.

http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11

--Robert

On Mar 28, 2009, at 12:40 PM, Markus Hitter wrote:


Am 27.03.2009 um 23:10 schrieb oren:

[@"//host/share" stringByDeletingLastPathComponent] produces @"" and
looks like a bug
the doc said @"//host/share" should produces @"/host/share"
removing ^/ ? looks like a typo there.

FYI, Mac OS X 10.4 produces @"/host" which is what I'd expect.

These extensions to NSString are meant to handle paths, not URLs. Simplifying // to / is correct.


MarKus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/






_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep





reply via email to

[Prev in Thread] Current Thread [Next in Thread]