Geant4 11.2.2
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 G4String &file)
 
std::string StrErrNo () const
 
G4int Shell (const G4String &str)
 
G4int CopyFile (const G4String &srcFile, const G4String &dstFile)
 
G4int DeleteFile (const G4String &file, const G4String &option)
 
std::string GetEnv (const G4String &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 G4String & srcFile,
const G4String & dstFile )

Definition at line 64 of file G4FileUtilities.cc.

66{
67 std::string cmd = "cp " + srcFile + " " + dstFile;
68 return Shell(cmd);
69}
G4int Shell(const G4String &str)

◆ DeleteFile()

G4int G4FileUtilities::DeleteFile ( const G4String & file,
const G4String & option )

Definition at line 72 of file G4FileUtilities.cc.

74{
75 std::string cmd = "rm " + option + " " + file;
76 return Shell(cmd);
77}

◆ FileExists()

G4bool G4FileUtilities::FileExists ( const G4String & 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 {
54 ::close(fd);
55 return true;
56 }
57 else
58 {
59 return false;
60 }
61}
int G4int
Definition G4Types.hh:85

Referenced by G4PersistencyCenter::SetReadFile().

◆ GetEnv()

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

Definition at line 74 of file G4FileUtilities.hh.

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

◆ Shell()

G4int G4FileUtilities::Shell ( const G4String & 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: