clanCore I/O Data

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...
 
FileSystemProviderclan::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 IODeviceProviderclan::IODevice::get_provider () const
 Returns the provider for this object. More...
 
IODeviceProviderclan::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 IODeviceProviderclan::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 DataBufferclan::MemoryDevice::get_data () const
 Retrieves the data buffer for the memory device. More...
 
DataBufferclan::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 &copy)
 Constructs a ZipArchive. More...
 
 clan::ZipArchive::~ZipArchive ()
 

Attributes

std::vector< ZipFileEntryclan::ZipArchive::get_file_list ()
 List of file entries in archive. More...
 
std::vector< ZipFileEntryclan::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 &copy)
 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

ZipFileEntryclan::ZipFileEntry::operator= (const ZipFileEntry &copy)
 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)
 

Detailed Description

Enumeration Type Documentation

◆ AccessFlags

Access flags.

File access types available.

Enumerator
access_read 

Generic read access.

access_write 

Generic write access.

access_read_write 

Generic read write access.

◆ CompressionMode

Enumerator
default_strategy 
filtered 
huffman_only 
rle 
fixed 

◆ Flags

Optimization Flags.

Enumerator
flag_write_through 
flag_no_buffering 
flag_random_access 
flag_sequential_scan 

◆ OpenMode

File opening modes.

Enumerator
open_always 

Open file or create it if it does not exist.

open_existing 

Open existing file. Fails if it does not exist.

open_existing_truncate 

Open existing file and truncate it.

create_always 

Create file, even if it already exists.

create_new 

Create a new file. Fails if it already exists.

◆ PathType

Path types.

Enumerator
path_type_file 

