Classes | |
class | clan::Directory |
Directory utility class. More... | |
class | clan::DirectoryScanner |
Directory scanning class. More... | |
class | clan::Endian |
Endianess management class. More... | |
class | clan::File |
File I/O device. More... | |
class | clan::FileHelp |
File operation helpers. More... | |
class | clan::FileSystem |
Virtual File System (VFS). More... | |
class | clan::FileSystemProvider |
Virtual File System (VFS) file source. More... | |
class | clan::IODevice |
I/O Device interface. More... | |
class | clan::IODeviceProvider |
I/O device provider interface. More... | |
class | clan::MemoryDevice |
Memory I/O device. More... | |
class | clan::PathHelp |
Path helper functions. More... | |
class | clan::ZipArchive |
Zip archive. More... | |
class | clan::ZipFileEntry |
File entry in zip file. More... | |
class | clan::ZipReader |
Zip file reader. More... | |
class | clan::ZipWriter |
Zip file writer. More... | |
class | clan::ZLibCompression |
Deflate compressor. More... | |
Operations | |
static void | clan::Endian::swap (void *data, int type_size, int total_times=1) |
Swaps larger amounts of data between little and big endian. More... | |
static void | clan::Endian::swap_if_big (void *data, int type_size, int total_times=1) |
static void | clan::Endian::swap_if_little (void *data, int type_size, int total_times=1) |
Attributes | |
static bool | clan::Endian::is_system_big () |
Returns true if big endian system. More... | |
static bool | clan::Endian::is_system_64bit () |
Returns true if 64 bit system. More... | |
Operations | |
static bool | clan::Directory::create (const std::string &dir_name, bool recursive=false) |
Create directory. More... | |
static bool | clan::Directory::remove (const std::string &dir_name, bool delete_files=false, bool delete_sub_directories=false) |
Remove directory. More... | |
static bool | clan::Directory::rename (const std::string &old_name, const std::string &new_name) |
Rename directory. More... | |
static bool | clan::Directory::set_current (const std::string &dir_name) |
Change current directory. More... | |
static std::string | clan::Directory::get_current () |
Get current directory. More... | |
static std::string | clan::Directory::get_appdata (const std::string &company_name, const std::string &application_name, const std::string &version, bool create_dirs_if_missing=true) |
Returns the current user's roaming application data directory. More... | |
static std::string | clan::Directory::get_local_appdata (const std::string &company_name, const std::string &application_name, const std::string &version, bool create_dirs_if_missing=true) |
Returns the current user's local (nonroaming) application data directory. More... | |
static std::string | clan::Directory::get_resourcedata (const std::string &application_name, const std::string &data_dir_name="Resources") |
Returns the application resource data directory. More... | |
Construction | |
clan::DirectoryScanner::DirectoryScanner () | |
Constructs directory scanner for iterating over a directory. More... | |
clan::DirectoryScanner::~DirectoryScanner () | |
Destructor. More... | |
Attributes | |
std::string | clan::DirectoryScanner::get_directory_path () |
Gets the directory being scanned. More... | |
std::string | clan::DirectoryScanner::get_name () |
Gets the name of the current file. More... | |
int | clan::DirectoryScanner::get_size () |
Gets the size of the current file. More... | |
std::string | clan::DirectoryScanner::get_pathname () |
Gets the pathname of the current file. More... | |
bool | clan::DirectoryScanner::is_directory () |
Returns true if the current file is a directory. More... | |
bool | clan::DirectoryScanner::is_hidden () |
Returns true if the file is hidden. More... | |
bool | clan::DirectoryScanner::is_readable () |
Returns true if the file is readable by the current user. More... | |
bool | clan::DirectoryScanner::is_writable () |
Returns true if the file is writable by the current user. More... | |
Operations | |
bool | clan::DirectoryScanner::scan (const std::string &pathname) |
Selects the directory to scan through. More... | |
bool | clan::DirectoryScanner::scan (const std::string &pathname, const std::string &pattern) |
Selects the directory to scan through. More... | |
bool | clan::DirectoryScanner::next () |
Find next file in directory scan. More... | |
Static helper functions | |
static std::string | clan::File::read_text (const std::string &filename) |
Loads an UTF-8 text file into a string. More... | |
static DataBuffer | clan::File::read_bytes (const std::string &filename) |
Loads an file into a byte buffer. More... | |
static void | clan::File::write_text (const std::string &filename, const std::string &text, bool write_bom=false) |
Saves an UTF-8 text string to file. More... | |
static void | clan::File::write_bytes (const std::string &filename, const DataBuffer &bytes) |
Saves a byte buffer to file. More... | |
Enumerations | |
enum | clan::File::AccessFlags { clan::File::access_read = 1, clan::File::access_write = 2, clan::File::access_read_write = access_read | access_write } |
Access flags. More... | |
enum | clan::File::ShareFlags { clan::File::share_read = 1, clan::File::share_write = 2, clan::File::share_delete = 4, clan::File::share_all = share_read + share_write + share_delete } |
File sharing flags. More... | |
enum | clan::File::OpenMode { clan::File::open_always, clan::File::open_existing, clan::File::open_existing_truncate, clan::File::create_always, clan::File::create_new } |
File opening modes. More... | |
enum | clan::File::Flags { clan::File::flag_write_through = 1, clan::File::flag_no_buffering = 2, clan::File::flag_random_access = 4, clan::File::flag_sequential_scan = 8 } |
Optimization Flags. More... | |
Construction | |
clan::File::File () | |
Constructs a file object. More... | |
clan::File::File (const std::string &filename) | |
Constructs a file object read only. More... | |
clan::File::File (const std::string &filename, OpenMode mode, unsigned int access, unsigned int share=share_all, unsigned int flags=0) | |
Constructs a file object. More... | |
clan::File::~File () | |
Operations | |
bool | clan::File::open (const std::string &filename) |
Opens a file read only. More... | |
bool | clan::File::open (const std::string &filename, OpenMode mode, unsigned int access, unsigned int share=share_all, unsigned int flags=0) |
Opens a file. More... | |
void | clan::File::close () |
Close file. More... | |
Operations | |
static void | clan::FileHelp::copy_file (const std::string &from, const std::string &to, bool copy_always) |
Copy a file. More... | |
static void | clan::FileHelp::delete_file (const std::string &filename) |
Delete a file. More... | |
static bool | clan::FileHelp::file_exists (const std::string &filename) |
Check if a file exists. More... | |
Construction | |
clan::FileSystem::FileSystem () | |
Constructs a file system. More... | |
clan::FileSystem::FileSystem (FileSystemProvider *provider) | |
Constructs a FileSystem. More... | |
clan::FileSystem::FileSystem (const std::string &path, bool is_zip_file=false) | |
Constructs a FileSystem. More... | |
clan::FileSystem::~FileSystem () | |
Attributes | |
bool | clan::FileSystem::is_null () const |
Returns true if the file system is null. More... | |
bool | clan::FileSystem::is_mount (const std::string &mount_point) |
Returns true if a path is a mount point. More... | |
DirectoryListing | clan::FileSystem::get_directory_listing (const std::string &path_rel) |
Return directory listing for path. More... | |
bool | clan::FileSystem::has_file (const std::string &filename) |
Return true if the root of the filesystem contains the specified file. More... | |
bool | clan::FileSystem::has_directory (const std::string &directory) |
Return true if the root of the filesystem contains the specified directory. More... | |
FileSystemProvider * | clan::FileSystem::get_provider () |
Returns the file source for this file system. More... | |
std::string | clan::FileSystem::get_path () const |
Returns a path to the file source for this file system. More... | |
std::string | clan::FileSystem::get_identifier () const |
Get the identifier of this file source. More... | |
Operations | |
IODevice | clan::FileSystem::open_file (const std::string &filename, File::OpenMode mode=File::open_existing, unsigned int access=File::access_read, unsigned int share=File::share_all, unsigned int flags=0) const |
Opens a file. More... | |
void | clan::FileSystem::mount (const std::string &mount_point, FileSystem fs) |
Mounts a file system at mount point. More... | |
void | clan::FileSystem::mount (const std::string &mount_point, const std::string &path, bool is_zip_file) |
Mounts a file system at mount point. More... | |
void | clan::FileSystem::unmount (const std::string &mount_point) |
Unmount a file system. More... | |
Construction | |
virtual | clan::FileSystemProvider::~FileSystemProvider () |
Operations | |
virtual IODevice | clan::FileSystemProvider::open_file (const std::string &filename, File::OpenMode mode=File::open_existing, unsigned int access=File::access_read|File::access_write, unsigned int share=File::share_all, unsigned int flags=0)=0 |
Open file from this source. More... | |
virtual bool | clan::FileSystemProvider::initialize_directory_listing (const std::string &path)=0 |
Initiate directory listing. More... | |
virtual bool | clan::FileSystemProvider::next_file (DirectoryListingEntry &entry)=0 |
Update directory listing item. More... | |
virtual std::string | clan::FileSystemProvider::get_path () const =0 |
Return the path of this file source. More... | |
virtual std::string | clan::FileSystemProvider::get_identifier () const =0 |
Get the identifier of this file source. More... | |
Enumerations | |
enum | clan::IODevice::SeekMode { clan::IODevice::seek_set, clan::IODevice::seek_cur, clan::IODevice::seek_end } |
Seeking modes. More... | |
Construction | |
clan::IODevice::IODevice () | |
Constructs a null instance. More... | |
clan::IODevice::IODevice (IODeviceProvider *provider) | |
Constructs a IODevice. More... | |
clan::IODevice::~IODevice () | |
Attributes | |
bool | clan::IODevice::is_null () const |
Returns true if this object is invalid. More... | |
void | clan::IODevice::throw_if_null () const |
Throw an exception if this object is invalid. More... | |
int | clan::IODevice::get_size () const |
Returns the size of data stream. More... | |
int | clan::IODevice::get_position () const |
Returns the position in the data stream. More... | |
bool | clan::IODevice::is_little_endian () const |
Returns true if the input source is in little endian mode. More... | |
const IODeviceProvider * | clan::IODevice::get_provider () const |
Returns the provider for this object. More... | |
IODeviceProvider * | clan::IODevice::get_provider () |
Returns the provider for this object. More... | |
Operations | |
int | clan::IODevice::send (const void *data, int len, bool send_all=true) |
Send data to device. More... | |
int | clan::IODevice::receive (void *data, int len, bool receive_all=true) |
Receive data from device. More... | |
int | clan::IODevice::peek (void *data, int len) |
Peek data from device (data is left in the buffer). More... | |
bool | clan::IODevice::seek (int position, SeekMode mode=seek_set) |
Seek in data stream. More... | |
int | clan::IODevice::read (void *data, int len, bool receive_all=true) |
Alias for receive(data, len, receive_all) More... | |
int | clan::IODevice::write (const void *data, int len, bool send_all=true) |
Alias for send(data, len, send_all) More... | |
void | clan::IODevice::set_system_mode () |
Changes input data endianess to the local systems mode. More... | |
void | clan::IODevice::set_big_endian_mode () |
Changes input data endianess to big endian mode. (Default is little endian) More... | |
void | clan::IODevice::set_little_endian_mode () |
Changes input data endianess to little endian mode. This is the default setting. More... | |
void | clan::IODevice::write_int64 (int64_t data) |
Writes a signed 64 bit integer to output source. More... | |
void | clan::IODevice::write_uint64 (uint64_t data) |
Writes an unsigned 64 bit integer to output source. More... | |
void | clan::IODevice::write_int32 (int32_t data) |
Writes a signed 32 bit integer to output source. More... | |
void | clan::IODevice::write_uint32 (uint32_t data) |
Writes an unsigned 32 bit integer to output source. More... | |
void | clan::IODevice::write_int16 (int16_t data) |
Writes a signed 16 bit integer to output source. More... | |
void | clan::IODevice::write_uint16 (uint16_t data) |
Writes an unsigned 16 bit integer to output source. More... | |
void | clan::IODevice::write_int8 (int8_t data) |
Writes a signed 8 bit integer to output source. More... | |
void | clan::IODevice::write_uint8 (uint8_t data) |
Writes an unsigned 8 bit integer to output source. More... | |
void | clan::IODevice::write_float (float data) |
Writes a float to output source. More... | |
void | clan::IODevice::write_string_a (const std::string &str) |
Writes a string to the output source. More... | |
void | clan::IODevice::write_string_nul (const std::string &str) |
Writes a nul terminated string to the output source. More... | |
void | clan::IODevice::write_string_text (const std::string &str) |
Writes a text string to the output source. More... | |
int64_t | clan::IODevice::read_int64 () |
Reads a signed 64 bit integer from input source. More... | |
uint64_t | clan::IODevice::read_uint64 () |
Reads an unsigned 64 bit integer from input source. More... | |
int32_t | clan::IODevice::read_int32 () |
Reads a signed 32 bit integer from input source. More... | |
uint32_t | clan::IODevice::read_uint32 () |
Reads an unsigned 32 bit integer from input source. More... | |
int16_t | clan::IODevice::read_int16 () |
Reads a signed 16 bit integer from input source. More... | |
uint16_t | clan::IODevice::read_uint16 () |
Reads an unsigned 16 bit integer from input source. More... | |
int8_t | clan::IODevice::read_int8 () |
Reads a signed 8 bit integer from input source. More... | |
uint8_t | clan::IODevice::read_uint8 () |
Reads an unsigned 8 bit integer from input source. More... | |
float | clan::IODevice::read_float () |
Reads a float from input source. More... | |
std::string | clan::IODevice::read_string_a () |
Reads a string from the input source. More... | |
std::string | clan::IODevice::read_string_nul () |
Reads a nul terminated string from the input source. More... | |
std::string | clan::IODevice::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... | |
IODevice | clan::IODevice::duplicate () |
Create a new IODevice referencing the same resource. More... | |
Implementation | |
std::shared_ptr< IODevice_Impl > | clan::IODevice::impl |
Construction | |
virtual | clan::IODeviceProvider::~IODeviceProvider () |
Attributes | |
virtual int | clan::IODeviceProvider::get_size () const |
Returns the size of data stream. More... | |
virtual int | clan::IODeviceProvider::get_position () const |
Returns the position in the data stream. More... | |
Operations | |
virtual int | clan::IODeviceProvider::send (const void *data, int len, bool send_all=true)=0 |
Send data to device. More... | |
virtual int | clan::IODeviceProvider::receive (void *data, int len, bool receive_all=true)=0 |
Receive data from device. More... | |
virtual int | clan::IODeviceProvider::peek (void *data, int len)=0 |
Peek data from device. More... | |
virtual IODeviceProvider * | clan::IODeviceProvider::duplicate ()=0 |
Returns a new provider to the same resource. More... | |
virtual bool | clan::IODeviceProvider::seek (int, IODevice::SeekMode) |
Seek in data stream. More... | |
Construction | |
clan::MemoryDevice::MemoryDevice () | |
Constructs a memory I/O device. More... | |
clan::MemoryDevice::MemoryDevice (DataBuffer &data) | |
Constructs a IODevice Memory. More... | |
Attributes | |
const DataBuffer & | clan::MemoryDevice::get_data () const |
Retrieves the data buffer for the memory device. More... | |
DataBuffer & | clan::MemoryDevice::get_data () |
Get Data. More... | |
Operations | |
enum | clan::PathHelp::PathType { clan::PathHelp::path_type_file, clan::PathHelp::path_type_virtual } |
Path types. More... | |
static std::string | clan::PathHelp::make_absolute (const std::string &base_path, const std::string &relative_path, PathType path_type=path_type_file) |
Convert a relative path to an absolute path. More... | |
static std::string | clan::PathHelp::make_relative (const std::string &base_path, const std::string &absolute_path, PathType path_type=path_type_file) |
Converts an absolute path into a path relative to a base path. More... | |
static bool | clan::PathHelp::is_absolute (const std::string &path, PathType path_type=path_type_file) |
Check if a path is absolute. More... | |
static bool | clan::PathHelp::is_relative (const std::string &path, PathType path_type=path_type_file) |
Check if a path is relative. More... | |
static std::string | clan::PathHelp::normalize (const std::string &path, PathType path_type=path_type_file) |
Normalize a path. More... | |
static std::string | clan::PathHelp::add_trailing_slash (const std::string &path, PathType path_type=path_type_file) |
Add trailing slash or backslash to path. More... | |
static std::string | clan::PathHelp::remove_trailing_slash (const std::string &path) |
Remove trailing slash or backslash from path. More... | |
static std::string | clan::PathHelp::get_location (const std::string &fullname, PathType path_type=path_type_file) |
Returns the drive (C:) or share name ( \ \ computer \ share) More... | |
static std::string | clan::PathHelp::get_basepath (const std::string &fullname, PathType path_type=path_type_file) |
Returns the path excluding the location and filename. More... | |
static std::vector< std::string > | clan::PathHelp::split_basepath (const std::string &fullname, PathType path_type=path_type_file) |
Splits the path, excluding the location, into parts. More... | |
static std::string | clan::PathHelp::get_fullpath (const std::string &fullname, PathType path_type=path_type_file) |
Returns the path including the location. More... | |
static std::string | clan::PathHelp::get_filename (const std::string &fullname, PathType path_type=path_type_file) |
Returns the filename part of a fullname. More... | |
static std::string | clan::PathHelp::get_basename (const std::string &fullname, PathType path_type=path_type_file) |
Returns the basename part of a fullname. More... | |
static std::string | clan::PathHelp::get_extension (const std::string &fullname, PathType path_type=path_type_file) |
Returns the extension part of a fullname. More... | |
static std::string | clan::PathHelp::get_fullname (const std::string &fullpath, const std::string &filename, PathType path_type=path_type_file) |
Create a fullname from parts. More... | |
static std::string | clan::PathHelp::get_fullname (const std::string &fullpath, const std::string &filename, const std::string &extension, PathType path_type=path_type_file) |
Create a fullname from parts. More... | |
static std::string | clan::PathHelp::get_fullname (const std::string &location, const std::string &basepath, const std::string &filename, const std::string &extension, PathType path_type=path_type_file) |
Create a fullname from parts. More... | |
static std::string | clan::PathHelp::combine (const std::string &part1, const std::string &part2, PathType path_type=path_type_file) |
Concatenates two strings into one adding a trailing slash to first string if missing. More... | |
Construction | |
clan::ZipArchive::ZipArchive () | |
Constructs or loads a ZIP archive. More... | |
clan::ZipArchive::ZipArchive (IODevice &input) | |
Constructs a ZipArchive. More... | |
clan::ZipArchive::ZipArchive (const std::string &filename) | |
Constructs a ZipArchive. More... | |
clan::ZipArchive::ZipArchive (const ZipArchive ©) | |
Constructs a ZipArchive. More... | |
clan::ZipArchive::~ZipArchive () | |
Attributes | |
std::vector< ZipFileEntry > | clan::ZipArchive::get_file_list () |
List of file entries in archive. More... | |
std::vector< ZipFileEntry > | clan::ZipArchive::get_file_list (const std::string &path) |
Operations | |
IODevice | clan::ZipArchive::open_file (const std::string &filename) |
Opens a file in the archive. More... | |
std::string | clan::ZipArchive::get_pathname (const std::string &filename) |
Get full path to source: More... | |
IODevice | clan::ZipArchive::create_file (const std::string &filename, bool compress=true) |
Creates a new file entry. More... | |
void | clan::ZipArchive::add_file (const std::string &input_filename, const std::string &filename_in_archive) |
Adds a file to zip archive. More... | |
void | clan::ZipArchive::save () |
Saves zip archive. More... | |
void | clan::ZipArchive::save (const std::string &filename) |
Save. More... | |
void | clan::ZipArchive::save (IODevice iodev) |
Save. More... | |
void | clan::ZipArchive::load (IODevice &input) |
Loads the zip archive from a input device (done automatically at construction). More... | |
Construction | |
clan::ZipFileEntry::ZipFileEntry () | |
clan::ZipFileEntry::ZipFileEntry (const ZipFileEntry ©) | |
Constructs a ZipFileEntry. More... | |
clan::ZipFileEntry::~ZipFileEntry () | |
Attributes | |
std::string | clan::ZipFileEntry::get_archive_filename () const |
Returns the filename of file entry. More... | |
std::string | clan::ZipFileEntry::get_input_filename () const |
Returns the filename of file entry. More... | |
int64_t | clan::ZipFileEntry::get_uncompressed_size () |
Returns the uncompressed size of file entry. More... | |
int64_t | clan::ZipFileEntry::get_compressed_size () |
Returns the compressed size of file entry. More... | |
bool | clan::ZipFileEntry::is_directory () const |
Is Directory. More... | |
Operations | |
ZipFileEntry & | clan::ZipFileEntry::operator= (const ZipFileEntry ©) |
Copy assignment operator. More... | |
void | clan::ZipFileEntry::set_input_filename (const std::string &filename) |
Sets the filename of the file to be added to the archive. More... | |
void | clan::ZipFileEntry::set_archive_filename (const std::string &filename) |
Sets the filename of the file inside the archive. More... | |
void | clan::ZipFileEntry::set_directory (bool is_directory) |
Set directory. More... | |
Implementation | |
class | clan::ZipFileEntry::ZipArchive |
class | clan::ZipFileEntry::ZipIODevice_FileEntry |
Construction | |
clan::ZipReader::ZipReader (IODevice &input) | |
Constructs a ZipReader. More... | |
Operations | |
bool | clan::ZipReader::read_local_file_header (bool allow_data_descriptor=false) |
Begins reading a file entry in the zip file. More... | |
std::string | clan::ZipReader::get_filename () |
Returns the file name that was stored in the local file header. More... | |
bool | clan::ZipReader::has_data_descriptor () const |
Returns true if the file entry is followed by a data descriptor. More... | |
int64_t | clan::ZipReader::get_compressed_size () const |
Returns the compressed size of the file entry. More... | |
int64_t | clan::ZipReader::get_uncompressed_size () const |
Returns the uncompressed size of the file entry. More... | |
void | clan::ZipReader::set_data_descriptor_data (int64_t compressed_size, int64_t uncompressed_size, uint32_t crc32) |
Informs the zip reader what the data descriptor contains. More... | |
int64_t | clan::ZipReader::read_file_data (void *data, int64_t size, bool read_all=true) |
Reads some file data from the zip file. More... | |
Construction | |
clan::ZipWriter::ZipWriter (IODevice &output, bool storeFilenamesAsUTF8=false) | |
Constructs a ZipWriter. More... | |
Operations | |
void | clan::ZipWriter::begin_file (const std::string &filename, bool compress) |
Begins file entry in the zip file. More... | |
void | clan::ZipWriter::write_file_data (const void *data, int64_t size) |
Writes some file data to the zip file. More... | |
void | clan::ZipWriter::end_file () |
Ends the file entry. More... | |
void | clan::ZipWriter::write_toc () |
Writes the table of contents part of the zip file. More... | |
Operations | |
enum | clan::ZLibCompression::CompressionMode { clan::ZLibCompression::default_strategy, clan::ZLibCompression::filtered, clan::ZLibCompression::huffman_only, clan::ZLibCompression::rle, clan::ZLibCompression::fixed } |
static DataBuffer | clan::ZLibCompression::compress (const DataBuffer &data, bool raw=true, int compression_level=6, CompressionMode mode=default_strategy) |
static DataBuffer | clan::ZLibCompression::decompress (const DataBuffer &data, bool raw=true) |
Access flags.
File access types available.
Enumerator | |
---|---|
access_read | Generic read access. |
access_write | Generic write access. |
access_read_write | Generic read write access. |
enum clan::File::Flags |
enum clan::File::OpenMode |
File opening modes.
File sharing flags.
clan::DirectoryScanner::DirectoryScanner | ( | ) |
Constructs directory scanner for iterating over a directory.
clan::File::File | ( | ) |
Constructs a file object.
clan::File::File | ( | const std::string & | filename | ) |
Constructs a file object read only.
PathHelp::normalize(filename, PathHelp::path_type_file) is called
clan::File::File | ( | const std::string & | filename, |
OpenMode | mode, | ||
unsigned int | access, | ||
unsigned int | share = share_all , |
||
unsigned int | flags = 0 |
||
) |
Constructs a file object.
PathHelp::normalize(filename, PathHelp::path_type_file) is called
clan::FileSystem::FileSystem | ( | ) |
Constructs a file system.
clan::FileSystem::FileSystem | ( | const std::string & | path, |
bool | is_zip_file = false |
||
) |
Constructs a FileSystem.
path | = String |
is_zip_file | = bool |
clan::FileSystem::FileSystem | ( | FileSystemProvider * | provider | ) |
Constructs a FileSystem.
provider | = Virtual File Source |
clan::IODevice::IODevice | ( | ) |
Constructs a null instance.
clan::IODevice::IODevice | ( | IODeviceProvider * | provider | ) |
clan::MemoryDevice::MemoryDevice | ( | ) |
Constructs a memory I/O device.
clan::MemoryDevice::MemoryDevice | ( | DataBuffer & | data | ) |
Constructs a IODevice Memory.
data | = Data Buffer |
clan::ZipArchive::ZipArchive | ( | ) |
Constructs or loads a ZIP archive.
filename | .zip archive to load. |
clan::ZipArchive::ZipArchive | ( | const std::string & | filename | ) |
Constructs a ZipArchive.
filename | = String Ref |
clan::ZipArchive::ZipArchive | ( | const ZipArchive & | copy | ) |
Constructs a ZipArchive.
copy | = Zip Archive |
clan::ZipArchive::ZipArchive | ( | IODevice & | input | ) |
Constructs a ZipArchive.
input | = IODevice |
clan::ZipFileEntry::ZipFileEntry | ( | ) |
clan::ZipFileEntry::ZipFileEntry | ( | const ZipFileEntry & | copy | ) |
Constructs a ZipFileEntry.
copy | = Zip File Entry |
clan::ZipWriter::ZipWriter | ( | IODevice & | output, |
bool | storeFilenamesAsUTF8 = false |
||
) |
clan::DirectoryScanner::~DirectoryScanner | ( | ) |
Destructor.
clan::File::~File | ( | ) |
clan::FileSystem::~FileSystem | ( | ) |
|
inlinevirtual |
clan::IODevice::~IODevice | ( | ) |
|
inlinevirtual |
clan::ZipArchive::~ZipArchive | ( | ) |
clan::ZipFileEntry::~ZipFileEntry | ( | ) |
void clan::ZipArchive::add_file | ( | const std::string & | input_filename, |
const std::string & | filename_in_archive | ||
) |
|
static |
Add trailing slash or backslash to path.
This function checks if a path already has a trailing slash/backslash and adds it if its missing.
path | The path to use |
path_type | The path type (of path) |
void clan::ZipWriter::begin_file | ( | const std::string & | filename, |
bool | compress | ||
) |
Begins file entry in the zip file.
void clan::File::close | ( | ) |
Close file.
|
static |
Concatenates two strings into one adding a trailing slash to first string if missing.
part1 | First part of path |
part2 | Second part of path |
path_type | The path type (of path) |
|
static |
|
static |
Copy a file.
from | Where to copy from |
to | Where to copy to |
copy_always | true = Copy, even if destination already exists. false = Do not copy if destination exists (throw a Exception) |
|
static |
Create directory.
dir_name | = Directory name for create. |
recursive | = If true, function will create all directories in the path, otherwise only the last directory |
IODevice clan::ZipArchive::create_file | ( | const std::string & | filename, |
bool | compress = true |
||
) |
Creates a new file entry.
|
static |
|
static |
Delete a file.
filename | File to delete |
|
pure virtual |
Returns a new provider to the same resource.
void clan::ZipWriter::end_file | ( | ) |
Ends the file entry.
|
static |
Check if a file exists.
filename | File to check for existance |
|
static |
Returns the current user's roaming application data directory.
In Windows, this functions returns special folder directory CSIDL_APPDATA appended with the "company_name\application_name\version" string. A typical path would be "C:\Documents and Settings\username\Application Data\company_name\application_name\version\".
In OS X, this function returns the directory "~/Library/company_name/application_name/version/".
In Linux, this function returns the directory "~/.company_name/application_name/version/".
company_name | = Company name. |
application_name | = Application name. |
version | = Application version. |
create_dirs_if_missing | = If true, function will create all missing directories in the path. |
std::string clan::ZipFileEntry::get_archive_filename | ( | ) | const |
Returns the filename of file entry.
|
static |
Returns the basename part of a fullname.
param: fullname = The full path to use param: path_type = The path type
|
static |
Returns the path excluding the location and filename.
fullname | The full path name to use |
path_type | The path type |
If (path_type == path_type_virtual) or not using windows, then this function returns the path (excluding filename)
int64_t clan::ZipFileEntry::get_compressed_size | ( | ) |
Returns the compressed size of file entry.
int64_t clan::ZipReader::get_compressed_size | ( | ) | const |
Returns the compressed size of the file entry.
|
static |
Get current directory.
DataBuffer& clan::MemoryDevice::get_data | ( | ) |
Get Data.
const DataBuffer& clan::MemoryDevice::get_data | ( | ) | const |
Retrieves the data buffer for the memory device.
DirectoryListing clan::FileSystem::get_directory_listing | ( | const std::string & | path_rel | ) |
Return directory listing for path.
std::string clan::DirectoryScanner::get_directory_path | ( | ) |
Gets the directory being scanned.
|
static |
Returns the extension part of a fullname.
If no extension was found, an empty string is returned.
param: fullname = The full path to use param: path_type = The path type
std::vector<ZipFileEntry> clan::ZipArchive::get_file_list | ( | ) |
List of file entries in archive.
std::vector<ZipFileEntry> clan::ZipArchive::get_file_list | ( | const std::string & | path | ) |
std::string clan::ZipReader::get_filename | ( | ) |
Returns the file name that was stored in the local file header.
|
static |
Returns the filename part of a fullname.
param: fullname = The full path to use param: path_type = The path type
|
static |
Create a fullname from parts.
param: fullpath = The full path to use param: filename = The filename to use param: extension = The filename extension to use param: path_type = The path type
|
static |
Create a fullname from parts.
param: fullpath = The full path to use param: filename = The filename to use param: path_type = The path type
|
static |
Create a fullname from parts.
param: location = The location to use param: fullpath = The full path to use param: filename = The filename to use param: extension = The filename extension to use param: path_type = The path type
|
static |
Returns the path including the location.
param: fullname = The full path to use (including filename) param: path_type = The path type
std::string clan::FileSystem::get_identifier | ( | ) | const |
Get the identifier of this file source.
The exact format of this identifier depends on the implementation of the underlying filesystem and mounts
|
pure virtual |
Get the identifier of this file source.
The exact format of this identifier depends on the implementation of the underlying filesystem and mounts
std::string clan::ZipFileEntry::get_input_filename | ( | ) | const |
Returns the filename of file entry.
|
static |
Returns the current user's local (nonroaming) application data directory.
In Windows, this functions returns special folder directory CSIDL_LOCAL_APPDATA appended with the "company_name\application_name\version" string. A typical path would be "C:\Documents and Settings\username\Local Settings\Application Data\company_name\application_name\version\".
In OS X, this function returns the directory "~/Library/company_name/application_name/version/".
In Linux, this function returns the directory "~/.company_name/application_name/version/".
company_name | = Company name. |
application_name | = Application name. |
version | = Application version. |
create_dirs_if_missing | = If true, function will create all missing directories in the path. |
|
static |
Returns the drive (C:) or share name ( \ \ computer \ share)
If (path_type == path_type_virtual) or not using windows, then this function always returns an empty string.
fullname | The full path name to use |
path_type | The path type |
std::string clan::DirectoryScanner::get_name | ( | ) |
Gets the name of the current file.
std::string clan::FileSystem::get_path | ( | ) | const |
Returns a path to the file source for this file system.
|
pure virtual |
Return the path of this file source.
std::string clan::DirectoryScanner::get_pathname | ( | ) |
Gets the pathname of the current file.
std::string clan::ZipArchive::get_pathname | ( | const std::string & | filename | ) |
Get full path to source:
|
inlinevirtual |
Returns the position in the data stream.
Returns -1 if the position is unknown.
int clan::IODevice::get_position | ( | ) | const |
Returns the position in the data stream.
Returns -1 if the position is unknown.
FileSystemProvider* clan::FileSystem::get_provider | ( | ) |
Returns the file source for this file system.
IODeviceProvider* clan::IODevice::get_provider | ( | ) |
Returns the provider for this object.
const IODeviceProvider* clan::IODevice::get_provider | ( | ) | const |
Returns the provider for this object.
|
static |
Returns the application resource data directory.
In Windows, this function returns a data_dir_name subdirectory located at the executable. If the executable path is "C:\Program Files\My Application\MyApp.exe", then it will return the path "C:\Program Files\My Application\data_dir_name\".
In OS X, this function returns a "Resources" subdirectory inside the application bundle. For example, if the application executable path is "/Applications/MyApplication.app/Contents/MacOS/MyApplication", then it will return "/Applications/MyApplication.app/Contents/Resources/". If the executable is not in an application bundle, it will use the same behavior as in Windows; that is, it will return a data_dir_name subdirectory next to the executable.
In Linux, this function will return the directory "../share/application_name/" relative to the executable, so if it is located in "/usr/bin" it will return "/usr/share/application_name/"
application_name | = Application name. |
data_dir_name | = Data directory name. |
int clan::DirectoryScanner::get_size | ( | ) |
Gets the size of the current file.
|
inlinevirtual |
Returns the size of data stream.
Returns -1 if the size is unknown.
int clan::IODevice::get_size | ( | ) | const |
Returns the size of data stream.
Returns -1 if the size is unknown.
int64_t clan::ZipFileEntry::get_uncompressed_size | ( | ) |
Returns the uncompressed size of file entry.
int64_t clan::ZipReader::get_uncompressed_size | ( | ) | const |
Returns the uncompressed size of the file entry.
bool clan::ZipReader::has_data_descriptor | ( | ) | const |
Returns true if the file entry is followed by a data descriptor.
bool clan::FileSystem::has_directory | ( | const std::string & | directory | ) |
Return true if the root of the filesystem contains the specified directory.
bool clan::FileSystem::has_file | ( | const std::string & | filename | ) |
Return true if the root of the filesystem contains the specified file.
|
pure virtual |
Initiate directory listing.
|
static |
Check if a path is absolute.
path | The path to check |
path_type | The path type (of path) |
bool clan::DirectoryScanner::is_directory | ( | ) |
Returns true if the current file is a directory.
bool clan::ZipFileEntry::is_directory | ( | ) | const |
Is Directory.
bool clan::DirectoryScanner::is_hidden | ( | ) |
Returns true if the file is hidden.
bool clan::IODevice::is_little_endian | ( | ) | const |
Returns true if the input source is in little endian mode.
bool clan::FileSystem::is_mount | ( | const std::string & | mount_point | ) |
Returns true if a path is a mount point.
|
inline |
Returns true if the file system is null.
|
inline |
Returns true if this object is invalid.
References clan::IODevice::impl.
bool clan::DirectoryScanner::is_readable | ( | ) |
Returns true if the file is readable by the current user.
|
static |
Check if a path is relative.
path | The path to check |
path_type | The path type (of path) |
|
static |
Returns true if 64 bit system.
|
static |
Returns true if big endian system.
Referenced by clan::Endian::swap_if_big(), and clan::Endian::swap_if_little().
bool clan::DirectoryScanner::is_writable | ( | ) |
Returns true if the file is writable by the current user.
void clan::ZipArchive::load | ( | IODevice & | input | ) |
Loads the zip archive from a input device (done automatically at construction).
|
static |
Convert a relative path to an absolute path.
base_path | The base path (Does not require a trailing slash) |
relative_path | The relative path |
path_type | The path type |
This function behaves differently depending on OS and path_type. In Windows, if the relative_path begins with a drive letter, and the driver letter differs from the base path, the path is converted to an absolute path using the current directory for that drive. Likewise, if the specified base path does not include a drive or its path is not absolute, the current drive and directory is added. The function converts all slashes to backslashes.
If the OS is unix based, there is no location (drive or share name) and the function also converts all backslashes to slashes.
If the type is path_type_virtual, the base path is required to be absolute. If it does not start in a slash, the function prefixes a slash to the path. The current drive or directory is never taken into account and all backslashes are converted to slashes.
This function calls normalise() on base_path and relative_path.
Example #1:
Example #2:
Example #3:
|
static |
Converts an absolute path into a path relative to a base path.
base_path | The base path (Does not require a trailing slash) |
absolute_path | The absolute path |
path_type | The path type |
This function is the inverse of FileHelp::make_absolute. Please see the detailed information for make_absolute for more information about behavior.
This function calls normalise() on the base_path and absolute_path-
Example #1 (Windows):
void clan::FileSystem::mount | ( | const std::string & | mount_point, |
const std::string & | path, | ||
bool | is_zip_file | ||
) |
Mounts a file system at mount point.
Filenames starting with "mount_point" at the start will be replaced by the path specified by "path" (ie the the base_path is ignored) param: mount_point = Mount alias name to use param: path = Path which "mount_point" should point to param: is_zip_file = false, create as a FileSystemProvider_File, else create as a FileSystemProvider_Zip
void clan::FileSystem::mount | ( | const std::string & | mount_point, |
FileSystem | fs | ||
) |
Mounts a file system at mount point.
This is only available if FileSystem was set Filenames starting with "mount_point" at the start will be replaced by the filesystem specified by "fs" (ie the the base_path is ignored) For example: FileSystem new_vfs(new MyFileSource("Hello")); vfs.mount("ABC", new_vfs); param: mount_point = Mount alias name to use param: fs = Filesystem to use
bool clan::DirectoryScanner::next | ( | ) |
Find next file in directory scan.
|
pure virtual |
Update directory listing item.
|
static |
Normalize a path.
path | The path to use |
path_type | The path type (of the normalized path) |
Converts all slashes and backslashes into their right type. Simplifies or removes all . and .., converting the path into its most readable form.
bool clan::File::open | ( | const std::string & | filename | ) |
Opens a file read only.
PathHelp::normalize(filename, PathHelp::path_type_file) is called
bool clan::File::open | ( | const std::string & | filename, |
OpenMode | mode, | ||
unsigned int | access, | ||
unsigned int | share = share_all , |
||
unsigned int | flags = 0 |
||
) |
Opens a file.
PathHelp::normalize(filename, PathHelp::path_type_file) is called
IODevice clan::ZipArchive::open_file | ( | const std::string & | filename | ) |
Opens a file in the archive.
IODevice clan::FileSystem::open_file | ( | const std::string & | filename, |
File::OpenMode | mode = File::open_existing , |
||
unsigned int | access = File::access_read , |
||
unsigned int | share = File::share_all , |
||
unsigned int | flags = 0 |
||
) | const |
Opens a file.
param: mode = File::OpenMode modes param: access = File::AccessFlags flags param: share = File::ShareFlags flags param: flags = File::Flags flags
|
pure virtual |
Open file from this source.
param: filename = The filename to use param: mode = File::OpenMode modes param: access = File::AccessFlags flags param: share = File::ShareFlags flags param: flags = File::Flags flags
ZipFileEntry& clan::ZipFileEntry::operator= | ( | const ZipFileEntry & | copy | ) |
Copy assignment operator.
int clan::IODevice::peek | ( | void * | data, |
int | len | ||
) |
Peek data from device (data is left in the buffer).
data | Data to receive |
len | Maximum length of data to receive |
|
pure virtual |
Peek data from device.
int clan::IODevice::read | ( | void * | data, |
int | len, | ||
bool | receive_all = true |
||
) |
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.
int64_t clan::ZipReader::read_file_data | ( | void * | data, |
int64_t | size, | ||
bool | read_all = true |
||
) |
Reads some file data from the zip file.
float clan::IODevice::read_float | ( | ) |
Reads a float from input source.
Warning, this is not portable
int16_t clan::IODevice::read_int16 | ( | ) |
Reads a signed 16 bit integer from input source.
int32_t clan::IODevice::read_int32 | ( | ) |
Reads a signed 32 bit integer from input source.
int64_t clan::IODevice::read_int64 | ( | ) |
Reads a signed 64 bit integer from input source.
int8_t clan::IODevice::read_int8 | ( | ) |
Reads a signed 8 bit integer from input source.
bool clan::ZipReader::read_local_file_header | ( | bool | allow_data_descriptor = false | ) |
Begins reading a file entry in the zip file.
If allow_data_descriptor is set to false, an exception will be thrown if the file entry sizes and crc32 values are written in a data descriptor instead of the local file header.
Returns false if there are no more file entries.
std::string clan::IODevice::read_string_a | ( | ) |
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.
std::string clan::IODevice::read_string_nul | ( | ) |
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)
std::string clan::IODevice::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.
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 |
|
static |
Loads an UTF-8 text file into a string.
uint16_t clan::IODevice::read_uint16 | ( | ) |
Reads an unsigned 16 bit integer from input source.
uint32_t clan::IODevice::read_uint32 | ( | ) |
Reads an unsigned 32 bit integer from input source.
uint64_t clan::IODevice::read_uint64 | ( | ) |
Reads an unsigned 64 bit integer from input source.
uint8_t clan::IODevice::read_uint8 | ( | ) |
Reads an unsigned 8 bit integer from input source.
int clan::IODevice::receive | ( | void * | data, |
int | len, | ||
bool | receive_all = true |
||
) |
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 |
|
pure virtual |
Receive data from device.
|
static |
Remove directory.
dir_name | = Directory name for delete. |
delete_files | = If true, function will delete files. |
delete_sub_directories | = If true, function will delete subdirectories too. |
|
static |
Remove trailing slash or backslash from path.
This function checks if a path has a trailing slash/backslash and removes it if needed.
path | The path to use |
|
static |
Rename directory.
old_name | = Old name of the directory to be renamed. |
new_name | = New directory name. |
void clan::ZipArchive::save | ( | ) |
Saves zip archive.
filename | Filename of zip archive. Must not be used to save to the same as loaded from. |
If no filename parameter was passed, it will modify the zip archive loaded at construction time. It does this by creating a temporary file, saving the new archive, deletes the old one and renames the temp file to the original archive filename.
If the archive was created instead of loaded, a filename must be specify a filename. Likewise, if saving to same archive as loaded from, a filename must not be specified. Doing so will cause the save operation to fail.
void clan::ZipArchive::save | ( | const std::string & | filename | ) |
Save.
filename | = the filename to save to |
void clan::ZipArchive::save | ( | IODevice | iodev | ) |
Save.
iodev | = The file to save to |
bool clan::DirectoryScanner::scan | ( | const std::string & | pathname | ) |
Selects the directory to scan through.
Selects the directory to scan through
pathname | Path to the directory to scan (without trailing slash) |
bool clan::DirectoryScanner::scan | ( | const std::string & | pathname, |
const std::string & | pattern | ||
) |
Selects the directory to scan through.
Selects the directory to scan through and use a matching pattern on the files.
WIN32: The pattern is normal DOS pattern matching ("*.*", ?) Unix: The pattern is normal pattern matching (*, ?)
pathname | Path to the directory to scan (without trailing slash) |
pattern | Pattern to match files against. |
Seek in data stream.
position | Position to use (usage depends on the seek mode) |
mode | Seek mode |
|
inlinevirtual |
Seek in data stream.
int clan::IODevice::send | ( | const void * | data, |
int | len, | ||
bool | send_all = true |
||
) |
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 |
|
pure virtual |
Send data to device.
void clan::ZipFileEntry::set_archive_filename | ( | const std::string & | filename | ) |
Sets the filename of the file inside the archive.
void clan::IODevice::set_big_endian_mode | ( | ) |
Changes input data endianess to big endian mode. (Default is little endian)
|
static |
Change current directory.
dir_name | = Directory name to change to. |
void clan::ZipReader::set_data_descriptor_data | ( | int64_t | compressed_size, |
int64_t | uncompressed_size, | ||
uint32_t | crc32 | ||
) |
Informs the zip reader what the data descriptor contains.
void clan::ZipFileEntry::set_directory | ( | bool | is_directory | ) |
Set directory.
is_directory | = bool |
void clan::ZipFileEntry::set_input_filename | ( | const std::string & | filename | ) |
Sets the filename of the file to be added to the archive.
void clan::IODevice::set_little_endian_mode | ( | ) |
Changes input data endianess to little endian mode. This is the default setting.
void clan::IODevice::set_system_mode | ( | ) |
Changes input data endianess to the local systems mode.
|
static |
Splits the path, excluding the location, into parts.
param: fullname = The full path name to use param: path_type = The path type
|
static |
Swaps larger amounts of data between little and big endian.
data | Data to be swapped. |
type_size | Size of datatype to be swapped. (Must be an even number) |
total_times | Number of 'type_size' size data chunks to be swapped. |
Referenced by clan::Endian::swap_if_big(), and clan::Endian::swap_if_little().
|
inlinestatic |
References clan::Endian::is_system_big(), and clan::Endian::swap().
|
inlinestatic |
References clan::Endian::is_system_big(), and clan::Endian::swap().
void clan::IODevice::throw_if_null | ( | ) | const |
Throw an exception if this object is invalid.
void clan::FileSystem::unmount | ( | const std::string & | mount_point | ) |
Unmount a file system.
param: mount_point = The mount point to unmount
int clan::IODevice::write | ( | const void * | data, |
int | len, | ||
bool | send_all = true |
||
) |
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 |
|
static |
Saves a byte buffer to file.
void clan::ZipWriter::write_file_data | ( | const void * | data, |
int64_t | size | ||
) |
Writes some file data to the zip file.
void clan::IODevice::write_float | ( | float | data | ) |
Writes a float to output source.
data | = Float to write |
Warning, this is not portable.
void clan::IODevice::write_int16 | ( | int16_t | data | ) |
Writes a signed 16 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_int32 | ( | int32_t | data | ) |
Writes a signed 32 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_int64 | ( | int64_t | data | ) |
Writes a signed 64 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_int8 | ( | int8_t | data | ) |
Writes a signed 8 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_string_a | ( | const std::string & | str | ) |
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.
void clan::IODevice::write_string_nul | ( | const std::string & | str | ) |
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.
void clan::IODevice::write_string_text | ( | const std::string & | str | ) |
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.
|
static |
Saves an UTF-8 text string to file.
void clan::ZipWriter::write_toc | ( | ) |
Writes the table of contents part of the zip file.
void clan::IODevice::write_uint16 | ( | uint16_t | data | ) |
Writes an unsigned 16 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_uint32 | ( | uint32_t | data | ) |
Writes an unsigned 32 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_uint64 | ( | uint64_t | data | ) |
Writes an unsigned 64 bit integer to output source.
data | Integer to write |
void clan::IODevice::write_uint8 | ( | uint8_t | data | ) |
Writes an unsigned 8 bit integer to output source.
data | Integer to write |
|
protected |
Referenced by clan::IODevice::is_null().
|
friend |
|
friend |