- Inherits from:
- Object
- Conforms to:
- DDataReadable, DDataWritable, DTextReadable, DTextWritable
- Declared in:
- DFile.h
Object
|
+---DFile
Class Description
The DFile class implements a number of methods for opening of, writing to,
reading from and closing of files.
- Last modified:
- 03-Nov-2005 (DFile.h)
Instance Variables
- private FILE *_file
- the file object
- Constructors
- - (DFile *) init
- Initialise an empty file object
- Returns:
- the object
- - (DFile *) init :(const char *) name :(const char *) mode
- Open a file
- Parameters:
- name - the filename (c-string)
mode - the file mode (c-string) (r,r+,w,w+,a,a+)
- Returns:
- the object
- Deconstructor
- - free
- Free the object
- Returns:
- the file object
- Copy related methods
- - deepen
- Deepen a copied object (not implemented)
- Returns:
- the object
- File info methods
- - (int) error
- Return the last error
- Returns:
- the last error
- - (int) fileno
- Return the file descriptor
- Returns:
- the file descriptor (or -1 on error)
- - (BOOL) isAtty
- Check if the file is an interactive terminal
- Returns:
- is it ?
- - (BOOL) isOpen
- Check if the file is open
- Returns:
- is the file open ?
- File opening methods
- - (BOOL) open :(const char *) name :(const char *) mode
- Open a file
- Parameters:
- name - the filename
mode - the file mode (r,r+,w,w+,a,a+)
- Returns:
- is the file open ?
- TextReadable protocol implementation
- - (BOOL) isEof
- Check if the end of the file is reached
- Returns:
- is it?
- - (char) readChar
- Read a character
- Returns:
- the character read (EOS for EOF)
- - (DText *) readLine
- Read a line of text (till Eof or \n)
- Returns:
- a (new) text string (or nil for no data)
- - (DText *) readText
- Read a text string (all available text)
- Returns:
- a (new) text string
- - (DText *) readText :(long) length
- Read a text string
- Parameters:
- length - the length of the text to be read
- Returns:
- a (new) text string
- - (BOOL) seek :(unsigned long) offset :(int) origin
- Move the current position in the readable
- Parameters:
- offset - the offset from the origin (in bytes)
origin - the origin for the offset (0=begin, 1=current, 2=end)
- Returns:
- success
- - (BOOL) skip :(unsigned long) offset
- Skip a number of positions
- Parameters:
- offset - the number of bytes to skip
- Returns:
- success
- - (unsigned long) tell
- Tell the current position in the readable
- Returns:
- the current position (or -1 for error)
- Implementation of DTextWritable
- - (BOOL) writeChar :(char) ch
- Write a character
- Parameters:
- ch - the character to be written
- Returns:
- success
- - (BOOL) writeLine :(const char *) text
- Write line (appending a '\n')
- Parameters:
- text - the text to be written
- Returns:
- success
- - (BOOL) writeText :(const char *) text
- Write text string
- Parameters:
- text - the text to be written
- Returns:
- success
- Methods for DDataReadable protocol
- - (unsigned char) readByte
- Read a byte
- Returns:
- the byte read (0 for error)
- - (DData *) readData :(unsigned long) length
- Read a data string
- Parameters:
- length - the length of the data
- Returns:
- the object
- - (double) readDouble
- Read a double
- Returns:
- the double
- - (long) readLong
- Read a long
- Returns:
- the long
- - (short) readShort
- Read a short
- Returns:
- the short
- DDataWritable protocol implementation
- - (BOOL) writeByte :(unsigned char) byte
- Write a byte
- Parameters:
- byte - the byte to be written
- Returns:
- success
- - (BOOL) writeData :(const unsigned char *) text :(unsigned long) length
- Write a data string
- Parameters:
- data - the data to be written
length - the length of the data
- Returns:
- success
- - (BOOL) writeDouble :(double) nr
- Write a double
- Parameters:
- nr - the double to be written
- Returns:
- success
- - (BOOL) writeLong :(long) nr
- Write a long
- Parameters:
- nr - the long to be written
- Returns:
- success
- - (BOOL) writeShort :(short) nr
- Write a short
- Parameters:
- nr - the short to be written
- Returns:
- success
- List related methods
- - (DList *) readLines
- Read all lines from a file into a list of strings
- Returns:
- a (new) list of (new) DText objects
- - (BOOL) writeLines :(DList *) list
- Writes all the elements ('lines') of text from a list to file
- Parameters:
- list - the list with objects that responds to textable protocol
- Returns:
- success
- File manipulation
- - (BOOL) flush
- Flush the output buffers of the file
- Returns:
- success
- - (BOOL) truncate :(long) size
- Truncate the file (not implemented for WIN32)
- Parameters:
- size - the location of the truncation (-1 = current file position)
- Returns:
- success
- File closing methods
- - close
- Close the file
- Returns:
- the file object
- Class methods
- + (DDateTime *) accessed :(const char *) path
- Return the last accessed time of a file
- Parameters:
- path - the path of the file
- Returns:
- a (new) DDateTime object with the last accessed date/time (or nil for error)
- + (int) error
- Return the last error for the class methods
- Returns:
- the last error
- + (BOOL) isDirectory :(const char *) path
- Check if the file exists as directory
- Parameters:
- path - the path of the file/directory
- Returns:
- does it ?
- + (BOOL) isFile :(const char *) path
- Check if the file exists (as file)
- Parameters:
- path - the path of the file
- Returns:
- does it ?
- + (DDateTime *) modified :(const char *) path
- Return the last modified time of a file
- Parameters:
- path - the path of the file
- Returns:
- a (new) DDateTime object with the last modification date/time (or nil for error)
- + (BOOL) move :(const char *) path :(const char *) newPath
- Move/Rename a file
- Parameters:
- path - the current path
newPath - the new path
- Returns:
- success
- + (BOOL) remove :(const char *) path
- Remove a file
- Parameters:
- path - the path
- Returns:
- success
- + (long long) size :(const char *) path
- Return the file size
- Parameters:
- path - the path of the file
- Returns:
- the size in bytes of the file (or -1 for error)
generated 08-Jan-2006 by ObjcDoc 3.0.0