~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Headers/Foundation/NSFileManager.h

Tags: upstream-1.11.2
ImportĀ upstreamĀ versionĀ 1.11.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*-objc-*-
 
1
/**
2
2
   NSFileManager.h
3
3
 
4
 
   Copyright (C) 1997,1999 Free Software Foundation, Inc.
 
4
   Copyright (C) 1997,1999-2005 Free Software Foundation, Inc.
5
5
 
6
6
   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
7
7
   Author: Ovidiu Predescu <ovidiu@net-community.com>
21
21
 
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.
 
25
 
 
26
 
 
27
<chapter>
 
28
  <heading>File management</heading>
 
29
  <section>
 
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].
 
42
    </p>
 
43
    <subsect>
 
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.
 
50
      </p>
 
51
      Here are various examples:
 
52
      <deflist>
 
53
        <term>/</term>
 
54
        <desc>An absolute path to the root directory. 
 
55
        </desc>
 
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. 
 
59
        </desc>
 
60
        <term>..</term>
 
61
        <desc>A relative path to the parent of the current directory. 
 
62
        </desc>
 
63
        <term>program.m</term>
 
64
        <desc>A relative path to the file <em>program.m</em>
 
65
        in the current directory. 
 
66
        </desc>
 
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. 
 
70
        </desc>
 
71
        <term>../GNUmakefile</term>
 
72
        <desc>A relative path to the file <em>GNUmakefile</em>
 
73
        in the directory above the current directory.
 
74
        </desc>
 
75
      </deflist>
 
76
    </subsect>
 
77
    <subsect>
 
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.
 
91
      </p>
 
92
      Here are various examples:
 
93
      <deflist>
 
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.
 
97
        </desc>
 
98
        <term>C:</term>
 
99
        <desc>A relative path to the current directory on drive C.
 
100
        </desc>
 
101
        <term>C:program.m</term>
 
102
        <desc>A relative path to the file <em>program.m</em> on drive C.
 
103
        </desc>
 
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.
 
107
        </desc>
 
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.
 
111
        </desc>
 
112
        <term>\\name</term>
 
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
 
116
        a UNC name).
 
117
        </desc>
 
118
      </deflist>
 
119
    </subsect>
 
120
    <subsect>
 
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>.
 
127
      </p>
 
128
    </subsect>
 
129
    <subsect>
 
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.
 
137
      </p>
 
138
      Even using relative paths you should take care ...
 
139
      <list>
 
140
        <item>Use only the slash (/) as a path separator, not backslash (\).
 
141
        </item>
 
142
        <item>Never use a backslash (\) in a file name.
 
143
        </item>
 
144
        <item>Avoid colons in file names.
 
145
        </item>
 
146
        <item>Use no more than three letters in a path extension.
 
147
        </item>
 
148
      </list>
 
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.
 
152
    </subsect>
 
153
    <subsect>
 
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
 
161
      the tilde.
 
162
      </p>
 
163
    </subsect>
 
164
  </section>
 
165
</chapter>
25
166
*/
26
167
 
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;
79
 
#ifndef NO_GNUSTEP
80
 
- (NSString*) localFromOpenStepPath:(NSString*)path;
81
 
- (NSString*) openStepPathFromLocal:(NSString*)localPath;
82
 
#endif
 
219
 
 
220
/**
 
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.
 
230
 */
 
231
- (const GSNativeChar*) fileSystemRepresentationWithPath: (NSString*)path;
 
232
 
83
233
- (BOOL) isExecutableFileAtPath: (NSString*)path;
84
234
- (BOOL) isDeletableFileAtPath: (NSString*)path;
85
235
- (BOOL) isReadableFileAtPath: (NSString*)path;
93
243
- (NSString*) pathContentOfSymbolicLinkAtPath: (NSString*)path;
94
244
- (BOOL) removeFileAtPath: (NSString*)path
95
245
                  handler: (id)handler;
96
 
- (NSString*) stringWithFileSystemRepresentation: (const char*)string
 
246
 
 
247
/**
 
248
 * Convert to OpenStep internal string format from a string in
 
249
 * the local filesystem format, as returned by system functions.<br />
 
250
 * This representation may vary between filesystems.<br />
 
251
 * The GNUstep version of this method currently does not bother to change
 
252
 * any path separator and extension characters to the standard values
 
253
 * ('/' and '.' respectively) as the path handling methods of [NSString]
 
254
 * should be able to handle native format strings.<br />
 
255
 * On mingw32 systems, the filesystem representation is 16-bit unicode and
 
256
 * is expected to have come from the variant of a system call which works
 
257
 * with unicode strings.
 
258
 */
 
259
- (NSString*) stringWithFileSystemRepresentation: (const GSNativeChar*)string
97
260
                                          length: (unsigned int)len;
 
261
 
98
262
- (NSArray*) subpathsAtPath: (NSString*)path;
99
263
 
100
264
@end /* NSFileManager */
122
286
 *   </item>
123
287
 *   <item><strong>"Path"</strong>
124
288
 *     contains the path that is being processed when
125
 
 *     an error occured.   If an error occurs during an
 
289
 *     an error occurred.   If an error occurs during an
126
290
 *     operation involving two files, like copying, and
127
291
 *     it is not clear which file triggers the error it
128
292
 *     will default to the source file.
158
322
 
159
323
@interface NSDirectoryEnumerator : NSEnumerator
160
324
{
 
325
@private
161
326
  void *_stack; /* GSIArray */
162
327
  NSString *_topPath;
163
328
  NSString *_currentFilePath;
164
 
  NSString *(*_openStepPathFromLocalImp)(id, SEL, id);
 
329
  NSFileManager *_mgr;
165
330
  struct 
166
331
  {
167
332
    BOOL isRecursive: 1;
169
334
    BOOL justContents: 1;
170
335
  } _flags;
171
336
}
172
 
 
173
 
- (id) initWithDirectoryPath: (NSString*)path 
174
 
   recurseIntoSubdirectories: (BOOL)recurse
175
 
              followSymlinks: (BOOL)follow
176
 
                justContents: (BOOL)justContents;
177
 
 
178
337
- (NSDictionary*) directoryAttributes;
179
338
- (NSDictionary*) fileAttributes;
180
339
- (void) skipDescendents;