File class

From Solid Graphics Wiki

Jump to: navigation, search
File class
Namespace: SKL
Base type: (None)
Include: SklIO.h
Lib (Release): SKL.lib
Lib (Debug): SKL_D.lib

The File class is a wrapper class for operating system functions dealing with files.


Constructors

The class provides only constructor with no parameters.

If a File class object holds a handle to an open file in time of the object's destruction then the File class destructor closes the file before the object is destroyed.

Fields

The class has no public fields defined.

Methods

Method name Description
Create Creates a new file and opens it for writing in binary mode.
CreateTextFile Creates a new file and opens it for writing in text mode.
OpenFile Opens existing file for reading or read-writing in binary mode.
OpenTextFile Opens existing file for reading in text mode.
Detach Detaches the File class object from the underlying file handle. The method returns the detached underlying file handle (See the Handle method below for more information).
Read Reads specified number of bytes from the file. The file must be opened for reading or read-writing in order for this method to succeeed. The method returns the number of bytes actually read, -1 in case of error.
ReadLine Reads next text line from the file. The file must be opened for reading or read-writing in order for this method to succeeed. The method returns true in case of success, if the file pointer is on the end of the file or in case of error it returns false.
ReadNextNonEmptyLine Reads next non-empty text line from the file. The file must be opened for reading or read-writing in order for this method to succeeed. The method returns true in case of success, if the file pointer is on the end of the file or in case of error it returns false.
Write Writes specified number of bytes to the file. The file must be opened for read-writing in order for this method to succeeed. The method returns the number of bytes actually written to the file, -1 in case of an error.
WriteText Writes text into the file. The file must be opened for read-writing in order for this method to succeeed. The method returns number of bytes written to the file, -1 in case of an error.
FormatAndWriteText Formats the text using format specifier and variable argument list (compatible with the C-runtime library's sprintf function) and writes the result text to the file. The file must be opened for read-writing in order for this method to succeeed. The method returns number of bytes written to the file, in case of error it returns -1.
Position Returns current file pointer position relative to the beginning of the file. In case of error it returns -1.
SeekBegin Moves the file pointer to the beginning of the file. Returns true if successfull, otherwise returns false.
Seek Moves the file pointer to specified position relative to the beginning of the file. Returns true if successfull, otherwise returns false.
Close Closes currently opened file. After the file is closed the File object can be no longer used to write or read additional file content.
Eof Returns true if file pointer is positioned on the end of the file, othrewise returns false.
Size Returns current size of the currently opened file.
IsOpen Returns true if the File object holds a Handle to an open file, otherwise returns false. If file is open the File object can be used to read or write data from/to the file.
Handle If the File object holds handle to an open file then the method returns file's underlying operating system handle , otherwise returns -1. The returned file handle is compatible with C-runtime library's set of low-level I/O file routines, such as _open, _close, _read or _write.
Exist Static method. Returns true if specified file exists and the user's security settings for the file allows to at least list the file, otherwise returns false.
Delete Static method. Deletes specified file from the file-system. Returns true if the file was successfully deleted, returns false if the file does not exist or cannot be deleted. Use GetLastErrorInfo function to retrieve information about the error cause.
CopyTime Static method. Copies created-time, last-written-time and last-accessed-time file attributes from one specified file to another.
Size Static method. Returns size of the specified file.
GetNewTempFileName Static method. Returns a new temporary file name. The returned file name currently does not exist in the file system.
GetDirectoryFilesList Static method. Appends (relative) filenames of the files from specified directory to the specified StringList. Returns true if success, false in case of an error.
GetDirectorySubDirectoriesList Static method. Appends (relative) directory names of the subdirectories of specified directory to the specified StringList. Returns true if success, false in case of an error.

Operators

The class has no public operators defined.


   


SolidKit Library Documentation

Personal tools