37 void set_name(
const std::string &name);
41 static int unit(
int u) ;
48 static std::string
protocol(
const std::string &url)
throw();
49 static std::string
extension(
const std::string &url)
throw();
50 static std::string
uri(
const std::string &url)
throw() ;
51 static std::string
short_name(
const std::string &url)
throw();
52 static int depth(
const std::string &path)
throw() ;
54 static std::string
first_line(
const std::string &text);
60 static std::string
expand_home(
const std::string path) ;
66 File(
const std::string &name);
67 File(
const char* name) ;
70 operator std::string()
const throw() ;
71 operator const
char* () const throw() ;
72 operator
bool() const throw() ;
74 operator
size_t() const ;
81 int depth() const throw() ;
87 bool exists() const throw() ;
113 std::ostream*
output(
bool append=false) const ;
Wrapper for file operations.
static std::string protocol(const std::string &url)
extracts the protocol part of an url */
static const int KILOBYTE
number of bytes in a kilobyte */
std::string short_name() const
short name for file */
void unlink() const
deletes (unlinks) file */
bool is_directory() const
is the file a regular file */
void make_path(mode_t permissions) const
creates a full path */
static std::string uri(const std::string &url)
extracts the local path of an url */
static const char *const FILE_PROTOCOL
string for the file protocol */
User owner() const
owner of the file */
OksSystem::File parent() const
parent of the current file */
void rmdir() const
deletes directory */
file_list_t directory() const
list of file in directory */
std::string extension() const
extension for file */
mode_t permissions() const
permissions for the file */
std::istream * input() const
returns an input stream from the file*/
std::string parent_name() const
path of directory containing file */
File(const std::string &name)
static std::string pretty_open_flag(int flags)
pretty prints open flags */
static File from_url(const std::string &url)
build a file out of an URL */
static const char *const HUMAN_OPEN_STR[]
strings for pretty printing open flags */
std::string file_type() const
type of the file */
int depth() const
depth of the file */
static std::string first_line(const std::string &text)
extracts the first line of a text */
size_t size() const
size of file */
static int unit(int u)
calculates the value of a computer unit of order n (i.e KB,GB, etc */
static const char *const FILE_COMMAND_PATH
static std::string to_string(mode_t permissions)
converts permission to string */
void ensure_path(mode_t permissions) const
creates the parent path */
void rename(const File &other) const
rename or moves the file */
void remove() const
recursively delete files and directories */
OksSystem::File temporary(const std::string &prefix) const
static const char *const HUMAN_SIZE_STR[]
strings for pretty printing file sizes */
const char * c_full_name() const
static std::string working_directory()
current directory of process */
void make_dir(mode_t permissions) const
creates a directory */
static std::string pretty_size(size_t size, bool cut_small)
pretty prints a file size */
uid_t owner_id() const
owner id of file */
void make_fifo(mode_t permissions) const
creates a FIFO (named pipe) */
bool equals(const File &other) const
compare two files */
OksSystem::File child(const std::string &name) const
named child of the current directory */
void set_name(const std::string &name)
sets the name of the file */
static const char *const FILE_FLAG_STR
column headers for display of permissions */
gid_t group() const
group of file */
const std::string & full_name() const
full name for file */
static std::string expand_home(const std::string path)
resolve home directory */
std::ostream * output(bool append=false) const
returns an output stream to the file*/
mode_t get_mode() const
get mode associated with file (permission + type) */
std::string m_full_name
full name (path) of the file */
bool is_fifo() const
is the file a named pipe */
std::vector< OksSystem::File > file_list_t
bool is_regular() const
is the file a directory */
std::string pretty_permissions() const
pretty permissions for the file */