22
22
You should have received a copy of the GNU Library General Public
23
23
License along with this library; if not, write to the Free
24
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
24
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
28
<heading>File management</heading>
30
<heading>Path handling</heading>
31
<p>The rules for path handling depend on the value in the
32
<code>GNUSTEP_PATH_HANDLING</code> environment variable and,
33
to some extent, on the platform on which the program is running.<br />
34
The understood values of GNUSTEP_PATH_HANDLING are <em>unix</em>
35
and <em>windows</em>. If GNUSTEP_PATH_HANDLING is any other value
36
(or has not been set), GNUstep interprets this as meaning
37
it should try to <em>do-the-right-thing</em><br />
38
In the default mode of operation the system is very tolerant
39
of paths and allows you to work with both unix and windows
40
style paths. The consequences of this are apparent in the
41
path handling methods of [NSString] rather than in [NSFileManager].
44
<heading>unix</heading>
45
<p>On all Unix platforms, Path components are separated by slashes
46
and file names may contain any character other than slash.<br />
47
The file names . and .. are special cases meaning current directory
48
and the parent of the current directory respectively.<br />
49
Multiple adjacent slash characters are treated as a single separator.
51
Here are various examples:
54
<desc>An absolute path to the root directory.
56
<term>/etc/motd</term>
57
<desc>An absolute path to the file named <em>motd</em>
58
in the subdirectory <em>etc</em> of the root directory.
61
<desc>A relative path to the parent of the current directory.
63
<term>program.m</term>
64
<desc>A relative path to the file <em>program.m</em>
65
in the current directory.
67
<term>Source/program.m</term>
68
<desc>A relative path to the file <em>program.m</em> in the
69
subdirectory <em>Source</em> of the current directory.
71
<term>../GNUmakefile</term>
72
<desc>A relative path to the file <em>GNUmakefile</em>
73
in the directory above the current directory.
78
<heading>windows</heading>
79
<p>On Microsoft Windows the native paths may be either UNC
80
or drive-relative, so GNUstep supports both.<br />
81
Either or both slash (/) and backslash (\) may be used as
82
separators for path components in either type of name.<br />
83
UNC paths follow the general form //host/share/path/file,
84
but must at least contain the host and share parts,
85
i.e. //host/share is a UNC path, but //host is <em>not</em><br />
86
Drive-relative names consist of an optional drive specifier
87
(consisting of a single letter followed by a single colon)
88
followed by an absolute or relative path.<br />
89
In both forms, the names . and .. are refer to the current
90
directory and the parent directory as in unix paths.
92
Here are various examples:
94
<term>//host/share/file</term>
95
<desc>An absolute UNC path to a file called <em>file</em>
96
in the top directory of the export point share on host.
99
<desc>A relative path to the current directory on drive C.
101
<term>C:program.m</term>
102
<desc>A relative path to the file <em>program.m</em> on drive C.
104
<term>C:\program.m</term>
105
<desc>An absolute path to the file <em>program.m</em>
106
in the top level directory on drive C.
108
<term>/Source\program.m</term>
109
<desc>A drive-relative path to <em>program.m</em> in the directory
110
<em>Source</em> on the current drive.
113
<desc>A drive-relative path to <em>name</em> in the top level directory
114
on the current drive. The '\\' is treated as a single backslash as
115
this is not a UNC name (there must be both a host and a share part in
121
<heading>gnustep</heading>
122
<p>In the default mode, GNUstep handles both unix and windows paths so
123
it treats both slash (/) and backslash (\) as separators and understands
124
the windows UNC and drive relative path roots.<br />
125
However, it treats any path beginning with a slash (/) as an absolute
126
path <em>if running on a unix system</em>.
130
<heading>Portability</heading>
131
<p>Attempting to pass absolute paths between applications working on
132
different systems is fraught with difficulty ... just don't do it.<br />
133
Where paths need to be passed around (eg. in property lists or archives)
134
you should pass relative paths and use a standard mechanism to construct
135
an absolute path in the receiving application, for instance, appending
136
the relative path to the home directory of a user.
138
Even using relative paths you should take care ...
140
<item>Use only the slash (/) as a path separator, not backslash (\).
142
<item>Never use a backslash (\) in a file name.
144
<item>Avoid colons in file names.
146
<item>Use no more than three letters in a path extension.
149
Remember that, while GNUstep will manipulate both windows and unix
150
paths, any path actually used to reference a file or directory
151
must be valid on the local system.
154
<heading>Tilde substitution</heading>
155
<p>GNUstep handles substitution of tilde (~) as follows:<br />
156
If a path is just ~ or begins ~/ then the value returned by
157
NSHomeDirectory() is substituted for the tilde.<br />
158
If a path is of the form ~name or begins with a string like ~name/
159
then name is used as the argument to NSHomeDirectoryForUser() and
160
the return value from that method (if non-nil) is used to replace
27
168
#ifndef __NSFileManager_h_GNUSTEP_BASE_INCLUDE
75
216
- (BOOL) fileExistsAtPath: (NSString*)path;
76
217
- (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory;
77
218
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path;
78
- (const char*) fileSystemRepresentationWithPath: (NSString*)path;
80
- (NSString*) localFromOpenStepPath:(NSString*)path;
81
- (NSString*) openStepPathFromLocal:(NSString*)localPath;
221
* Convert from OpenStep internal string format to a string in
222
* the local filesystem format, suitable for passing to system functions.<br />
223
* This representation may vary between filesystems.<br />
224
* Converts the standard path separator ('/') and path extension ('.')
225
* characters to the local representation if necessary.<br />
226
* On mingw32 systems, the filesystem representation is 16-bit unicode and is
227
* expected to be used in conjunction with the variants of system calls which
228
* work with unicode strings.<br />
229
* Raises an exception if the character conversion is not possible.
231
- (const GSNativeChar*) fileSystemRepresentationWithPath: (NSString*)path;
83
233
- (BOOL) isExecutableFileAtPath: (NSString*)path;
84
234
- (BOOL) isDeletableFileAtPath: (NSString*)path;
85
235
- (BOOL) isReadableFileAtPath: (NSString*)path;