Native file system path. (On windows, '/' are turned into '\'. On linux, '\' are turned into '/')

path_type_virtual 

Path using slashes ('/').

◆ SeekMode

Seeking modes.

Enumerator
seek_set 

Set to a specific value from the start.

seek_cur 

Set relative to the current position.

seek_end 

Set to a specific value from the end (use negative position)

◆ ShareFlags

File sharing flags.

Enumerator
share_read 

Allow others to open the file for reading.

share_write 

Allow others to open the file for writing.

share_delete 

Allow others to delete the file.

share_all 

All other sharing flags combined.

Function Documentation

◆ DirectoryScanner()

clan::DirectoryScanner::DirectoryScanner ( )

Constructs directory scanner for iterating over a directory.

◆ File() [1/3]

clan::File::File ( )

Constructs a file object.

◆ File() [2/3]

clan::File::File ( const std::string &  filename)

Constructs a file object read only.

PathHelp::normalize(filename, PathHelp::path_type_file) is called

◆ File() [3/3]

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

◆ FileSystem() [1/3]

clan::FileSystem::FileSystem ( )

Constructs a file system.

◆ FileSystem() [2/3]

clan::FileSystem::FileSystem ( const std::string &  path,
bool  is_zip_file = false 
)

Constructs a FileSystem.

Parameters
path= String
is_zip_file= bool

◆ FileSystem() [3/3]

clan::FileSystem::FileSystem ( FileSystemProvider provider)

Constructs a FileSystem.

Parameters
provider= Virtual File Source

◆ IODevice() [1/2]

clan::IODevice::IODevice ( )

Constructs a null instance.

◆ IODevice() [2/2]

clan::IODevice::IODevice ( IODeviceProvider provider)

Constructs a IODevice.

Parameters
provider= IODevice Provider

◆ MemoryDevice() [1/2]

clan::MemoryDevice::MemoryDevice ( )

Constructs a memory I/O device.

◆ MemoryDevice() [2/2]

clan::MemoryDevice::MemoryDevice ( DataBuffer data)

Constructs a IODevice Memory.

Parameters
data= Data Buffer

◆ ZipArchive() [1/4]

clan::ZipArchive::ZipArchive ( )

Constructs or loads a ZIP archive.

Parameters
filename.zip archive to load.

◆ ZipArchive() [2/4]

clan::ZipArchive::ZipArchive ( const std::string &  filename)

Constructs a ZipArchive.

Parameters
filename= String Ref

◆ ZipArchive() [3/4]

clan::ZipArchive::ZipArchive ( const ZipArchive copy)

Constructs a ZipArchive.

Parameters
copy= Zip Archive

◆ ZipArchive() [4/4]

clan::ZipArchive::ZipArchive ( IODevice input)

Constructs a ZipArchive.

Parameters
input= IODevice

◆ ZipFileEntry() [1/2]

clan::ZipFileEntry::ZipFileEntry ( )

◆ ZipFileEntry() [2/2]

clan::ZipFileEntry::ZipFileEntry ( const ZipFileEntry copy)

Constructs a ZipFileEntry.

Parameters
copy= Zip File Entry

◆ ZipReader()

clan::ZipReader::ZipReader ( IODevice input)

Constructs a ZipReader.

Parameters
input= IODevice

◆ ZipWriter()

clan::ZipWriter::ZipWriter ( IODevice output,
bool  storeFilenamesAsUTF8 = false 
)

Constructs a ZipWriter.

Parameters
output= IODevice
storeFilenamesAsUTF8= bool

◆ ~DirectoryScanner()

clan::DirectoryScanner::~DirectoryScanner ( )

Destructor.

◆ ~File()

clan::File::~File ( )

◆ ~FileSystem()

clan::FileSystem::~FileSystem ( )

◆ ~FileSystemProvider()

virtual clan::FileSystemProvider::~FileSystemProvider ( )
inlinevirtual

◆ ~IODevice()

clan::IODevice::~IODevice ( )

◆ ~IODeviceProvider()

virtual clan::IODeviceProvider::~IODeviceProvider ( )
inlinevirtual

◆ ~ZipArchive()

clan::ZipArchive::~ZipArchive ( )

◆ ~ZipFileEntry()

clan::ZipFileEntry::~ZipFileEntry ( )

◆ add_file()

void clan::ZipArchive::add_file ( const std::string &  input_filename,
const std::string &  filename_in_archive 
)

Adds a file to zip archive.

File is not added to zip file until it save() is called.

Parameters
filenameFilename of file.

◆ add_trailing_slash()

static std::string clan::PathHelp::add_trailing_slash ( const std::string &  path,
PathType  path_type = path_type_file 
)
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.

Parameters
pathThe path to use
path_typeThe path type (of path)
Returns
The converted path

◆ begin_file()

void clan::ZipWriter::begin_file ( const std::string &  filename,
bool  compress 
)

Begins file entry in the zip file.

◆ close()

void clan::File::close ( )

Close file.

◆ combine()

static std::string clan::PathHelp::combine ( const std::string &  part1,
const std::string &  part2,
PathType  path_type = path_type_file 
)
static

Concatenates two strings into one adding a trailing slash to first string if missing.

Parameters
part1First part of path
part2Second part of path
path_typeThe path type (of path)

◆ compress()

static DataBuffer clan::ZLibCompression::compress ( const DataBuffer data,
bool  raw = true,
int  compression_level = 6,
CompressionMode  mode = default_strategy 
)
static

◆ copy_file()

static void clan::FileHelp::copy_file ( const std::string &  from,
const std::string &  to,
bool  copy_always 
)
static

Copy a file.

Parameters
fromWhere to copy from
toWhere to copy to
copy_alwaystrue = Copy, even if destination already exists. false = Do not copy if destination exists (throw a Exception)

◆ create()

static bool clan::Directory::create ( const std::string &  dir_name,
bool  recursive = false 
)
static

Create directory.

Parameters
dir_name= Directory name for create.
recursive= If true, function will create all directories in the path, otherwise only the last directory
Returns
true on success or false on error.

◆ create_file()

IODevice clan::ZipArchive::create_file ( const std::string &  filename,
bool  compress = true 
)

Creates a new file entry.

◆ decompress()

static DataBuffer clan::ZLibCompression::decompress ( const DataBuffer data,
bool  raw = true 
)
static

◆ delete_file()

static void clan::FileHelp::delete_file ( const std::string &  filename)
static

Delete a file.

Parameters
filenameFile to delete

◆ duplicate() [1/2]

IODevice clan::IODevice::duplicate ( )

Create a new IODevice referencing the same resource.

◆ duplicate() [2/2]

virtual IODeviceProvider* clan::IODeviceProvider::duplicate ( )
pure virtual

Returns a new provider to the same resource.

◆ end_file()

void clan::ZipWriter::end_file ( )

Ends the file entry.

◆ file_exists()

static bool clan::FileHelp::file_exists ( const std::string &  filename)
static

Check if a file exists.

Parameters
filenameFile to check for existance

◆ get_appdata()

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 
)
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/".

