fs.h File Reference

#include <iostream>
#include <string>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/statvfs.h>
#include <sys/vfs.h>
#include "types.h"

Include dependency graph for fs.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

class  filestatus
 Retrieve information about a file or directory. More...

class  subdirectory
 Retrieve a list of files in a subdirectory that match a given wildcard filename. More...

class  directory
 Retrieve a list of pathnames that match a given wildcard path. More...

class  filesystem
 Retrieve information about a filesystem. More...


Defines

#define STATFS   statfs

Functions

const std::string cwd (void)
 Return the current working directory.

const pid_t pid (void)
 Return the PID of this process.

const pid_t parent_pid (void)
 Return the PID of the parent process.

bool absolute_path (const std::string &a_path)
 Return true if the string looks like an absolute path.

bool relative_path (const std::string &a_path)
 Return true if the string looks like a relative path.

std::string reform_path (const std::string &a_path)
 Reformat a path to remove double slashes.

std::string permute_path (const std::string &a_path)
 Reformat a path to remove the begining and trailing slashes, and replace all other slashes with underscores.

std::string path_basename (const std::string &a_path)
 Return everything after the last slash from a path.

std::string path_dirname (const std::string &a_path)
 Return everything up to the last slash from a path.

std::string mk_absolute_path (const std::string a_path, const std::string a_rel_path)
 Make the path a_rel_path absolute with respect to a_path, where a_rel_path and a_path are directory names.

std::string mk_relative_path (const std::string a_path_to, const std::string a_path_from)
 Make the path a_path_to relative from a_path_from, where a_path_to and a_path_from are directory names.

bool exists (const std::string &a_path)
 Return true if the file or directory exists.

bool readable (const std::string &a_path)
 Return true if the file or directory exists and is readable.

bool writable (const std::string &a_path)
 Return true if the file or directory exists and is writable.

bool executable (const std::string &a_path)
 Return true if the file or directory exists and is executable.

void mk_dir (const std::string &a_path)
 Create a directory.

void rm_dir (const std::string a_path)
 Remove a directory.

void rm_file (const std::string a_path)
 Remove a file.

void mk_dirhier (const std::string a_path)
 Recursively create a directory heirarchy.

void rename_file (const std::string a_from, const std::string a_to)
 Rename a file or directory.

void mk_symlink (const std::string a_from, const std::string a_to)
 Create a symbolic link.

void mk_relative_symlink (const std::string a_from, const std::string a_to)
 Given a from and to path, create a relative symbolic link.

void rm_recursive (const std::string a_path)
 Recursively delete the contents of a directory.


Define Documentation

#define STATFS   statfs
 

Definition at line 59 of file fs.h.

Referenced by filesystem::path().


Function Documentation

bool absolute_path const std::string &  a_path  ) 
 

Return true if the string looks like an absolute path.

Definition at line 186 of file fs.cc.

Referenced by relative_path().

const std::string cwd void   ) 
 

Return the current working directory.

Definition at line 148 of file fs.cc.

References ERROR, and TRY_nomem.

Referenced by test_cwd(), and test_filesystem().

bool executable const std::string &  a_path  ) 
 

Return true if the file or directory exists and is executable.

Definition at line 415 of file fs.cc.

Referenced by test_executable().

bool exists const std::string &  a_path  ) 
 

Return true if the file or directory exists.

Definition at line 385 of file fs.cc.

Referenced by archive_manager::archive(), report_manager::file_report(), log_manager::init(), job_archiver::mf_do_chores(), mk_dirhier(), mk_dirhier_recursive_(), directory::path(), rename_file(), rm_recursive(), test_executable(), test_exists(), test_filestatus(), test_mk_dir(), test_mk_dirhier(), test_mk_relative_symlink(), test_mk_symlink(), test_rm_dir(), test_rm_file(), test_rm_recursive(), and test_rvm().

std::string mk_absolute_path const std::string  a_path,
const std::string  a_rel_path
 

Make the path a_rel_path absolute with respect to a_path, where a_rel_path and a_path are directory names.

Definition at line 282 of file fs.cc.

References ERROR, INTERNAL_ERROR, reform_path(), relative_path(), and TRY_nomem.

Here is the call graph for this function:

void mk_dir const std::string &  a_path  ) 
 

Create a directory.

Definition at line 577 of file fs.cc.

References ACCESSPERMS, ERROR, and TRY_nomem.

Referenced by archive_manager::archive(), make_dir(), mk_dirhier_recursive_(), test_mk_dir(), and test_rm_file().

void mk_dirhier const std::string  a_path  ) 
 

Recursively create a directory heirarchy.

Definition at line 639 of file fs.cc.

