Rosetta
Classes | Functions
utility::file Namespace Reference

Classes

class  FileName
 File name class supporting Windows and UN*X/Linux format names. More...
 
class  PathName
 Path name class supporting Windows and UN*X/Linux format names. More...
 

Functions

bool file_exists (std::string const &path)
 Does File Exist? More...
 
bool is_directory (std::string const &path)
 Is the given path a directory? More...
 
int file_delete (std::string const &path)
 Delete File. More...
 
std::string file_extension (std::string const &filename)
 Extension of a File Name. More...
 
std::string file_basename (std::string const &filename)
 Basename of a File Name. More...
 
long file_size (std::string const &filename)
 Platform independent way of getting file size. More...
 
bool create_blank_file (std::string const &blank_file)
 Create a blank file if it doesn't already exist. More...
 
std::string create_temp_filename (std::string const &dir, std::string const &prefix)
 Find an unused random tempfile name with a given prefix (which may include a directory) More...
 
bool create_directory (std::string const &dir_path)
 Create a directory if it doesn't already exist. More...
 
bool create_directory_recursive (std::string const &dir_path)
 Create a directory and its parent directories if they doesn't already exist. More...
 
bool trytry_ifstream_open (std::ifstream &ifstream_, std::string const &name, std::ios_base::openmode open_mode)
 Try to open file a few times just in case it is locked (from BOINC LIB) More...
 
bool trytry_ofstream_open (std::ofstream &ofstream_, std::string const &name, std::ios_base::openmode open_mode)
 Try to open file a few times just in case it is locked (from BOINC LIB) More...
 
int list_dir (std::string dir, utility::vector1< std::string > &files)
 generate sorted file listing for given directory, return non-zero value on error More...
 
FileName combine_names (utility::vector1< std::string > file_name_strings)
 
std::string cwd ()
 current working directory More...
 
std::string get_home_dir ()
 Get the (absolute) path to the users home directory. More...
 
bool change_working_directory (std::string const &dir_path)
 Changes the current working directory. More...
 
std::istream & operator>> (std::istream &stream, FileName &name)
 Input from stream. More...
 
std::ostream & operator<< (std::ostream &stream, FileName const &name)
 Output to stream. More...
 
bool char_equali (char c, char d)
 Characters equal case-insensitively? More...
 
bool equali (std::string const &s, std::string const &t)
 Strings equal case-insensitively? More...
 
bool operator== (FileName const &name1, FileName const &name2)
 FileName == FileName. More...
 
bool operator!= (FileName const &name1, FileName const &name2)
 FileName != FileName. More...
 
bool operator< (FileName const &name1, FileName const &name2)
 FileName < FileName. More...
 
bool operator<= (FileName const &name1, FileName const &name2)
 FileName <= FileName. More...
 
bool operator>= (FileName const &name1, FileName const &name2)
 FileName >= FileName. More...
 
bool operator> (FileName const &name1, FileName const &name2)
 FileName > FileName. More...
 
long gzip (std::string const &uncompressedfile, bool overwrite)
 gzip: file compression More...
 
long gunzip (std::string const &compressedfile, bool overwrite)
 gunzip: file decompression More...
 
std::istream & operator>> (std::istream &stream, PathName &name)
 Input from stream. More...
 
std::ostream & operator<< (std::ostream &stream, PathName const &name)
 Output to stream. More...
 
bool operator== (PathName const &name1, PathName const &name2)
 PathName == PathName. More...
 
bool operator!= (PathName const &name1, PathName const &name2)
 PathName != PathName. More...
 
bool operator< (PathName const &name1, PathName const &name2)
 PathName < PathName. More...
 
bool operator<= (PathName const &name1, PathName const &name2)
 PathName <= PathName. More...
 
bool operator>= (PathName const &name1, PathName const &name2)
 PathName >= PathName. More...
 
bool operator> (PathName const &name1, PathName const &name2)
 PathName > PathName. More...
 

Function Documentation

◆ change_working_directory()

bool utility::file::change_working_directory ( std::string const &  dir_path)

Changes the current working directory.

◆ char_equali()

bool utility::file::char_equali ( char  c,
char  d 
)
inline

Characters equal case-insensitively?

References kmeans_adaptive_kernel_density_bb_dependent_rotlib::c.

Referenced by equali().

