Changeset 83:10f32063cdf7 in rrlib_util


Ignore:
Timestamp:
04.04.2013 08:31:02 (7 years ago)
Author:
Patrick Fleischmann <fleischmann@…>
Branch:
default
Phase:
public
Transplant:
41b7c54657c4ff560188783c285cc2880cf4e860
Message:

Method added to test if a file exists

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sFileIOUtils.cpp

    r61 r83  
    203203 
    204204//---------------------------------------------------------------------- 
     205// class sFileIOUtils::FileExists() 
     206//---------------------------------------------------------------------- 
     207bool sFileIOUtils::FileExists(const std::string &filename) 
     208{ 
     209  // catch empty file 
     210  if (filename == "") 
     211  { 
     212    return false; 
     213  } 
     214 
     215  // test if file exists 
     216  FILE* file = fopen(filename.c_str(), "rb"); 
     217  if (file == 0) 
     218  { 
     219    return false; 
     220  } 
     221  fclose(file); 
     222 
     223  return true; 
     224} 
     225 
     226 
     227//---------------------------------------------------------------------- 
    205228// class sFileIOUtils::ShellExpandFilename() 
    206229//---------------------------------------------------------------------- 
  • sFileIOUtils.h

    r61 r83  
    121121   */ 
    122122  static void DecompressFile(const std::string& input_filename, const std::string& output_filename); 
     123 
     124 
     125  /*! 
     126   * \brief Test if file exists for given file name 
     127   * 
     128   * \returns true if file exists 
     129   */ 
     130  static bool FileExists(const std::string &filename); 
    123131 
    124132 
Note: See TracChangeset for help on using the changeset viewer.