Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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::G4FileUtilities ( )

Definition at line 36 of file G4FileUtilities.cc.

37{
38}

◆ ~G4FileUtilities()

G4FileUtilities::~G4FileUtilities ( )

Definition at line 41 of file G4FileUtilities.cc.

42{
43}

Member Function Documentation

◆ CopyFile()

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

Definition at line 61 of file G4FileUtilities.cc.

62{
63 std::string cmd = "cp " + srcFile + " " + dstFile;
64 return Shell( cmd );
65}
G4int Shell(std::string str)

◆ DeleteFile()

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

Definition at line 68 of file G4FileUtilities.cc.

69{
70 std::string cmd = "rm " + option + " " + file;
71 return Shell( cmd );
72}

◆ FileExists()

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

Definition at line 46 of file G4FileUtilities.cc.

47{
48 char* c = (char *) file.c_str();
49
50 G4int fd = ::open( c, O_RDONLY );
51 // G4int error = errno;
52 if ( fd != -1 ) {
53 ::close( fd );
54 return true;
55 } else {
56 return false;
57 }
58}
int G4int
Definition: G4Types.hh:66

Referenced by G4PersistencyCenter::SetReadFile().

◆ GetEnv()

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

Definition at line 74 of file G4FileUtilities.hh.

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

◆ Shell()

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

Definition at line 65 of file G4FileUtilities.hh.

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

Referenced by CopyFile(), and DeleteFile().

◆ StrErrNo()

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

Definition at line 62 of file G4FileUtilities.hh.

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

The documentation for this class was generated from the following files: