G4FileUtilities.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // File: G4FileUtilities.hh
00027 //
00028 // History:
00029 //   01.08.24  Youhei Morita  Initial creation
00030 
00031 #ifndef FILE_UTILITIES_HH
00032 #define FILE_UTILITIES_HH 1
00033 
00034 #include "G4Types.hh"
00035 
00036 #include <sys/types.h>
00037 #include <fcntl.h>
00038 #include <unistd.h>
00039 #include <errno.h>
00040 #include <stdlib.h>
00041 #include <string.h>
00042 #include <string>
00043 #include <iostream>
00044 
00045 
00046 // Class Description:
00047 //   File utilities to access files with POSIX interface.
00048 
00049 class G4FileUtilities
00050 {
00051     public: // With description
00052       G4FileUtilities();
00053       // Constructor
00054 
00055       ~G4FileUtilities();
00056       // Destructor
00057 
00058     public: // With description
00059       G4bool FileExists(const std::string file);
00060       // checks if the "file" exists.  returns true if it does.
00061 
00062       std::string StrErrNo() const { return ::strerror(errno); };
00063       // returns the error message of the last system call as string.
00064 
00065       G4int Shell(std::string str) { return ::system(str.c_str()); };
00066       // execute the shell command.  returns zero if success.
00067 
00068       G4int CopyFile(const std::string srcFile, const std::string dstFile);
00069       // copies the "srcFile" to "dstFile".  returns zero if success.
00070 
00071       G4int DeleteFile(const std::string file, const std::string option);
00072       // deletes the "file" with the "option".  returns zero if success.
00073 
00074       std::string GetEnv(const std::string env) { return ::getenv(env.c_str()); };
00075       // retuns the value of environment variable as string.
00076 
00077 }; // End of class G4FileUtilities
00078 
00079 #endif
00080 

Generated on Mon May 27 17:48:16 2013 for Geant4 by  doxygen 1.4.7