ftp.nice.ch/Attic/openStep/implementation/gnustep/sources/libFoundation.0.7.tgz#/libFoundation-0.7/libFoundation/Foundation/NSFileManager.h

This is NSFileManager.h in view mode; [Download] [Up]

/* 
   NSFileManager.h

   Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
   All rights reserved.

   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>

   This file is part of libFoundation.

   Permission to use, copy, modify, and distribute this software and its
   documentation for any purpose and without fee is hereby granted, provided
   that the above copyright notice appear in all copies and that both that
   copyright notice and this permission notice appear in supporting
   documentation.

   We disclaim all warranties with regard to this software, including all
   implied warranties of merchantability and fitness, in no event shall
   we be liable for any special, indirect or consequential damages or any
   damages whatsoever resulting from loss of use, data or profits, whether in
   an action of contract, negligence or other tortious action, arising out of
   or in connection with the use or performance of this software.
*/

#ifndef __NSFileManager_h__
#define __NSFileManager_h__

#include <Foundation/NSObject.h>
#include <Foundation/NSUtilities.h>
#include <Foundation/NSDictionary.h>

@class NSNumber;
@class NSString;
@class NSData;
@class NSDate;
@class NSArray;
@class NSMutableArray;

@class NSDirectoryEnumerator;

@interface NSFileManager : NSObject

// Getting the default manager
+ (NSFileManager*)defaultManager;

// Directory operations
- (BOOL)changeCurrentDirectoryPath:(NSString*)path;
- (BOOL)createDirectoryAtPath:(NSString*)path
  attributes:(NSDictionary*)attributes;
- (NSString*)currentDirectoryPath;

// File operations
- (BOOL)copyPath:(NSString*)source toPath:(NSString*)destination
  handler:handler;
- (BOOL)movePath:(NSString*)source toPath:(NSString*)destination 
  handler:handler;
- (BOOL)linkPath:(NSString*)source toPath:(NSString*)destination
  handler:handler;
- (BOOL)removeFileAtPath:(NSString*)path
  handler: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;

@end /* NSFileManager */


@interface NSObject (NSFileManagerHandler)
- (BOOL)fileManager:(NSFileManager*)fileManager
  shouldProceedAfterError:(NSDictionary*)errorDictionary;
- (void)fileManager:(NSFileManager*)fileManager
  willProcessPath:(NSString*)path;
@end


@interface NSDirectoryEnumerator : NSEnumerator
{
    NSMutableArray*	enumStack;
    NSMutableArray*	pathStack;
    NSString*		currentFileName;
    NSString*		currentFilePath;
    NSString*		topPath;
    struct {
	BOOL		isRecursive:1;
 	BOOL		isFollowing:1;
   } flags;
}

// Initializing
- initWithDirectoryPath:(NSString*)path 
  recurseIntoSubdirectories:(BOOL)recurse
  followSymlinks:(BOOL)follow
  prefixFiles:(BOOL)prefix;

// Getting attributes
- (NSDictionary*)directoryAttributes;
- (NSDictionary*)fileAttributes;

// Skipping subdirectories
- (void)skipDescendents;

@end /* NSDirectoryEnumerator */

/* File Attributes */
extern NSString* NSFileSize;
extern NSString* NSFileModificationDate;
extern NSString* NSFileOwnerAccountNumber;
extern NSString* NSFileGroupOwnerAccountNumber;
extern NSString* NSFileReferenceCount;
extern NSString* NSFileIdentifier;
extern NSString* NSFileDeviceIdentifier;
extern NSString* NSFilePosixPermissions;
extern NSString* NSFileType;

/* File Types */

extern NSString* NSFileTypeDirectory;
extern NSString* NSFileTypeRegular;
extern NSString* NSFileTypeSymbolicLink;
extern NSString* NSFileTypeSocket;
extern NSString* NSFileTypeFifo;
extern NSString* NSFileTypeCharacterSpecial;
extern NSString* NSFileTypeBlockSpecial;
extern NSString* NSFileTypeUnknown;

/* FileSystem Attributes */

extern NSString* NSFileSystemSize;
extern NSString* NSFileSystemFreeSize;
extern NSString* NSFileSystemNodes;
extern NSString* NSFileSystemFreeNodes;
extern NSString* NSFileSystemNumber;

/* Easy access to attributes in a dictionary */

@interface NSDictionary(NSFileAttributes)
- (NSNumber*)fileSize;
- (NSString*)fileType;
- (NSNumber*)fileOwnerAccountNumber;
- (NSNumber*)fileGroupOwnerAccountNumber;
- (NSDate*)fileModificationDate;
- (NSNumber*)filePosixPermissions;
@end


#endif /* __NSFileManager_h__ */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.