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


Files and Directories ( file )

#include < LEDA/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.

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

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.

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
root 2008-01-09