Parameters
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.
Returns
the current user's roaming application data directory.

◆ get_archive_filename()

std::string clan::ZipFileEntry::get_archive_filename ( ) const

Returns the filename of file entry.

◆ get_basename()

static std::string clan::PathHelp::get_basename ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
static

Returns the basename part of a fullname.

param: fullname = The full path to use param: path_type = The path type

Returns
The filename (excluding the extension)

◆ get_basepath()

static std::string clan::PathHelp::get_basepath ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
static

Returns the path excluding the location and filename.

Parameters
fullnameThe full path name to use
path_typeThe path type
Returns
The base path

If (path_type == path_type_virtual) or not using windows, then this function returns the path (excluding filename)

◆ get_compressed_size() [1/2]

int64_t clan::ZipFileEntry::get_compressed_size ( )

Returns the compressed size of file entry.

◆ get_compressed_size() [2/2]

int64_t clan::ZipReader::get_compressed_size ( ) const

Returns the compressed size of the file entry.

◆ get_current()

static std::string clan::Directory::get_current ( )
static

Get current directory.

Returns
the current directory path.

◆ get_data() [1/2]

DataBuffer& clan::MemoryDevice::get_data ( )

Get Data.

Returns
data

◆ get_data() [2/2]

const DataBuffer& clan::MemoryDevice::get_data ( ) const

Retrieves the data buffer for the memory device.

◆ get_directory_listing()

DirectoryListing clan::FileSystem::get_directory_listing ( const std::string &  path_rel)

Return directory listing for path.

◆ get_directory_path()

std::string clan::DirectoryScanner::get_directory_path ( )

Gets the directory being scanned.

Returns
Directory being scanned. (including the trailing slash)

◆ get_extension()

static std::string clan::PathHelp::get_extension ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
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

Returns
The extension

◆ get_file_list() [1/2]

std::vector<ZipFileEntry> clan::ZipArchive::get_file_list ( )

List of file entries in archive.

◆ get_file_list() [2/2]

std::vector<ZipFileEntry> clan::ZipArchive::get_file_list ( const std::string &  path)

◆ get_filename() [1/2]

std::string clan::ZipReader::get_filename ( )

Returns the file name that was stored in the local file header.

◆ get_filename() [2/2]

static std::string clan::PathHelp::get_filename ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
static

Returns the filename part of a fullname.

param: fullname = The full path to use param: path_type = The path type

Returns
The filename

◆ get_fullname() [1/3]

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 
)
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

Returns
The full name

◆ get_fullname() [2/3]

static std::string clan::PathHelp::get_fullname ( const std::string &  fullpath,
const std::string &  filename,
PathType  path_type = path_type_file 
)
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

Returns
The full name

◆ get_fullname() [3/3]

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 
)
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

Returns
The full name

◆ get_fullpath()

static std::string clan::PathHelp::get_fullpath ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
static

Returns the path including the location.

param: fullname = The full path to use (including filename) param: path_type = The path type

Returns
The full path including the location (excluding filename)

◆ get_identifier() [1/2]

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

Returns
the identifier

◆ get_identifier() [2/2]

virtual std::string clan::FileSystemProvider::get_identifier ( ) const
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

Returns
the identifier

◆ get_input_filename()

std::string clan::ZipFileEntry::get_input_filename ( ) const

Returns the filename of file entry.

◆ get_local_appdata()

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 
)
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/".

Parameters
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.
Returns
the current user's local (nonroaming) application data directory.

◆ get_location()

static std::string clan::PathHelp::get_location ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
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.

