~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to Headers/Foundation/NSFileManager.h

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*-objc-*-
 
2
   NSFileManager.h
 
3
 
 
4
   Copyright (C) 1997,1999 Free Software Foundation, Inc.
 
5
 
 
6
   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
 
7
   Author: Ovidiu Predescu <ovidiu@net-community.com>
 
8
   Date: Feb 1997
 
9
 
 
10
   This file is part of the GNUstep Base Library.
 
11
 
 
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.
 
16
   
 
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.
 
21
 
 
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.
 
25
*/
 
26
 
 
27
#ifndef __NSFileManager_h_GNUSTEP_BASE_INCLUDE
 
28
#define __NSFileManager_h_GNUSTEP_BASE_INCLUDE
 
29
 
 
30
#include <Foundation/NSObject.h>
 
31
 
 
32
#ifndef STRICT_OPENSTEP
 
33
#include <Foundation/NSUtilities.h>
 
34
#include <Foundation/NSDictionary.h>
 
35
 
 
36
@class NSNumber;
 
37
@class NSString;
 
38
@class NSData;
 
39
@class NSDate;
 
40
@class NSArray;
 
41
@class NSMutableArray;
 
42
 
 
43
@class NSDirectoryEnumerator;
 
44
 
 
45
@interface NSFileManager : NSObject
 
46
{
 
47
  NSString      *_lastError;
 
48
}
 
49
 
 
50
+ (NSFileManager*) defaultManager;
 
51
 
 
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
 
61
          handler: (id)handler;
 
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;
 
79
#ifndef NO_GNUSTEP
 
80
- (NSString*) localFromOpenStepPath:(NSString*)path;
 
81
- (NSString*) openStepPathFromLocal:(NSString*)localPath;
 
82
#endif
 
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
 
89
          handler: (id)handler;
 
90
- (BOOL) movePath: (NSString*)source
 
91
           toPath: (NSString*)destination 
 
92
          handler: (id)handler;
 
93
- (NSString*) pathContentOfSymbolicLinkAtPath: (NSString*)path;
 
94
- (BOOL) removeFileAtPath: (NSString*)path
 
95
                  handler: (id)handler;
 
96
- (NSString*) stringWithFileSystemRepresentation: (const char*)string
 
97
                                          length: (unsigned int)len;
 
98
- (NSArray*) subpathsAtPath: (NSString*)path;
 
99
 
 
100
@end /* NSFileManager */
 
101
 
 
102
/**
 
103
 * An informal protocol to which handler objects should conform
 
104
 * if they wish to deal with copy and move operations performed
 
105
 * by NSFileManager.
 
106
 */
 
107
@interface NSObject (NSFileManagerHandler)
 
108
/**
 
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.
 
114
 * </p>
 
115
 * <p>If the handler does not implement this method it will be treated as
 
116
 * if it returns NO.
 
117
 * </p>
 
118
 * The error dictionary contains the following
 
119
 * <list>
 
120
 *   <item><strong>"Error"</strong>
 
121
 *     contains a description of the error.
 
122
 *   </item>
 
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.
 
129
 *   </item>          
 
130
 *   <item><strong>"FromPath"</strong>
 
131
 *     (Optional)  contains the path involved in reading.
 
132
 *   </item>
 
133
 *   <item><strong>"ToPath"</strong>
 
134
 *     (Optional)  contains the path involved in writing.
 
135
 *   </item>
 
136
 * </list>
 
137
 *
 
138
 * <p>Note that the <code>FromPath</code> is a GNUstep extension.
 
139
 * </p>
 
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>.
 
143
 * </p>
 
144
 */
 
145
- (BOOL) fileManager: (NSFileManager*)fileManager
 
146
  shouldProceedAfterError: (NSDictionary*)errorDictionary;
 
147
 
 
148
/**
 
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.
 
153
 */
 
154
- (void) fileManager: (NSFileManager*)fileManager
 
155
     willProcessPath: (NSString*)path;
 
156
@end
 
157
 
 
158
 
 
159
@interface NSDirectoryEnumerator : NSEnumerator
 
160
{
 
161
  void *_stack; /* GSIArray */
 
162
  NSString *_topPath;
 
163
  NSString *_currentFilePath;
 
164
  NSString *(*_openStepPathFromLocalImp)(id, SEL, id);
 
165
  struct 
 
166
  {
 
167
    BOOL isRecursive: 1;
 
168
    BOOL isFollowing: 1;
 
169
    BOOL justContents: 1;
 
170
  } _flags;
 
171
}
 
172
 
 
173
- (id) initWithDirectoryPath: (NSString*)path 
 
174
   recurseIntoSubdirectories: (BOOL)recurse
 
175
              followSymlinks: (BOOL)follow
 
176
                justContents: (BOOL)justContents;
 
177
 
 
178
- (NSDictionary*) directoryAttributes;
 
179
- (NSDictionary*) fileAttributes;
 
180
- (void) skipDescendents;
 
181
 
 
182
@end /* NSDirectoryEnumerator */
 
183
 
 
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;
 
239
 
 
240
/* File Types */
 
241
 
 
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;
 
266
 
 
267
/* FileSystem Attributes */
 
268
 
 
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;
 
281
 
 
282
/* Easy access to attributes in a dictionary */
 
283
 
 
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;
 
301
@end
 
302
 
 
303
#endif
 
304
#endif /* __NSFileManager_h_GNUSTEP_BASE_INCLUDE */