ObjFW
Public Member Functions | Static Public Member Functions
OFFile Class Reference

A class which provides functions to read, write and manipulate files. More...

#import <OFFile.h>

Inheritance diagram for OFFile:
OFSeekableStream OFStream OFObject <OFCopying> <OFObject>

List of all members.

Public Member Functions

(id) - initWithPath:mode:
 Initializes an already allocated OFFile.
(id) - initWithFileDescriptor:
 Initializes an already allocated OFFile.

Static Public Member Functions

(id) + fileWithPath:mode:
 Creates a new OFFile with the specified path and mode.
(id) + fileWithFileDescriptor:
 Creates a new OFFile with the specified file descriptor.
(OFString *) + currentDirectoryPath
 Returns the path fo the current working directory.
(BOOL) + fileExistsAtPath:
 Checks whether a file exists at the specified path.
(BOOL) + directoryExistsAtPath:
 Checks whether a directory exists at the specified path.
(void) + createDirectoryAtPath:
 Creates a directory at the specified path.
(OFArray *) + filesInDirectoryAtPath:
 Returns an array with the files in the specified directory.
(void) + changeToDirectory:
 Changes the current working directory.
(OFDate *) + modificationDateOfFile:
 Returns the date of the last modification of the file.
(void) + changeModeOfFile:toMode:
 Changes the mode of a file.
(void) + changeOwnerOfFile:toOwner:group:
 Changes the owner of a file.
(void) + copyFileAtPath:toPath:
 Copies a file.
(void) + renameFileAtPath:toPath:
 Renames a file.
(void) + deleteFileAtPath:
 Deletes a file.
(void) + deleteDirectoryAtPath:
 Deletes an empty directory.
(void) + linkFileAtPath:toPath:
 Creates a hard link for a file.
(void) + symlinkFileAtPath:toPath:
 Creates a symbolink link for a file.

Detailed Description

A class which provides functions to read, write and manipulate files.


Member Function Documentation

+ (void) changeModeOfFile: (OFString*)  path
toMode: (mode_t)  mode 

Changes the mode of a file.

Only changes read-only flag on Windows.

Parameters:
pathThe path to the file of which the mode should be changed as a string
modeThe new mode for the file
+ (void) changeOwnerOfFile: (OFString*)  path
toOwner: (OFString*)  owner
group: (OFString*)  group 

Changes the owner of a file.

Not available on Windows.

Parameters:
pathThe path to the file of which the owner should be changed as a string
ownerThe new owner for the file
groupThe new group for the file
+ (void) changeToDirectory: (OFString*)  path

Changes the current working directory.

Parameters:
pathThe new directory to change to
+ (void) copyFileAtPath: (OFString*)  source
toPath: (OFString*)  destination 

Copies a file.

Parameters:
sourceThe file to copy
destinationThe destination path
+ (void) createDirectoryAtPath: (OFString*)  path

Creates a directory at the specified path.

Parameters:
pathThe path of the directory
+ (OFString *) currentDirectoryPath

Returns the path fo the current working directory.

Returns:
The path of the current working directory
+ (void) deleteDirectoryAtPath: (OFString*)  path

Deletes an empty directory.

Parameters:
pathThe path to the directory which should be deleted as a string
+ (void) deleteFileAtPath: (OFString*)  path

Deletes a file.

Parameters:
pathThe path to the file of which should be deleted as a string
+ (BOOL) directoryExistsAtPath: (OFString*)  path

Checks whether a directory exists at the specified path.

Parameters:
pathThe path to check
Returns:
A boolean whether there is a directory at the specified path
+ (BOOL) fileExistsAtPath: (OFString*)  path

Checks whether a file exists at the specified path.

Parameters:
pathThe path to check
Returns:
A boolean whether there is a file at the specified path
+ (OFArray *) filesInDirectoryAtPath: (OFString*)  path

Returns an array with the files in the specified directory.

Parameters:
pathThe path of the directory
Returns:
An array of OFStrings with the files at the specified path
+ (id) fileWithFileDescriptor: (int)  fileDescriptor

Creates a new OFFile with the specified file descriptor.

Parameters:
fileDescriptorA file descriptor, returned from for example open(). It is not closed when the OFFile object is deallocated!
Returns:
A new autoreleased OFFile
+ (id) fileWithPath: (OFString*)  path
mode: (OFString*)  mode 

Creates a new OFFile with the specified path and mode.

Parameters:
pathThe path to the file to open as a string
modeThe mode in which the file should be opened as a string
Returns:
A new autoreleased OFFile
- (id) initWithFileDescriptor: (int)  fileDescriptor

Initializes an already allocated OFFile.

Parameters:
fileDescriptorA file descriptor, returned from for example open(). It is not closed when the OFFile object is deallocated!
- (id) initWithPath: (OFString*)  path
mode: (OFString*)  mode 

Initializes an already allocated OFFile.

Parameters:
pathThe path to the file to open as a string
modeThe mode in which the file should be opened as a string
Returns:
An initialized OFFile
+ (void) linkFileAtPath: (OFString*)  source
toPath: (OFString*)  destination 

Creates a hard link for a file.

Not available on Windows.

Parameters:
sourceThe path to the file of which should be linked as a string
destinationThe path to where the file should be linked as a string
+ (OFDate *) modificationDateOfFile: (OFString*)  path

Returns the date of the last modification of the file.

Returns:
The date of the last modification of the file
+ (void) renameFileAtPath: (OFString*)  source
toPath: (OFString*)  destination 

Renames a file.

Parameters:
sourceThe file to rename
destinationThe new name
+ (void) symlinkFileAtPath: (OFString*)  source
toPath: (OFString*)  destination 

Creates a symbolink link for a file.

Not available on Windows.

Parameters:
sourceThe path to the file of which should be symlinked as a string
destinationThe path to where the file should be symlinked as a string

The documentation for this class was generated from the following files:
 All Classes Functions Variables Properties