ClanLib
2.3.7
|
File I/O device. More...
#include <file.h>
Public Types | |
Enumerations | |
enum | AccessFlags { access_read = 1, access_write = 2, access_read_write = access_read | access_write } |
Access flags. More... | |
enum | ShareFlags { share_read = 1, share_write = 2, share_delete = 4, share_all = share_read + share_write + share_delete } |
File sharing flags. More... | |
enum | OpenMode { open_always, open_existing, open_existing_truncate, create_always, create_new } |
File opening modes. More... | |
enum | Flags { flag_write_through = 1, flag_no_buffering = 2, flag_random_access = 4, flag_sequential_scan = 8 } |
Optimization Flags. More... | |
Enumerations | |
enum | SeekMode { seek_set, seek_cur, seek_end } |
Seeking modes. More... | |
Public Member Functions | |
Construction | |
CL_File () | |
Constructs a file object. More... | |
CL_File (const CL_String &filename) | |
Constructs a file object read only. More... | |
CL_File (const CL_String &filename, OpenMode mode, unsigned int access, unsigned int share=share_all, unsigned int flags=0) | |
Constructs a file object. More... | |
CL_File (const CL_String &filename, OpenMode mode, const CL_SecurityDescriptor &permissions, unsigned int access, unsigned int share=share_all, unsigned int flags=0) | |
Constructs a file object. More... | |
~CL_File () | |
Attributes | |
CL_SecurityDescriptor | get_permissions () const |
Returns the file permissions. More... | |
Operations | |
bool | open (const CL_String &filename) |
Opens a file read only. More... | |
bool | open (const CL_String &filename, OpenMode mode, unsigned int access, unsigned int share=share_all, unsigned int flags=0) |
Opens a file. More... | |
bool | open (const CL_String &filename, OpenMode mode, const CL_SecurityDescriptor &permissions, unsigned int access, unsigned int share=share_all, unsigned int flags=0) |
Opens a file. More... | |
void | close () |
Close file. More... | |
bool | set_permissions (const CL_SecurityDescriptor &permissions) |
Change file permissions. More... | |
Attributes | |
bool | is_null () const |
Returns true if this object is invalid. More... | |
void | throw_if_null () const |
Throw an exception if this object is invalid. More... | |
int | get_size () const |
Returns the size of data stream. More... | |
int | get_position () const |
Returns the position in the data stream. More... | |
bool | is_little_endian () const |
Returns true if the input source is in little endian mode. More... | |
const CL_IODeviceProvider * | get_provider () const |
Returns the provider for this object. More... | |
CL_IODeviceProvider * | get_provider () |
Returns the provider for this object. More... | |
Operations | |
int | send (const void *data, int len, bool send_all=true) |
Send data to device. More... | |
int | receive (void *data, int len, bool receive_all=true) |
Receive data from device. More... | |
int | peek (void *data, int len) |
Peek data from device (data is left in the buffer). More... | |
bool | seek (int position, SeekMode mode=seek_set) |
Seek in data stream. More... | |
int | read (void *data, int len, bool receive_all=true) |
Alias for receive(data, len, receive_all) More... | |
int | write (const void *data, int len, bool send_all=true) |
Alias for send(data, len, send_all) More... | |
void | set_system_mode () |
Changes input data endianess to the local systems mode. More... | |
void | set_big_endian_mode () |
Changes input data endianess to big endian mode. (Default is little endian) More... | |
void | set_little_endian_mode () |
Changes input data endianess to little endian mode. This is the default setting. More... | |
void | write_int64 (cl_byte64 data) |
Writes a signed 64 bit integer to output source. More... | |
void | write_uint64 (cl_ubyte64 data) |
Writes an unsigned 64 bit integer to output source. More... | |
void | write_int32 (cl_byte32 data) |
Writes a signed 32 bit integer to output source. More... | |
void | write_uint32 (cl_ubyte32 data) |
Writes an unsigned 32 bit integer to output source. More... | |
void | write_int16 (cl_byte16 data) |
Writes a signed 16 bit integer to output source. More... | |
void | write_uint16 (cl_ubyte16 data) |
Writes an unsigned 16 bit integer to output source. More... | |
void | write_int8 (cl_byte8 data) |
Writes a signed 8 bit integer to output source. More... | |
void | write_uint8 (cl_ubyte8 data) |
Writes an unsigned 8 bit integer to output source. More... | |
void | write_float (float data) |
Writes a float to output source. More... | |
void | write_string_a (const CL_StringRef8 &str) |
Writes a string to the output source. More... | |
void | write_string_nul (const CL_StringRef8 &str) |
Writes a nul terminated string to the output source. More... | |
void | write_string_text (const CL_StringRef8 &str) |
Writes a text string to the output source. More... | |
cl_byte64 | read_int64 () |
Reads a signed 64 bit integer from input source. More... | |
cl_ubyte64 | read_uint64 () |
Reads an unsigned 64 bit integer from input source. More... | |
cl_byte32 | read_int32 () |
Reads a signed 32 bit integer from input source. More... | |
cl_ubyte32 | read_uint32 () |
Reads an unsigned 32 bit integer from input source. More... | |
cl_byte16 | read_int16 () |
Reads a signed 16 bit integer from input source. More... | |
cl_ubyte16 | read_uint16 () |
Reads an unsigned 16 bit integer from input source. More... | |
cl_byte8 | read_int8 () |
Reads a signed 8 bit integer from input source. More... | |
cl_ubyte8 | read_uint8 () |
Reads an unsigned 8 bit integer from input source. More... | |
float | read_float () |
Reads a float from input source. More... | |
CL_String8 | read_string_a () |
Reads a string from the input source. More... | |
CL_String8 | read_string_nul () |
Reads a nul terminated string from the input source. More... | |
CL_String8 | read_string_text (const char *skip_initial_chars, const char *read_until_chars, bool allow_eof=true) |
Reads a string from the input source where the source is a text file. More... | |
CL_IODevice | duplicate () |
Create a new CL_IODevice referencing the same resource. More... | |
Static Public Member Functions | |
Static helper functions | |
static CL_String | read_text (const CL_String &filename) |
Loads an UTF-8 text file into a string. More... | |
static CL_DataBuffer | read_bytes (const CL_String &filename) |
Loads an file into a byte buffer. More... | |
Protected Attributes | |
Implementation | |
CL_SharedPtr< CL_IODevice_Impl > | impl |
File I/O device.
enum CL_File::AccessFlags |
enum CL_File::Flags |
enum CL_File::OpenMode |
File opening modes.
|
inherited |
enum CL_File::ShareFlags |
CL_File::CL_File | ( | ) |
Constructs a file object.
CL_File::CL_File | ( | const CL_String & | filename) |
Constructs a file object read only.
CL_PathHelp::normalize(filename, CL_PathHelp::path_type_file) is called
CL_File::CL_File | ( | const CL_String & | filename, |
OpenMode | mode, | ||
unsigned int | access, | ||
unsigned int | share = share_all , |
||
unsigned int | flags = 0 |
||
) |
Constructs a file object.
CL_PathHelp::normalize(filename, CL_PathHelp::path_type_file) is called
CL_File::CL_File | ( | const CL_String & | filename, |
OpenMode | mode, | ||
const CL_SecurityDescriptor & | permissions, | ||
unsigned int | access, | ||
unsigned int | share = share_all , |
||
unsigned int | flags = 0 |
||
) |
Constructs a file object.
CL_PathHelp::normalize(filename, CL_PathHelp::path_type_file) is called
CL_File::~CL_File | ( | ) |
void CL_File::close | ( | ) |
Close file.
|
inherited |
Create a new CL_IODevice referencing the same resource.
CL_SecurityDescriptor CL_File::get_permissions | ( | ) | const |
Returns the file permissions.
|
inherited |
Returns the position in the data stream.
Returns -1 if the position is unknown.
|
inherited |
Returns the provider for this object.
|
inherited |
Returns the provider for this object.
|
inherited |
Returns the size of data stream.
Returns -1 if the size is unknown.
|
inherited |
Returns true if the input source is in little endian mode.
|
inlineinherited |
Returns true if this object is invalid.
bool CL_File::open | ( | const CL_String & | filename) |
Opens a file read only.
CL_PathHelp::normalize(filename, CL_PathHelp::path_type_file) is called
bool CL_File::open | ( | const CL_String & | filename, |
OpenMode | mode, | ||
unsigned int | access, | ||
unsigned int | share = share_all , |
||
unsigned int | flags = 0 |
||
) |
Opens a file.
CL_PathHelp::normalize(filename, CL_PathHelp::path_type_file) is called
bool CL_File::open | ( | const CL_String & | filename, |
OpenMode | mode, | ||
const CL_SecurityDescriptor & | permissions, | ||
unsigned int | access, | ||
unsigned int | share = share_all , |
||
unsigned int | flags = 0 |
||
) |
Opens a file.
CL_PathHelp::normalize(filename, CL_PathHelp::path_type_file) is called
|
inherited |
Peek data from device (data is left in the buffer).
data | Data to receive |
len | Maximum length of data to receive |
|
inherited |
Alias for receive(data, len, receive_all)
data | Data to receive |
len | Length to receive |
receive_all | true to receive all the data. false = receive part of the data, if it would block |
|
static |
Loads an file into a byte buffer.
|
inherited |
Reads a float from input source.
Warning, this is not portable
|
inherited |
Reads a signed 16 bit integer from input source.
|
inherited |
Reads a signed 32 bit integer from input source.
|
inherited |
Reads a signed 64 bit integer from input source.
|
inherited |
Reads a signed 8 bit integer from input source.
|
inherited |
Reads a string from the input source.
The binary format expected in the input source is first an uint32 telling the length of the string, and then the string itself.
|
inherited |
Reads a nul terminated string from the input source.
The binary format expected in the input source is a nul terminated string. (The NUL termintor is read, so that the file position is set after the NUL)
|
inherited |
Reads a string from the input source where the source is a text file.
After reading the input source up to "read_until_chars", the file position is set to the first character that was not read. If the file contains NUL characters, then the input is read up to the NUL character, and the file position is set AFTER the NUL)
skip_initial_chars | Ignore any of these characters at the start of the string. NULL = Do not ignore any characters |
read_until_chars | Read from the input until any of these characters are found. NULL = Read until the end of the file |
allow_eof | Allow EOF |
Loads an UTF-8 text file into a string.
|
inherited |
Reads an unsigned 16 bit integer from input source.
|
inherited |
Reads an unsigned 32 bit integer from input source.
|
inherited |
Reads an unsigned 64 bit integer from input source.
|
inherited |
Reads an unsigned 8 bit integer from input source.
|
inherited |
Receive data from device.
data | Data to receive |
len | Length to receive |
receive_all | true to receive all the data. false = receive part of the data, if it would block |
Seek in data stream.
position | Position to use (usage depends on the seek mode) |
mode | Seek mode |
|
inherited |
Send data to device.
If the device databuffer is too small, it will be extended (ie grow memory block size or file size)
data | Data to send |
len | Length to send |
send_all | true to send all the data. false = send part of the data, if it would block |
|
inherited |
Changes input data endianess to big endian mode. (Default is little endian)
|
inherited |
Changes input data endianess to little endian mode. This is the default setting.
bool CL_File::set_permissions | ( | const CL_SecurityDescriptor & | permissions) |
Change file permissions.
|
inherited |
Changes input data endianess to the local systems mode.
|
inherited |
Throw an exception if this object is invalid.
|
inherited |
Alias for send(data, len, send_all)
data | Data to send |
len | Length to send |
send_all | true to send all the data. false = send part of the data, if it would block |
|
inherited |
Writes a float to output source.
data | = Float to write |
Warning, this is not portable.
|
inherited |
Writes a signed 16 bit integer to output source.
data | Integer to write |
|
inherited |
Writes a signed 32 bit integer to output source.
data | Integer to write |
|
inherited |
Writes a signed 64 bit integer to output source.
data | Integer to write |
|
inherited |
Writes a signed 8 bit integer to output source.
data | Integer to write |
|
inherited |
Writes a string to the output source.
str | String to write |
The binary format written to the output source is first an uint32 telling the length of the string, and then the string itself.
|
inherited |
Writes a nul terminated string to the output source.
str | String to write |
The binary format written to the output source is the string content followed by the NUL character.
|
inherited |
Writes a text string to the output source.
str | String to write |
The binary format written to the output source is the string content appended with a native newline. On Windows the newline is CR+LF sequence and on other platforms it is only LF character. This function is intended for use with text files.
|
inherited |
Writes an unsigned 16 bit integer to output source.
data | Integer to write |
|
inherited |
Writes an unsigned 32 bit integer to output source.
data | Integer to write |
|
inherited |
Writes an unsigned 64 bit integer to output source.
data | Integer to write |
|
inherited |
Writes an unsigned 8 bit integer to output source.
data | Integer to write |
|
protectedinherited |
Referenced by CL_HTTPServerConnection::is_null().