Implement new methods.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14441 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-09-15 07:51:29 +00:00
parent 33589dec57
commit 9689bbaadf
3 changed files with 67 additions and 49 deletions

View file

@ -1,3 +1,8 @@
2002-09-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: MacOS-X ([componentsToDisplayForPath:]) and
([displayNameAtPath:]) methods imnplemented.
2002-09-13 Adam Fedor <fedor@gnu.org>
* Source/cifframe.m (cifframe_guess_struct_size): Recurse if

View file

@ -47,65 +47,51 @@
NSString *_lastError;
}
// Getting the default manager
+ (NSFileManager*) defaultManager;
// Directory operations
- (BOOL) changeCurrentDirectoryPath: (NSString*)path;
- (BOOL) changeFileAttributes: (NSDictionary*)attributes
atPath: (NSString*)path;
- (NSArray*) componentsToDisplayForPath: (NSString*)path;
- (NSData*) contentsAtPath: (NSString*)path;
- (BOOL) contentsEqualAtPath: (NSString*)path1
andPath: (NSString*)path2;
- (BOOL) copyPath: (NSString*)source
toPath: (NSString*)destination
handler: (id)handler;
- (BOOL) createDirectoryAtPath: (NSString*)path
attributes: (NSDictionary*)attributes;
- (BOOL) createFileAtPath: (NSString*)path
contents: (NSData*)contents
attributes: (NSDictionary*)attributes;
- (BOOL) createSymbolicLinkAtPath: (NSString*)path
pathContent: (NSString*)otherPath;
- (NSString*) currentDirectoryPath;
// File operations
- (BOOL) copyPath: (NSString*)source
- (NSArray*) directoryContentsAtPath: (NSString*)path;
- (NSString*) displayNameAtPath: (NSString*)path;
- (NSDirectoryEnumerator*) enumeratorAtPath: (NSString*)path;
- (NSDictionary*) fileAttributesAtPath: (NSString*)path
traverseLink: (BOOL)flag;
- (BOOL) fileExistsAtPath: (NSString*)path;
- (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory;
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path;
- (const char*) fileSystemRepresentationWithPath: (NSString*)path;
- (BOOL) isExecutableFileAtPath: (NSString*)path;
- (BOOL) isDeletableFileAtPath: (NSString*)path;
- (BOOL) isReadableFileAtPath: (NSString*)path;
- (BOOL) isWritableFileAtPath: (NSString*)path;
- (BOOL) linkPath: (NSString*)source
toPath: (NSString*)destination
handler: (id)handler;
- (BOOL) movePath: (NSString*)source
toPath: (NSString*)destination
handler: (id)handler;
- (BOOL) linkPath: (NSString*)source
toPath: (NSString*)destination
handler: (id)handler;
- (NSString*) pathContentOfSymbolicLinkAtPath: (NSString*)path;
- (BOOL) removeFileAtPath: (NSString*)path
handler: (id)handler;
- (BOOL) createFileAtPath: (NSString*)path
contents: (NSData*)contents
attributes: (NSDictionary*)attributes;
// Getting and comparing file contents
- (NSData*) contentsAtPath: (NSString*)path;
- (BOOL) contentsEqualAtPath: (NSString*)path1
andPath: (NSString*)path2;
// Detemining access to files
- (BOOL) fileExistsAtPath: (NSString*)path;
- (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory;
- (BOOL) isReadableFileAtPath: (NSString*)path;
- (BOOL) isWritableFileAtPath: (NSString*)path;
- (BOOL) isExecutableFileAtPath: (NSString*)path;
- (BOOL) isDeletableFileAtPath: (NSString*)path;
// Getting and setting attributes
- (NSDictionary*) fileAttributesAtPath: (NSString*)path
traverseLink: (BOOL)flag;
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path;
- (BOOL) changeFileAttributes: (NSDictionary*)attributes
atPath: (NSString*)path;
// Discovering directory contents
- (NSArray*) directoryContentsAtPath: (NSString*)path;
- (NSDirectoryEnumerator*) enumeratorAtPath: (NSString*)path;
- (NSArray*) subpathsAtPath: (NSString*)path;
// Symbolic-link operations
- (BOOL) createSymbolicLinkAtPath: (NSString*)path
pathContent: (NSString*)otherPath;
- (NSString*) pathContentOfSymbolicLinkAtPath: (NSString*)path;
// Converting file-system representations
- (const char*) fileSystemRepresentationWithPath: (NSString*)path;
- (NSString*) stringWithFileSystemRepresentation: (const char*)string
length: (unsigned int)len;
- (NSArray*) subpathsAtPath: (NSString*)path;
@end /* NSFileManager */
@ -132,17 +118,13 @@
} _flags;
}
// Initializing
- (id) initWithDirectoryPath: (NSString*)path
recurseIntoSubdirectories: (BOOL)recurse
followSymlinks: (BOOL)follow
justContents: (BOOL)justContents;
// Getting attributes
- (NSDictionary*) directoryAttributes;
- (NSDictionary*) fileAttributes;
// Skipping subdirectories
- (void) skipDescendents;
@end /* NSDirectoryEnumerator */

View file

@ -1238,8 +1238,25 @@ static NSFileManager* defaultManager = nil;
return allOk;
}
// Discovering directory contents
/**
* Returns an array of path components suitably modified for display
* to the end user. This modification may render the returned strings
* unusable for path manipulation, so you should work with two arrays ...
* one returned by this method (for display tio the user), and a
* parallel one returned by [NSString-pathComponents] (for path
* manipulation).
*/
- (NSArray*) componentsToDisplayForPath: (NSString*)path
{
return [path pathComponents];
}
/**
* Returns an array of the contents of the specified directory.<br />
* The listing does <strong>not</strong> recursively list subdirectories.<br />
* The special files '.' and '..' are not listed.<br />
* Returns nil if path is not a directory (or it can't be read for some reason).
*/
- (NSArray*) directoryContentsAtPath: (NSString*)path
{
NSDirectoryEnumerator *direnum;
@ -1277,6 +1294,20 @@ static NSFileManager* defaultManager = nil;
return content;
}
/**
* Returns the name of the file or directory at path. Converts it into
* a format for display to an end user. This may render it unusable as
* part of a file/path name.<br />
* For instance, if a user has elected not to see file extensions, this
* method may return filenames with the extension removed.<br />
* The default operation is to return the result of calling
* [NSString-lastPathComponent] on the path.
*/
- (NSString*) displayNameAtPath: (NSString*)path
{
return [path lastPathComponent];
}
- (NSDirectoryEnumerator*) enumeratorAtPath: (NSString*)path
{
return AUTORELEASE([[NSDirectoryEnumerator alloc]