4
Copyright (C) 1997,1999 Free Software Foundation, Inc.
6
Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
7
Author: Ovidiu Predescu <ovidiu@net-community.com>
10
This file is part of the GNUstep Base Library.
12
This library is free software; you can redistribute it and/or
13
modify it under the terms of the GNU Library General Public
14
License as published by the Free Software Foundation; either
15
version 2 of the License, or (at your option) any later version.
17
This library is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
Library General Public License for more details.
22
You should have received a copy of the GNU Library General Public
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.
27
#ifndef __NSFileManager_h_GNUSTEP_BASE_INCLUDE
28
#define __NSFileManager_h_GNUSTEP_BASE_INCLUDE
30
#include <Foundation/NSObject.h>
32
#ifndef STRICT_OPENSTEP
33
#include <Foundation/NSUtilities.h>
34
#include <Foundation/NSDictionary.h>
41
@class NSMutableArray;
43
@class NSDirectoryEnumerator;
45
@interface NSFileManager : NSObject
50
+ (NSFileManager*) defaultManager;
52
- (BOOL) changeCurrentDirectoryPath: (NSString*)path;
53
- (BOOL) changeFileAttributes: (NSDictionary*)attributes
54
atPath: (NSString*)path;
55
- (NSArray*) componentsToDisplayForPath: (NSString*)path;
56
- (NSData*) contentsAtPath: (NSString*)path;
57
- (BOOL) contentsEqualAtPath: (NSString*)path1
58
andPath: (NSString*)path2;
59
- (BOOL) copyPath: (NSString*)source
60
toPath: (NSString*)destination
62
- (BOOL) createDirectoryAtPath: (NSString*)path
63
attributes: (NSDictionary*)attributes;
64
- (BOOL) createFileAtPath: (NSString*)path
65
contents: (NSData*)contents
66
attributes: (NSDictionary*)attributes;
67
- (BOOL) createSymbolicLinkAtPath: (NSString*)path
68
pathContent: (NSString*)otherPath;
69
- (NSString*) currentDirectoryPath;
70
- (NSArray*) directoryContentsAtPath: (NSString*)path;
71
- (NSString*) displayNameAtPath: (NSString*)path;
72
- (NSDirectoryEnumerator*) enumeratorAtPath: (NSString*)path;
73
- (NSDictionary*) fileAttributesAtPath: (NSString*)path
74
traverseLink: (BOOL)flag;
75
- (BOOL) fileExistsAtPath: (NSString*)path;
76
- (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory;
77
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path;
78
- (const char*) fileSystemRepresentationWithPath: (NSString*)path;
80
- (NSString*) localFromOpenStepPath:(NSString*)path;
81
- (NSString*) openStepPathFromLocal:(NSString*)localPath;
83
- (BOOL) isExecutableFileAtPath: (NSString*)path;
84
- (BOOL) isDeletableFileAtPath: (NSString*)path;
85
- (BOOL) isReadableFileAtPath: (NSString*)path;
86
- (BOOL) isWritableFileAtPath: (NSString*)path;
87
- (BOOL) linkPath: (NSString*)source
88
toPath: (NSString*)destination
90
- (BOOL) movePath: (NSString*)source
91
toPath: (NSString*)destination
93
- (NSString*) pathContentOfSymbolicLinkAtPath: (NSString*)path;
94
- (BOOL) removeFileAtPath: (NSString*)path
96
- (NSString*) stringWithFileSystemRepresentation: (const char*)string
97
length: (unsigned int)len;
98
- (NSArray*) subpathsAtPath: (NSString*)path;
100
@end /* NSFileManager */
103
* An informal protocol to which handler objects should conform
104
* if they wish to deal with copy and move operations performed
107
@interface NSObject (NSFileManagerHandler)
109
* <p>When an error occurs during a copy or move operation, the file manager
110
* will send this message to the handler, and will use the return value to
111
* determine whether the operation should proceed. If the method returns
112
* YES then the operation will proceed after the error, if it returns NO
113
* then it will be aborted.
115
* <p>If the handler does not implement this method it will be treated as
118
* The error dictionary contains the following
120
* <item><strong>"Error"</strong>
121
* contains a description of the error.
123
* <item><strong>"Path"</strong>
124
* contains the path that is being processed when
125
* an error occured. If an error occurs during an
126
* operation involving two files, like copying, and
127
* it is not clear which file triggers the error it
128
* will default to the source file.
130
* <item><strong>"FromPath"</strong>
131
* (Optional) contains the path involved in reading.
133
* <item><strong>"ToPath"</strong>
134
* (Optional) contains the path involved in writing.
138
* <p>Note that the <code>FromPath</code> is a GNUstep extension.
140
* <p>Also the <code>FromPath</code> and <code>ToPath</code> are filled
141
* in when appropriate. So when copying a file they will typically
142
* both have a value and when reading only <code>FromPath</code>.
145
- (BOOL) fileManager: (NSFileManager*)fileManager
146
shouldProceedAfterError: (NSDictionary*)errorDictionary;
149
* The file manager sends this method to the handler immediately before
150
* performing part of a directory move or copy operation. This provides
151
* the handler object with information it can use in the event of an
152
* error, to decide whether processing should proceed after the error.
154
- (void) fileManager: (NSFileManager*)fileManager
155
willProcessPath: (NSString*)path;
159
@interface NSDirectoryEnumerator : NSEnumerator
161
void *_stack; /* GSIArray */
163
NSString *_currentFilePath;
164
NSString *(*_openStepPathFromLocalImp)(id, SEL, id);
169
BOOL justContents: 1;
173
- (id) initWithDirectoryPath: (NSString*)path
174
recurseIntoSubdirectories: (BOOL)recurse
175
followSymlinks: (BOOL)follow
176
justContents: (BOOL)justContents;
178
- (NSDictionary*) directoryAttributes;
179
- (NSDictionary*) fileAttributes;
180
- (void) skipDescendents;
182
@end /* NSDirectoryEnumerator */
184
/* File Attributes */
185
/** File attribute key in dictionary returned by
186
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
187
GS_EXPORT NSString* const NSFileAppendOnly;
188
/** File attribute key in dictionary returned by
189
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
190
GS_EXPORT NSString* const NSFileCreationDate;
191
/** File attribute key in dictionary returned by
192
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
193
GS_EXPORT NSString* const NSFileDeviceIdentifier;
194
/** File attribute key in dictionary returned by
195
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
196
GS_EXPORT NSString* const NSFileExtensionHidden;
197
/** File attribute key in dictionary returned by
198
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
199
GS_EXPORT NSString* const NSFileGroupOwnerAccountID;
200
/** File attribute key in dictionary returned by
201
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
202
GS_EXPORT NSString* const NSFileGroupOwnerAccountName;
203
/** File attribute key in dictionary returned by
204
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
205
GS_EXPORT NSString* const NSFileHFSCreatorCode;
206
/** File attribute key in dictionary returned by
207
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
208
GS_EXPORT NSString* const NSFileHFSTypeCode;
209
/** File attribute key in dictionary returned by
210
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
211
GS_EXPORT NSString* const NSFileImmutable;
212
/** File attribute key in dictionary returned by
213
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
214
GS_EXPORT NSString* const NSFileModificationDate;
215
/** File attribute key in dictionary returned by
216
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
217
GS_EXPORT NSString* const NSFileOwnerAccountID;
218
/** File attribute key in dictionary returned by
219
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
220
GS_EXPORT NSString* const NSFileOwnerAccountName;
221
/** File attribute key in dictionary returned by
222
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
223
GS_EXPORT NSString* const NSFilePosixPermissions;
224
/** File attribute key in dictionary returned by
225
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
226
GS_EXPORT NSString* const NSFileReferenceCount;
227
/** File attribute key in dictionary returned by
228
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
229
GS_EXPORT NSString* const NSFileSize;
230
/** File attribute key in dictionary returned by
231
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
232
GS_EXPORT NSString* const NSFileSystemFileNumber;
233
/** File attribute key in dictionary returned by
234
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
235
GS_EXPORT NSString* const NSFileSystemNumber;
236
/** File attribute key in dictionary returned by
237
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
238
GS_EXPORT NSString* const NSFileType;
242
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
243
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
244
GS_EXPORT NSString* const NSFileTypeDirectory;
245
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
246
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
247
GS_EXPORT NSString* const NSFileTypeRegular;
248
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
249
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
250
GS_EXPORT NSString* const NSFileTypeSymbolicLink;
251
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
252
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
253
GS_EXPORT NSString* const NSFileTypeSocket;
254
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
255
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
256
GS_EXPORT NSString* const NSFileTypeFifo;
257
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
258
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
259
GS_EXPORT NSString* const NSFileTypeCharacterSpecial;
260
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
261
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
262
GS_EXPORT NSString* const NSFileTypeBlockSpecial;
263
/** Possible value for '<code>NSFileType</code>' key in dictionary returned by
264
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
265
GS_EXPORT NSString* const NSFileTypeUnknown;
267
/* FileSystem Attributes */
269
/** File system attribute key in dictionary returned by
270
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
271
GS_EXPORT NSString* const NSFileSystemSize;
272
/** File system attribute key in dictionary returned by
273
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
274
GS_EXPORT NSString* const NSFileSystemFreeSize;
275
/** File system attribute key in dictionary returned by
276
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
277
GS_EXPORT NSString* const NSFileSystemNodes;
278
/** File system attribute key in dictionary returned by
279
[NSFileManager-fileAttributesAtPath:traverseLink:]. */
280
GS_EXPORT NSString* const NSFileSystemFreeNodes;
282
/* Easy access to attributes in a dictionary */
284
@interface NSDictionary(NSFileAttributes)
285
- (NSDate*) fileCreationDate;
286
- (BOOL) fileExtensionHidden;
287
- (int) fileHFSCreatorCode;
288
- (int) fileHFSTypeCode;
289
- (BOOL) fileIsAppendOnly;
290
- (BOOL) fileIsImmutable;
291
- (unsigned long long) fileSize;
292
- (NSString*) fileType;
293
- (unsigned long) fileOwnerAccountID;
294
- (NSString*) fileOwnerAccountName;
295
- (unsigned long) fileGroupOwnerAccountID;
296
- (NSString*) fileGroupOwnerAccountName;
297
- (NSDate*) fileModificationDate;
298
- (unsigned long) filePosixPermissions;
299
- (unsigned long) fileSystemNumber;
300
- (unsigned long) fileSystemFileNumber;
304
#endif /* __NSFileManager_h_GNUSTEP_BASE_INCLUDE */