Parameters
fullnameThe full path name to use
path_typeThe path type
Returns
The drive or share name*‍/

◆ get_name()

std::string clan::DirectoryScanner::get_name ( )

Gets the name of the current file.

Returns
The name of the current found file.

◆ get_path() [1/2]

std::string clan::FileSystem::get_path ( ) const

Returns a path to the file source for this file system.

◆ get_path() [2/2]

virtual std::string clan::FileSystemProvider::get_path ( ) const
pure virtual

Return the path of this file source.

◆ get_pathname() [1/2]

std::string clan::DirectoryScanner::get_pathname ( )

Gets the pathname of the current file.

Returns
The name of the current found file, including the directory path.

◆ get_pathname() [2/2]

std::string clan::ZipArchive::get_pathname ( const std::string &  filename)

Get full path to source:

◆ get_position() [1/2]

virtual int clan::IODeviceProvider::get_position ( ) const
inlinevirtual

Returns the position in the data stream.

Returns -1 if the position is unknown.

◆ get_position() [2/2]

int clan::IODevice::get_position ( ) const

Returns the position in the data stream.

Returns -1 if the position is unknown.

Returns
The size (-1 if position is unknown)

◆ get_provider() [1/3]

FileSystemProvider* clan::FileSystem::get_provider ( )

Returns the file source for this file system.

◆ get_provider() [2/3]

IODeviceProvider* clan::IODevice::get_provider ( )

Returns the provider for this object.

◆ get_provider() [3/3]

const IODeviceProvider* clan::IODevice::get_provider ( ) const

Returns the provider for this object.

◆ get_resourcedata()

static std::string clan::Directory::get_resourcedata ( const std::string &  application_name,
const std::string &  data_dir_name = "Resources" 
)
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/"

Parameters
application_name= Application name.
data_dir_name= Data directory name.
Returns
the application resource data directory.

◆ get_size() [1/3]

int clan::DirectoryScanner::get_size ( )

Gets the size of the current file.

Returns
The size of the current found file.

◆ get_size() [2/3]

virtual int clan::IODeviceProvider::get_size ( ) const
inlinevirtual

Returns the size of data stream.

Returns -1 if the size is unknown.

◆ get_size() [3/3]

int clan::IODevice::get_size ( ) const

Returns the size of data stream.

Returns -1 if the size is unknown.

Returns
The size (-1 if size is unknown)

◆ get_uncompressed_size() [1/2]

int64_t clan::ZipFileEntry::get_uncompressed_size ( )

Returns the uncompressed size of file entry.

◆ get_uncompressed_size() [2/2]

int64_t clan::ZipReader::get_uncompressed_size ( ) const

Returns the uncompressed size of the file entry.

◆ has_data_descriptor()

bool clan::ZipReader::has_data_descriptor ( ) const

Returns true if the file entry is followed by a data descriptor.

◆ has_directory()

bool clan::FileSystem::has_directory ( const std::string &  directory)

Return true if the root of the filesystem contains the specified directory.

◆ has_file()

bool clan::FileSystem::has_file ( const std::string &  filename)

Return true if the root of the filesystem contains the specified file.

◆ initialize_directory_listing()

virtual bool clan::FileSystemProvider::initialize_directory_listing ( const std::string &  path)
pure virtual

Initiate directory listing.

◆ is_absolute()

static bool clan::PathHelp::is_absolute ( const std::string &  path,
PathType  path_type = path_type_file 
)
static

Check if a path is absolute.

Parameters
pathThe path to check
path_typeThe path type (of path)
Returns
true if path is absolute

◆ is_directory() [1/2]

bool clan::DirectoryScanner::is_directory ( )

Returns true if the current file is a directory.

Returns
True if filename is a directory.

◆ is_directory() [2/2]

bool clan::ZipFileEntry::is_directory ( ) const

Is Directory.

Returns
true = directory

◆ is_hidden()

bool clan::DirectoryScanner::is_hidden ( )

Returns true if the file is hidden.

Returns
True if filename is hidden.

◆ is_little_endian()

