G4FileUtilities Class Reference

#include <G4FileUtilities.hh>


Public Member Functions

 G4FileUtilities ()
 ~G4FileUtilities ()
G4bool FileExists (const std::string file)
std::string StrErrNo () const
G4int Shell (std::string str)
G4int CopyFile (const std::string srcFile, const std::string dstFile)
G4int DeleteFile (const std::string file, const std::string option)
std::string GetEnv (const std::string env)


Detailed Description

Definition at line 49 of file G4FileUtilities.hh.


Constructor & Destructor Documentation

G4FileUtilities::G4FileUtilities (  ) 

Definition at line 36 of file G4FileUtilities.cc.

00037 {
00038 }

G4FileUtilities::~G4FileUtilities (  ) 

Definition at line 41 of file G4FileUtilities.cc.

00042 {
00043 }


Member Function Documentation

G4int G4FileUtilities::CopyFile ( const std::string  srcFile,
const std::string  dstFile 
)

Definition at line 61 of file G4FileUtilities.cc.

References Shell().

00062 {
00063   std::string cmd = "cp " + srcFile + " " + dstFile;
00064   return Shell( cmd );
00065 }

G4int G4FileUtilities::DeleteFile ( const std::string  file,
const std::string  option 
)

Definition at line 68 of file G4FileUtilities.cc.

References Shell().

00069 {
00070   std::string cmd = "rm " + option + " " + file;
00071   return Shell( cmd );
00072 }

G4bool G4FileUtilities::FileExists ( const std::string  file  ) 

Definition at line 46 of file G4FileUtilities.cc.

Referenced by G4PersistencyCenter::SetReadFile().

00047 {
00048   char* c = (char *) file.c_str();
00049 
00050   G4int fd = ::open( c, O_RDONLY ); 
00051   // G4int error = errno;
00052   if ( fd != -1 ) {
00053     ::close( fd );
00054     return true;
00055   } else {
00056     return false;
00057   }
00058 }

std::string G4FileUtilities::GetEnv ( const std::string  env  )  [inline]

Definition at line 74 of file G4FileUtilities.hh.

00074 { return ::getenv(env.c_str()); };

G4int G4FileUtilities::Shell ( std::string  str  )  [inline]

Definition at line 65 of file G4FileUtilities.hh.

Referenced by CopyFile(), and DeleteFile().

00065 { return ::system(str.c_str()); };

std::string G4FileUtilities::StrErrNo (  )  const [inline]

Definition at line 62 of file G4FileUtilities.hh.

00062 { return ::strerror(errno); };


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:59 2013 for Geant4 by  doxygen 1.4.7