Scopira
20080306
|
#include <file.h>
Public Types | |
typedef ::off_t | offset_t |
Public Member Functions | |
file (void) | |
default ctor and copy are fine | |
file (const std::string &fname) | |
void | set (const std::string &fname) |
bool | exists (void) const |
bool | is_file (void) const |
bool | is_dir (void) const |
offset_t | size (void) const |
Static Public Member Functions | |
static bool | check_path (const std::string &path) |
static bool | has_ext (const std::string &fname, const std::string &ext) |
static void | expand_homedir (std::string &path) |
static void | expand_envvar (std::string &path) |
static void | split_ext (const std::string &fullname, std::string &sansext, std::string &ext) |
static void | split_path (const std::string &fullname, std::string &path, std::string &name) |
static std::string | realpath (const std::string &name) |
static void | create_directory (const std::string &dirname) |
File class. use to get information about a file on disk (kinda like the Java class by the same name)
This should probably be eventually upgraded to stat64 and int64_t (especialy for size()).
scopira::tool::file::file | ( | const std::string & | fname | ) |
ctor. this object is mostly const-ish
|
static |
check if the given path is nice. nice means, no "/."
|
static |
Creates a directory.
bool scopira::tool::file::exists | ( | void | ) | const |
Does this "file" exist? In this context, file can be anything (eg directory, symlink, etc)
|
static |
Find all references to $ENVVAR and replace them with the corresponding variable from the environment.
|
static |
expand the give path for home directory references. in particular, [0] == '~', replace it with $HOME (home directory)
|
static |
check if the file ends (case insensitivly) with the given exntesion. ext must be all upper case. Example: ".XML". The "extension" may have multiple periods (this function just does a end-string comparison – periods have no special meaning)
bool scopira::tool::file::is_dir | ( | void | ) | const |
Is it a directory?
bool scopira::tool::file::is_file | ( | void | ) | const |
Is this a file?
|
static |
Wrapper around stdlib realpath(). Mainly, removes the trailing / or \, removes . or .. and resolves all symbolice links.
void scopira::tool::file::set | ( | const std::string & | fname | ) |
set it to a new file
offset_t scopira::tool::file::size | ( | void | ) | const |
return the size, in bytes
|
static |
Splits a full path from its extension. For example, /path/filename.ext will be split into /path/filename and .ext.
|
static |
Splits a filename from it's path. For example, /path/filename.ext becomes /path/ and filename.ext.