bool clan::IODevice::is_little_endian ( ) const

Returns true if the input source is in little endian mode.

Returns
true if little endian

◆ is_mount()

bool clan::FileSystem::is_mount ( const std::string &  mount_point)

Returns true if a path is a mount point.

◆ is_null() [1/2]

bool clan::FileSystem::is_null ( ) const
inline

Returns true if the file system is null.

◆ is_null() [2/2]

bool clan::IODevice::is_null ( ) const
inline

Returns true if this object is invalid.

References clan::IODevice::impl.

◆ is_readable()

bool clan::DirectoryScanner::is_readable ( )

Returns true if the file is readable by the current user.

Returns
True if the file is readable.

◆ is_relative()

static bool clan::PathHelp::is_relative ( const std::string &  path,
PathType  path_type = path_type_file 
)
static

Check if a path is relative.

Parameters
pathThe path to check
path_typeThe path type (of path)
Returns
true if path is relative

◆ is_system_64bit()

static bool clan::Endian::is_system_64bit ( )
static

Returns true if 64 bit system.

Returns
True if 64 bit, false otherwise.

◆ is_system_big()

static bool clan::Endian::is_system_big ( )
static

Returns true if big endian system.

Returns
True if big endian system, false otherwise.

Referenced by clan::Endian::swap_if_big(), and clan::Endian::swap_if_little().

◆ is_writable()

bool clan::DirectoryScanner::is_writable ( )

Returns true if the file is writable by the current user.

Returns
True if the file is writable.

◆ load()

void clan::ZipArchive::load ( IODevice input)

Loads the zip archive from a input device (done automatically at construction).

◆ make_absolute()

static std::string clan::PathHelp::make_absolute ( const std::string &  base_path,
const std::string &  relative_path,
PathType  path_type = path_type_file 
)
static

Convert a relative path to an absolute path.

Parameters
base_pathThe base path (Does not require a trailing slash)
relative_pathThe relative path
path_typeThe path type
Returns
The converted path

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:

std::string str = PathHelp::make_absolute("ABD/DEF/", "GFX/Filename.txt", PathHelp::path_type_file);
On Linux: str = "/home/user/ABD/DEF/GFX/Filename.txt"
On Windows: str = "c:\user\ABD\DEF\GFX\Filename.txt"

Example #2:

std::string str = PathHelp::make_absolute("/ABD/DEF/", "../Filename.txt", PathHelp::path_type_file);
On Linux: str = "/ABD/Filename.txt"
On Windows: str = "c:\ABD\Filename.txt"

Example #3:

std::string str = PathHelp::make_absolute("/ABD/DEF/", "../Filename.txt", PathHelp::path_type_virtual);
On Linux: str = "/ABD/Filename.txt"
On Windows: str = "/ABD/Filename.txt"

◆ make_relative()

static std::string clan::PathHelp::make_relative ( const std::string &  base_path,
const std::string &  absolute_path,
PathType  path_type = path_type_file 
)
static

Converts an absolute path into a path relative to a base path.

Parameters
base_pathThe base path (Does not require a trailing slash)
absolute_pathThe absolute path
path_typeThe path type
Returns
The converted path

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):

std::string str = PathHelp::make_relative("ABD/DEF/", "c:\user\ABD\Filename.txt", PathHelp::path_type_file);
On Windows: str = "..\Filename.txt"

◆ mount() [1/2]

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

◆ mount() [2/2]

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

◆ next()

bool clan::DirectoryScanner::next ( )

Find next file in directory scan.

Returns
false if no more files was found.

◆ next_file()

virtual bool clan::FileSystemProvider::next_file ( DirectoryListingEntry entry)
pure virtual

Update directory listing item.

◆ normalize()

static std::string clan::PathHelp::normalize ( const std::string &  path,
PathType  path_type = path_type_file 
)
static

Normalize a path.

Parameters
pathThe path to use
path_typeThe path type (of the normalized path)
Returns
The converted path

Converts all slashes and backslashes into their right type. Simplifies or removes all . and .., converting the path into its most readable form.

◆ open() [1/2]

bool clan::File::open ( const std::string &  filename)

