Geant4 11.3.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 G4String &file)
 
G4String StrErrNo () const
 
G4int Shell (const G4String &str)
 
G4int CopyFile (const G4String &srcFile, const G4String &dstFile)
 
G4int DeleteFile (const G4String &file, const G4String &option)
 
G4String GetEnv (const G4String &env)
 

Detailed Description

Definition at line 40 of file G4FileUtilities.hh.

Constructor & Destructor Documentation

◆ G4FileUtilities()

G4FileUtilities::G4FileUtilities ( )

Definition at line 42 of file G4FileUtilities.cc.

43{
44}

◆ ~G4FileUtilities()

G4FileUtilities::~G4FileUtilities ( )

Definition at line 47 of file G4FileUtilities.cc.

48{
49}

Member Function Documentation

◆ CopyFile()

G4int G4FileUtilities::CopyFile ( const G4String & srcFile,
const G4String & dstFile )

Definition at line 82 of file G4FileUtilities.cc.

84{
85 G4String cmd = "cp " + srcFile + " " + dstFile;
86 return Shell(cmd);
87}
G4int Shell(const G4String &str)

◆ DeleteFile()

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

Definition at line 90 of file G4FileUtilities.cc.

92{
93 G4String cmd = "rm " + option + " " + file;
94 return Shell(cmd);
95}

◆ FileExists()

G4bool G4FileUtilities::FileExists ( const G4String & file)

Definition at line 52 of file G4FileUtilities.cc.

53{
54 char* c = (char*) file.c_str();
55
56 G4int fd = ::open(c, O_RDONLY);
57 // G4int error = errno;
58 if(fd != -1)
59 {
60 ::close(fd);
61 return true;
62 }
63 else
64 {
65 return false;
66 }
67}
int G4int
Definition G4Types.hh:85

◆ GetEnv()

G4String G4FileUtilities::GetEnv ( const G4String & env)

Definition at line 98 of file G4FileUtilities.cc.

99{
100 return ::getenv(env.c_str());
101}

◆ Shell()

G4int G4FileUtilities::Shell ( const G4String & str)

Definition at line 76 of file G4FileUtilities.cc.

77{
78 return ::system(str.c_str());
79}

Referenced by CopyFile(), and DeleteFile().

◆ StrErrNo()

G4String G4FileUtilities::StrErrNo ( ) const

Definition at line 70 of file G4FileUtilities.cc.

71{
72 return ::strerror(errno);
73}

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