References err_unknown, ERROR_INSTANCE, exists(), mk_dirhier_recursive_(), and TRY_nomem.

Referenced by job_archiver::mf_do_chores(), and test_mk_dirhier().

Here is the call graph for this function:

std::string mk_relative_path const std::string  a_path_to,
const std::string  a_path_from
 

Make the path a_path_to relative from a_path_from, where a_path_to and a_path_from are directory names.

Definition at line 314 of file fs.cc.

References reform_path(), and TRY_nomem.

Referenced by job_archiver::mf_do_chores(), mk_relative_symlink(), and test_mk_relative_path().

Here is the call graph for this function:

void mk_relative_symlink const std::string  a_from,
const std::string  a_to
 

Given a from and to path, create a relative symbolic link.

Definition at line 720 of file fs.cc.

References err_unknown, ERROR_INSTANCE, mk_relative_path(), mk_symlink(), path_basename(), path_dirname(), reform_path(), and TRY_nomem.

Referenced by catalog_manager::catalog(), and test_mk_relative_symlink().

Here is the call graph for this function:

void mk_symlink const std::string  a_from,
const std::string  a_to
 

Create a symbolic link.

Definition at line 704 of file fs.cc.

References ERROR, and TRY_nomem.

Referenced by mk_relative_symlink(), and test_mk_symlink().

const pid_t parent_pid void   ) 
 

Return the PID of the parent process.

Definition at line 174 of file fs.cc.

References ERROR, and pid().

Here is the call graph for this function:

std::string path_basename const std::string &  a_path  ) 
 

Return everything after the last slash from a path.

Definition at line 247 of file fs.cc.

References TRY_nomem.

Referenced by mk_relative_symlink().

std::string path_dirname const std::string &  a_path  ) 
 

Return everything up to the last slash from a path.

Definition at line 264 of file fs.cc.

References TRY_nomem.

Referenced by mk_relative_symlink().

std::string permute_path const std::string &  a_path  ) 
 

Reformat a path to remove the begining and trailing slashes, and replace all other slashes with underscores.

Definition at line 224 of file fs.cc.

References reform_path(), and TRY_nomem.

Referenced by job::generate_archive_path(), and test_permute_path().

Here is the call graph for this function:

const pid_t pid void   ) 
 

Return the PID of this process.

Definition at line 162 of file fs.cc.

References ERROR, and pid().

Referenced by execute::my_pid(), parent_pid(), pid(), stamp(), and test().

Here is the call graph for this function:

bool readable const std::string &  a_path  ) 
 

Return true if the file or directory exists and is readable.

Definition at line 395 of file fs.cc.

Referenced by test_readable().

std::string reform_path const std::string &  a_path  ) 
 

Reformat a path to remove double slashes.

Definition at line 205 of file fs.cc.

References TRY_nomem.

Referenced by catalog_manager::catalog(), catalog_manager::erase(), job::generate_archive_path(), job_archiver::mf_do_chores(), mk_absolute_path(), mk_relative_path(), mk_relative_symlink(), filesystem::path(), directory::path(), filestatus::path(), permute_path(), test_inodes(), and test_reform_path().

bool relative_path const std::string &  a_path  ) 
 

Return true if the string looks like a relative path.

Definition at line 195 of file fs.cc.

References absolute_path().

Referenced by job_archiver::mf_do_chores(), and mk_absolute_path().

Here is the call graph for this function:

void rename_file const std::string  a_from,
const std::string  a_to
 

Rename a file or directory.

Definition at line 665 of file fs.cc.

References ERROR, exists(), INTERNAL_ERROR, and TRY_nomem.

Referenced by archive_manager::archive().

Here is the call graph for this function:

void rm_dir const std::string  a_path  ) 
 

Remove a directory.

Definition at line 590 of file fs.cc.

References ERROR, and TRY_nomem.

Referenced by rm_recursive(), test_rm_dir(), and test_rm_file().

void rm_file const std::string  a_path  ) 
 

Remove a file.

Definition at line 604 of file fs.cc.

References ERROR, and TRY_nomem.

Referenced by rm_recursive(), and test_rm_file().

void rm_recursive const std::string  a_path  ) 
 

Recursively delete the contents of a directory.

Definition at line 1364 of file fs.cc.

References exists(), subdirectory::path(), filestatus::path(), rm_dir(), rm_file(), TRY, and TRY_nomem.

Referenced by vault_manager::delete_oldest_archive(), catalog_manager::erase(), and test_rm_recursive().

Here is the call graph for this function:

bool writable const std::string &  a_path  ) 
 

Return true if the file or directory exists and is writable.

Definition at line 405 of file fs.cc.

Referenced by test_writable().


Generated on Mon Jul 12 12:04:00 2004 for rvm by doxygen 1.3.6