Opens a file read only.

PathHelp::normalize(filename, PathHelp::path_type_file) is called

◆ open() [2/2]

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

◆ open_file() [1/3]

IODevice clan::ZipArchive::open_file ( const std::string &  filename)

Opens a file in the archive.

◆ open_file() [2/3]

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

Returns
The IODevice

◆ open_file() [3/3]

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 
)
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

Returns
The IODevice

◆ operator=()

ZipFileEntry& clan::ZipFileEntry::operator= ( const ZipFileEntry copy)

Copy assignment operator.

◆ peek() [1/2]

int clan::IODevice::peek ( void *  data,
int  len 
)

Peek data from device (data is left in the buffer).

Parameters
dataData to receive
lenMaximum length of data to receive
Returns
size of data received.

◆ peek() [2/2]

virtual int clan::IODeviceProvider::peek ( void *  data,
int  len 
)
pure virtual

Peek data from device.

◆ read()

int clan::IODevice::read ( void *  data,
int  len,
bool  receive_all = true 
)

Alias for receive(data, len, receive_all)

Parameters
dataData to receive
lenLength to receive
receive_alltrue to receive all the data. false = receive part of the data, if it would block
Returns
size of data received

◆ read_bytes()

static DataBuffer clan::File::read_bytes ( const std::string &  filename)
static

Loads an file into a byte buffer.

◆ read_file_data()

int64_t clan::ZipReader::read_file_data ( void *  data,
int64_t  size,
bool  read_all = true 
)

Reads some file data from the zip file.

◆ read_float()

float clan::IODevice::read_float ( )

Reads a float from input source.

Warning, this is not portable

Returns
The float read.

◆ read_int16()

int16_t clan::IODevice::read_int16 ( )

Reads a signed 16 bit integer from input source.

Returns
The integer read.

◆ read_int32()

int32_t clan::IODevice::read_int32 ( )

Reads a signed 32 bit integer from input source.

Returns
The integer read.

◆ read_int64()

int64_t clan::IODevice::read_int64 ( )

Reads a signed 64 bit integer from input source.

Returns
The integer read.

◆ read_int8()

int8_t clan::IODevice::read_int8 ( )

Reads a signed 8 bit integer from input source.

Returns
The integer read.

◆ read_local_file_header()

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.

◆ read_string_a()

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.

Returns
The string read.

◆ read_string_nul()

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)

Returns
The string read.

◆ read_string_text()

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)

Parameters
skip_initial_charsIgnore any of these characters at the start of the string. NULL = Do not ignore any characters
read_until_charsRead from the input until any of these characters are found. NULL = Read until the end of the file
allow_eofAllow EOF
Returns
The string read.

◆ read_text()

static std::string clan::File::read_text ( const std::string &  filename)
static

Loads an UTF-8 text file into a string.

◆ read_uint16()

uint16_t clan::IODevice::read_uint16 ( )

Reads an unsigned 16 bit integer from input source.

Returns
The integer read.

◆ read_uint32()

uint32_t clan::IODevice::read_uint32 ( )

Reads an unsigned 32 bit integer from input source.

Returns
The integer read.

◆ read_uint64()

uint64_t clan::IODevice::read_uint64 ( )

Reads an unsigned 64 bit integer from input source.

Returns
The integer read.

◆ read_uint8()

uint8_t clan::IODevice::read_uint8 ( )

Reads an unsigned 8 bit integer from input source.

Returns
The integer read.

◆ receive() [1/2]

int clan::IODevice::receive ( void *  data,
int  len,
bool  receive_all = true 
)

Receive data from device.

Parameters
dataData to receive
lenLength to receive
receive_alltrue to receive all the data. false = receive part of the data, if it would block
Returns
size of data received

◆ receive() [2/2]

virtual int clan::IODeviceProvider::receive ( void *  data,
int  len,
bool  receive_all = true 
)
pure virtual

Receive data from device.

◆ remove()

static bool clan::Directory::remove ( const std::string &  dir_name,
bool  delete_files = false,
bool  delete_sub_directories = false 
)
static

Remove directory.