◆ combine_names()

FileName utility::file::combine_names ( utility::vector1< std::string >  file_name_strings)

References begin.

Referenced by CrystFFTDock::apply().

◆ create_blank_file()

bool utility::file::create_blank_file ( std::string const &  blank_file)

Create a blank file if it doesn't already exist.

References utility::io::oc::cerr, utility::io::oc::cout, erraser_single_res_analysis::out, trytry_ofstream_open(), and utility_exit.

◆ create_directory()

bool utility::file::create_directory ( std::string const &  dir_path)

Create a directory if it doesn't already exist.

Code is based on a discussion on this web site:

http://www.brainbell.com/tutorials/C++/Creating_A_Directory.htm

On non-Windows systems, the permissions are solely determined by the umask. If directory creation is successful, the function returns true.

*** Currently untested on Windows! If you find it works, remove this warning. Thanks. ***

Referenced by create_directory_recursive(), main(), and RunPepSpec().

◆ create_directory_recursive()

bool utility::file::create_directory_recursive ( std::string const &  dir_path)

Create a directory and its parent directories if they doesn't already exist.

Based on the above create_directory() function. If directory creation is successful or the directory already exists, the function returns true.

*** Currently untested on Windows! If you find it works, remove this warning. Thanks. ***

References create_directory(), utility::file::PathName::name(), utility::file::PathName::parent(), and loops_kic::success.

Referenced by basic::database::find_cache_file(), harvest_motifs_one(), harvest_scores(), main(), sicdock_thread_num(), and write_base_pair_step_to_silent_struct().

◆ create_temp_filename()

std::string utility::file::create_temp_filename ( std::string const &  dir,
std::string const &  prefix 
)

Find an unused random tempfile name with a given prefix (which may include a directory)

References evaluate_beta_mutants::file, free(), create_a3b_hbs::i, platform::file::PATH_SEPARATOR(), create_a3b_hbs::prefix, and str().

Referenced by basic::database::find_cache_file().

◆ cwd()

std::string utility::file::cwd ( )

current working directory

References utility_exit_with_message.

Referenced by get_sc().

◆ equali()

bool utility::file::equali ( std::string const &  s,
std::string const &  t 
)
inline

Strings equal case-insensitively?

References char_equali(), ObjexxFCL::equal(), docking::s, and predPRE::t.

Referenced by utility::file::FileName::equal(), and utility::file::PathName::equal().

◆ file_basename()

std::string utility::file::file_basename ( std::string const &  filename)

◆ file_delete()

int utility::file::file_delete ( std::string const &  path)

◆ file_exists()

bool utility::file::file_exists ( std::string const &  path)

Does File Exist?

Does file exist?

References cal_vdw_radius_pool::buf, utility::Inline_File_Provider::file_exists(), utility::SingletonBase< Inline_File_Provider >::get_instance(), and closure_error::path.

Referenced by IAMover::apply(), calculate_hASA_by_type_and_attractiveE(), calculate_hASA_by_type_and_exposure(), calculate_hASA_by_type_and_nbcount(), calculate_hydrophobic_accessible_surface_area(), calculate_percent_hydrophobic_distribution(), calculate_percent_hydrophobic_stats(), calculate_total_hASA_within_distance_avg_values(), calculate_total_hASA_within_distance_avgresiduevalues_allnbs_conditionalonnumnbs(), calculate_total_hASA_within_distance_exact_hASA_values(), calculate_total_hASA_within_distance_exact_hASA_values_allnbs(), calculate_total_hASA_within_distance_exact_hASA_values_allnbs_exposedornot_conditionalonnumnbs(), calculate_total_hASA_within_distance_miniSASAvalues_allnbs_exposedornot_conditionalonnumnbs(), FragMonteCarlo::check_file_exists(), composite_sequences_from_cmd_line(), file_delete(), file_size(), filter_combine_long_loop(), basic::database::find_cache_file(), find_hppatches_distance(), find_hppatches_nb_graph(), basic::database::full_name(), get_pos_from_fragfn(), get_pose_by_id(), gunzip(), gzip(), harvest_motifs(), import_and_dump_pdb(), input_coordCstsMapped(), is_locked(), main(), MSA_design_main(), my_main(), utility::io::ozstream::open_append_if_existed(), zinc_stats::ZincStatisticGenerator::output_file(), poses_from_cmd_line(), poses_from_cmd_line_noPDBtag(), read_embeddings(), read_membrane(), read_parameters(), read_penalties(), rna_fullatom_minimize_silent_test(), scheme_score(), sequences_from_cmd_line(), sicdock_thread_num(), swa_rna_cluster(), test(), trytry_ifstream_open(), trytry_ofstream_open(), and write_base_pair_step_to_silent_struct().

