file_manip.h File Reference

Useful file management helpers. More...

#include <string>
#include <list>
Include dependency graph for file_manip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool copy_file (std::string const &source, std::string const &destination)
 copy_file - copy a file.
bool is_directory (std::string const &dirname)
 return true if dir is an existing directory
bool is_files_identical (std::string const &file1, std::string const &file2)
 is_file_identical - check for identical files
std::string const op_realpath (std::string const &name)
 op_realpath - resolve symlinks etc.
bool op_file_readable (std::string const &file)
 return true if the given file is readable
bool create_file_list (std::list< std::string > &file_list, std::string const &base_dir, std::string const &filter="*", bool recursive=false)
std::string op_dirname (std::string const &file_name)
 op_dirname - get the path component of a filename
std::string op_basename (std::string const &path_name)
 op_basename - get the basename of a path

Detailed Description

Useful file management helpers.

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
Philippe Elie
John Levon

Function Documentation

bool copy_file ( std::string const &  source,
std::string const &  destination 
)

copy_file - copy a file.

Parameters:
source filename to copy from
destination filename to copy into

the last modification time of the source file is preserved, file attribute and owner are preserved if possible. Return true if copying successful.

bool create_file_list ( std::list< std::string > &  file_list,
std::string const &  base_dir,
std::string const &  filter = "*",
bool  recursive = false 
)
Parameters:
file_list where to store result
base_dir directory from where lookup start
filter a filename filter
recursive if true lookup in sub-directory

create a filelist under base_dir, filtered by filter and optionally looking in sub-directory. If we look in sub-directory only sub-directory which match filter are traversed.

bool is_directory ( std::string const &  dirname  ) 

return true if dir is an existing directory

bool is_files_identical ( std::string const &  file1,
std::string const &  file2 
)

is_file_identical - check for identical files

Parameters:
file1 first filename
file2 second filename

return true if the two filenames belong to the same file

std::string op_basename ( std::string const &  path_name  ) 

op_basename - get the basename of a path

Parameters:
path_name path

Returns the basename of a path with trailing '/' removed.

Always use this instead of the C basename() - header order can affect behaviour for basename("/")

std::string op_dirname ( std::string const &  file_name  ) 

op_dirname - get the path component of a filename

Parameters:
file_name filename

Returns the path name of a filename with trailing '/' removed.

bool op_file_readable ( std::string const &  file  ) 

return true if the given file is readable

std::string const op_realpath ( std::string const &  name  ) 

op_realpath - resolve symlinks etc.

Resolve a path as much as possible. Accounts for relative paths (from cwd), ".." and ".". For success, the target file must exist !

Resolve a symbolic link as far as possible. Returns the original string on failure.


Generated on 29 Jul 2013 for oprofile by  doxygen 1.6.1