Parameters
dir_name= Directory name for delete.
delete_files= If true, function will delete files.
delete_sub_directories= If true, function will delete subdirectories too.
Returns
true on success or false on error.

◆ remove_trailing_slash()

static std::string clan::PathHelp::remove_trailing_slash ( const std::string &  path)
static

Remove trailing slash or backslash from path.

This function checks if a path has a trailing slash/backslash and removes it if needed.

Parameters
pathThe path to use
Returns
The converted path

◆ rename()

static bool clan::Directory::rename ( const std::string &  old_name,
const std::string &  new_name 
)
static

Rename directory.

Parameters
old_name= Old name of the directory to be renamed.
new_name= New directory name.
Returns
true on success or false on error.

◆ save() [1/3]

void clan::ZipArchive::save ( )

Saves zip archive.

Parameters
filenameFilename 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.

◆ save() [2/3]

void clan::ZipArchive::save ( const std::string &  filename)

Save.

Parameters
filename= the filename to save to

◆ save() [3/3]

void clan::ZipArchive::save ( IODevice  iodev)

Save.

Parameters
iodev= The file to save to

◆ scan() [1/2]

bool clan::DirectoryScanner::scan ( const std::string &  pathname)

Selects the directory to scan through.

Selects the directory to scan through

Parameters
pathnamePath to the directory to scan (without trailing slash)
Returns
true if the directory can be accessed.

◆ scan() [2/2]

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 (*, ?)

Parameters
pathnamePath to the directory to scan (without trailing slash)
patternPattern to match files against.
Returns
true if the directory can be accessed.

◆ seek() [1/2]

bool clan::IODevice::seek ( int  position,
SeekMode  mode = seek_set 
)

Seek in data stream.

Parameters
positionPosition to use (usage depends on the seek mode)
modeSeek mode
Returns
false = Failed

◆ seek() [2/2]

virtual bool clan::IODeviceProvider::seek ( int  ,
IODevice::SeekMode   
)
inlinevirtual

Seek in data stream.

◆ send() [1/2]

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)

Parameters
dataData to send
lenLength to send
send_alltrue to send all the data. false = send part of the data, if it would block
Returns
size of data sent

◆ send() [2/2]

virtual int clan::IODeviceProvider::send ( const void *  data,
int  len,
bool  send_all = true 
)
pure virtual

Send data to device.

◆ set_archive_filename()

void clan::ZipFileEntry::set_archive_filename ( const std::string &  filename)

Sets the filename of the file inside the archive.

◆ set_big_endian_mode()

void clan::IODevice::set_big_endian_mode ( )

Changes input data endianess to big endian mode. (Default is little endian)

◆ set_current()

static bool clan::Directory::set_current ( const std::string &  dir_name)
static

Change current directory.

Parameters
dir_name= Directory name to change to.
Returns
true on success or false on error.

◆ set_data_descriptor_data()

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.

◆ set_directory()

void clan::ZipFileEntry::set_directory ( bool  is_directory)

Set directory.

Parameters
is_directory= bool

◆ set_input_filename()

void clan::ZipFileEntry::set_input_filename ( const std::string &  filename)

Sets the filename of the file to be added to the archive.

◆ set_little_endian_mode()

void clan::IODevice::set_little_endian_mode ( )

Changes input data endianess to little endian mode. This is the default setting.

◆ set_system_mode()

void clan::IODevice::set_system_mode ( )

Changes input data endianess to the local systems mode.

◆ split_basepath()

static std::vector<std::string> clan::PathHelp::split_basepath ( const std::string &  fullname,
PathType  path_type = path_type_file 
)
static

Splits the path, excluding the location, into parts.

param: fullname = The full path name to use param: path_type = The path type

Returns
The split path

◆ swap()

static void clan::Endian::swap ( void *  data,
int  type_size,
int  total_times = 1 
)
static

Swaps larger amounts of data between little and big endian.

Parameters
dataData to be swapped.
type_sizeSize of datatype to be swapped. (Must be an even number)
total_timesNumber of 'type_size' size data chunks to be swapped.