◆ file_extension()

std::string utility::file::file_extension ( std::string const &  filename)

◆ file_size()

long utility::file::file_size ( std::string const &  filename)

◆ get_home_dir()

std::string utility::file::get_home_dir ( )

Get the (absolute) path to the users home directory.

If homedir could not be found, it will return an empty string. Rocco Moretti

Referenced by basic::database::full_cache_name().

◆ gunzip()

long utility::file::gunzip ( std::string const &  compressedfile,
bool  overwrite 
)

◆ gzip()

long utility::file::gzip ( std::string const &  uncompressedfile,
bool  overwrite 
)

◆ is_directory()

bool utility::file::is_directory ( std::string const &  path)

Is the given path a directory?

Is the file a directory?

References cal_vdw_radius_pool::buf, closure_error::path, and S_ISDIR.

Referenced by main(), and trytry_ifstream_open().

◆ list_dir()

int utility::file::list_dir ( std::string  dir,
utility::vector1< std::string > &  files 
)

generate sorted file listing for given directory, return non-zero value on error

◆ operator!=() [1/2]

bool utility::file::operator!= ( FileName const &  name1,
FileName const &  name2 
)

◆ operator!=() [2/2]

bool utility::file::operator!= ( PathName const &  name1,
PathName const &  name2 
)

◆ operator<() [1/2]

bool utility::file::operator< ( FileName const &  name1,
FileName const &  name2 
)

◆ operator<() [2/2]

bool utility::file::operator< ( PathName const &  name1,
PathName const &  name2 
)

◆ operator<<() [1/2]

std::ostream& utility::file::operator<< ( std::ostream &  stream,
FileName const &  name 
)

Output to stream.

◆ operator<<() [2/2]

std::ostream& utility::file::operator<< ( std::ostream &  stream,
PathName const &  name 
)

Output to stream.

◆ operator<=() [1/2]

bool utility::file::operator<= ( FileName const &  name1,
FileName const &  name2 
)

◆ operator<=() [2/2]

bool utility::file::operator<= ( PathName const &  name1,
PathName const &  name2 
)

◆ operator==() [1/2]

bool utility::file::operator== ( FileName const &  name1,
FileName const &  name2 
)

◆ operator==() [2/2]

bool utility::file::operator== ( PathName const &  name1,
PathName const &  name2 
)

◆ operator>() [1/2]

bool utility::file::operator> ( FileName const &  name1,
FileName const &  name2 
)

◆ operator>() [2/2]

bool utility::file::operator> ( PathName const &  name1,
PathName const &  name2 
)

◆ operator>=() [1/2]

bool utility::file::operator>= ( FileName const &  name1,
FileName const &  name2 
)

◆ operator>=() [2/2]

bool utility::file::operator>= ( PathName const &  name1,
PathName const &  name2 
)

◆ operator>>() [1/2]

std::istream& utility::file::operator>> ( std::istream &  stream,
FileName name 
)

Input from stream.

◆ operator>>() [2/2]

std::istream& utility::file::operator>> ( std::istream &  stream,
PathName name 
)

Input from stream.

◆ trytry_ifstream_open()

bool utility::file::trytry_ifstream_open ( std::ifstream &  ifstream_,
std::string const &  name,
std::ios_base::openmode  open_mode 
)

Try to open file a few times just in case it is locked (from BOINC LIB)

Try to open file for read a few times just in case it is locked (from BOINC LIB)

References file_exists(), create_a3b_hbs::i, basic::options::OptionKeys::in::in, is_directory(), name, and utility::rand_sleep().

Referenced by file_size(), gzip(), utility::io::izstream::open(), and utility::io::izstream::open_ifstream().

◆ trytry_ofstream_open()

bool utility::file::trytry_ofstream_open ( std::ofstream &  ofstream_,
std::string const &  name,
std::ios_base::openmode  open_mode 
)