Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vul_file.h

Go to the documentation of this file.
00001 // This is core/vul/vul_file.h
00002 #ifndef vul_file_h_
00003 #define vul_file_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A collection of miscellaneous filesystem-type utilities
00010 // \author Andrew W. Fitzgibbon, Oxford RRG
00011 // \date   02 Nov 98
00012 //
00013 // \verbatim
00014 // Modifications
00015 // 981102 AWF Initial version.
00016 // PDA (Manchester) 21/03/2001: Tidied up the documentation
00017 //   Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
00018 //   Jun.2003 - Ian Scott      - added support for '\' file separator to dos version
00019 // \endverbatim
00020 
00021 #include <vcl_string.h>
00022 
00023 //: A collection of miscellaneous filesystem-type utilities
00024 //
00025 struct vul_file
00026 {
00027   //: Return current working directory
00028   static vcl_string get_cwd();
00029 
00030   //: change current working directory
00031   static bool change_directory(char const* dirname);
00032   static bool change_directory(vcl_string const& dirname) {
00033     return change_directory(dirname.c_str());
00034   }
00035 
00036   //: Make a writable directory.
00037   // You might imagine mkdir would be a better name,
00038   // and then you might imagine a world w/out ms.
00039   static bool make_directory(char const* filename);
00040   static bool make_directory(vcl_string const& filename) {
00041     return make_directory(filename.c_str());
00042   }
00043 
00044   //: Make a writable directory, including any necessary parents.
00045   // Returns true if successful, or if the directory alredy exists.
00046   static bool make_directory_path(char const* filename);
00047   static bool make_directory_path(vcl_string const& filename) {
00048     return make_directory_path(filename.c_str());
00049   }
00050 
00051   //: Return true iff filename is a directory.
00052   static bool is_directory(char const* filename);
00053   static bool is_directory(const vcl_string& filename) {
00054     return is_directory(filename.c_str());
00055   }
00056 
00057   //: Expand any leading ~ escapes in filename
00058   static vcl_string expand_tilde(char const* filename);
00059   static vcl_string expand_tilde(vcl_string const& filename) {
00060     return expand_tilde(filename.c_str());
00061   }
00062 
00063   //: Return true iff filename exists.  It may be any sort of file.
00064   static bool exists(char const* filename);
00065   static bool exists(vcl_string const& filename) {
00066     return exists(filename.c_str());
00067   }
00068 
00069   //: Return size of vul_file
00070   static unsigned long size(char const* filename);
00071   static unsigned long size(vcl_string filename) { return size(filename.c_str()); }
00072 
00073   //: Return dirname
00074   static vcl_string dirname(char const* filename);
00075   static vcl_string dirname(vcl_string const& filename) {
00076     return dirname(filename.c_str());
00077   }
00078 
00079   //: Return extension (including the '.').
00080   static vcl_string extension(char const* filename);
00081   static vcl_string extension(vcl_string const& filename) {
00082     return extension( filename.c_str() );
00083   }
00084 
00085   //: Return basename
00086   static vcl_string basename(char const* filename, char const* suffix = 0);
00087   static vcl_string basename(vcl_string const& filename, char const* suffix = 0) {
00088     return basename(filename.c_str(), suffix );
00089   }
00090 
00091   //: Strips away directory of the filename
00092   static vcl_string strip_directory(char const* filename);
00093   static vcl_string strip_directory(vcl_string const &filename)
00094   { return strip_directory(filename.c_str()); }
00095 
00096   //: Strips away extension of the filename
00097   static vcl_string strip_extension(char const* filename);
00098   static vcl_string strip_extension(vcl_string const &filename)
00099   { return strip_extension(filename.c_str()); }
00100 
00101   //: Delete 1 or more files using the Local OS preferred globbing.
00102   // E.g. \c delete_file_glob("*"); will delete all the files in the
00103   // current directory on most operating systems.
00104   // \return true if successful.
00105   static bool delete_file_glob(char const* file_glob);
00106 };
00107 
00108 inline bool vul_file_exists(char const *f) { return vul_file::exists(f); }
00109 inline bool vul_file_exists(vcl_string  f) { return vul_file::exists(f); }
00110 
00111 inline bool vul_file_is_directory(char const *f) { return vul_file::is_directory(f); }
00112 inline bool vul_file_is_directory(vcl_string  f) { return vul_file::is_directory(f); }
00113 
00114 inline unsigned long vul_file_size(char const *f) { return vul_file::size(f); }
00115 inline unsigned long vul_file_size(vcl_string  f) { return vul_file::size(f); }
00116 
00117 inline vcl_string vul_file_extension(char const *f) { return vul_file::extension(f); }
00118 inline vcl_string vul_file_extension(vcl_string  f) { return vul_file_extension(f.c_str()); }
00119 
00120 #endif // vul_file_h_

Generated on Thu Jan 10 14:41:00 2008 for core/vul by  doxygen 1.4.4