Referenced by clan::Endian::swap_if_big(), and clan::Endian::swap_if_little().

◆ swap_if_big()

static void clan::Endian::swap_if_big ( void *  data,
int  type_size,
int  total_times = 1 
)
inlinestatic

◆ swap_if_little()

static void clan::Endian::swap_if_little ( void *  data,
int  type_size,
int  total_times = 1 
)
inlinestatic

◆ throw_if_null()

void clan::IODevice::throw_if_null ( ) const

Throw an exception if this object is invalid.

◆ unmount()

void clan::FileSystem::unmount ( const std::string &  mount_point)

Unmount a file system.

param: mount_point = The mount point to unmount

◆ write()

int clan::IODevice::write ( const void *  data,
int  len,
bool  send_all = true 
)

Alias for send(data, len, send_all)

Parameters
dataData to send
lenLength to send
send_alltrue to send all the data. false = send part of the data, if it would block
Returns
size of data sent

◆ write_bytes()

static void clan::File::write_bytes ( const std::string &  filename,
const DataBuffer bytes 
)
static

Saves a byte buffer to file.

◆ write_file_data()

void clan::ZipWriter::write_file_data ( const void *  data,
int64_t  size 
)

Writes some file data to the zip file.

◆ write_float()

void clan::IODevice::write_float ( float  data)

Writes a float to output source.

Parameters
data= Float to write

Warning, this is not portable.

◆ write_int16()

void clan::IODevice::write_int16 ( int16_t  data)

Writes a signed 16 bit integer to output source.

Parameters
dataInteger to write

◆ write_int32()

void clan::IODevice::write_int32 ( int32_t  data)

Writes a signed 32 bit integer to output source.

Parameters
dataInteger to write

◆ write_int64()

void clan::IODevice::write_int64 ( int64_t  data)

Writes a signed 64 bit integer to output source.

Parameters
dataInteger to write

◆ write_int8()

void clan::IODevice::write_int8 ( int8_t  data)

Writes a signed 8 bit integer to output source.

Parameters
dataInteger to write

◆ write_string_a()

void clan::IODevice::write_string_a ( const std::string &  str)

Writes a string to the output source.

Parameters
strString 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.

◆ write_string_nul()

void clan::IODevice::write_string_nul ( const std::string &  str)

Writes a nul terminated string to the output source.

Parameters
strString to write

The binary format written to the output source is the string content followed by the NUL character.

◆ write_string_text()

void clan::IODevice::write_string_text ( const std::string &  str)

Writes a text string to the output source.

Parameters
strString 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.

◆ write_text()

static void clan::File::write_text ( const std::string &  filename,
const std::string &  text,
bool  write_bom = false 
)
static

Saves an UTF-8 text string to file.

◆ write_toc()

void clan::ZipWriter::write_toc ( )

Writes the table of contents part of the zip file.

◆ write_uint16()

void clan::IODevice::write_uint16 ( uint16_t  data)

Writes an unsigned 16 bit integer to output source.

Parameters
dataInteger to write

◆ write_uint32()

void clan::IODevice::write_uint32 ( uint32_t  data)

Writes an unsigned 32 bit integer to output source.

Parameters
dataInteger to write

◆ write_uint64()

void clan::IODevice::write_uint64 ( uint64_t  data)

Writes an unsigned 64 bit integer to output source.

Parameters
dataInteger to write

◆ write_uint8()

void clan::IODevice::write_uint8 ( uint8_t  data)

Writes an unsigned 8 bit integer to output source.

Parameters
dataInteger to write

Variable Documentation

◆ impl

std::shared_ptr<IODevice_Impl> clan::IODevice::impl
protected

Referenced by clan::IODevice::is_null().

Friends

◆ ZipArchive

friend class ZipArchive
friend

◆ ZipIODevice_FileEntry

friend class ZipIODevice_FileEntry
friend
static std::string 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.
static std::string 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.
@ path_type_virtual
Path using slashes ('/').
Definition: path_help.h:53
@ path_type_file
Native file system path. (On windows, '/' are turned into '\'. On linux, '\' are turned into '/')
Definition: path_help.h:50