next up previous contents index
Next: Sockets ( leda_socket ) Up: Simple Data Types and Previous: Error Handling ( error   Contents   Index


Files and Directories ( file )

Operations

#include < LEDA/system/file.h >

string set_directory(string new_dir)
    sets the current working directory to new_dir and returns the name of the old cwd.

string get_directory() returns the name of the current working directory.

string get_home_directory() returns the name of the user's home directory.

string get_directory_delimiter() returns the character that delimits directory names in a path (i.e. `` \ '' on Windows and ``/'' on Unix).

void append_directory_delimiter(string& dir)
    appends the directory delimiter to dir if dir does not already end with the delimiter.

void remove_trailing_directory_delimiter(string& dir)
    removes the directory delimiter from dir if dir ends with it.

list< string> get_directories(string dir)
    returns the list of names of all sub-directories in directory dir.

list< string> get_files(string dir) returns the list of names of all regular files in directory dir.

list< string> get_files(string dir, string pattern)
    returns the list of names of all regular files in directory dir matching pattern.

list< string> get_entries(string dir) returns the list of all entries (directory and files) of directory dir.

bool create_directory(string fname)
    creates a directory with name dname, returns true on success.

bool is_directory(string fname)
    returns true if fname is the path name of a directory and false otherwise.

bool is_file(string fname) returns true if fname is the path name of a regular file and false otherwise.

bool is_link(string fname) returns true if fname is the path name of a symbolic link and false otherwise.

size_t size_of_file(string fname)
    returns the size of file fname in bytes.

time_t time_of_file(string fname)
    returns the time of last access to file fname.

string tmp_dir_name() returns name of the directory for temporary files.

string tmp_file_name() returns a unique name for a temporary file.

bool delete_file(string fname) deletes file fname returns true on success and false otherwise.

bool copy_file(string src, string dest)
    copies file src to file dest returns true on success and false otherwise.

bool move_file(string src, string dest)
    moves file src to file dest returns true on success and false otherwise.

bool chmod_file(string fname, string option)
    change file permission bits.

bool open_file(string fname, string suffix)
    opens file fname with application associated to suffix.

bool open_file(string fname) opens file fname with associated application.

int compare_files(string fname1, string fname2)
    returns 1 if the contents of fname1 and fname2 differ and 0 otherwise.

string first_file_in_path(string fname, string path, char sep = ':')
    searches all directories in string path (separated by sep ) for the first directory dir that contains a file with name fname and returns dir/fname (the empty string if no such directory is contained in path).


next up previous contents index
Next: Sockets ( leda_socket ) Up: Simple Data Types and Previous: Error Handling ( error   Contents   Index
Christian Uhrig 2017-04-07