OpenFOAM logo
Open Source CFD Toolkit

OSspecific.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     OSspecific
00027 
00028 Description
00029     Functions used by FOAM which are specific to the unix operating system,
00030     and need to be replaced or simulated on any other system.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #ifndef OSspecific_H
00035 #define OSspecific_H
00036 
00037 #include "fileNameList.H"
00038 #include "long.H"
00039 
00040 #include <sys/types.h>
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 //- Return the PID of this process
00050 pid_t pid();
00051 
00052 //- Return the parent PID of this process
00053 pid_t ppid();
00054 
00055 //- Return the group PID of this process
00056 pid_t pgid();
00057 
00058 //- Return true if environment variable of given name is defined
00059 bool env(const word&);
00060 
00061 //- Return environment variable of given name
00062 string getEnv(const word& name);
00063 
00064 //- Set an environment variable
00065 bool setEnv(const word& name, const string& value, const bool overwrite);
00066 
00067 //- Return the system's host name
00068 word hostName();
00069 
00070 //- Return the user's login name
00071 word userName();
00072 
00073 //- Return home directory path name
00074 fileName home();
00075 
00076 //- Return home directory path name
00077 fileName cwd();
00078 
00079 //- Change the current directory to the one given and return true,
00080 //  else return false
00081 bool chDir(const fileName& dir);
00082 
00083 //- Return .foam directory path name
00084 fileName dotFoam(const fileName& name);
00085 
00086 //- Make a directory and return an error if it could not be created
00087 //  and does not already exist
00088 bool mkDir(const fileName&, mode_t=0754);
00089 
00090 //- Set the file mode
00091 bool chmod(const fileName&, const mode_t=0640);
00092 
00093 //- Return the file mode
00094 mode_t mode(const fileName&);
00095 
00096 //- Return the file type: FILE or DIRECTORY
00097 fileName::Type type(const fileName&);
00098 
00099 //- Does the name exist in the filing system?
00100 bool exists(const fileName& name);
00101 
00102 //- Does the file exist?
00103 bool file(const fileName&);
00104 
00105 //- Does the directory exist?
00106 bool dir(const fileName&);
00107 
00108 //- Return size of file
00109 off_t size(const fileName&);
00110 
00111 //- Return time of last file modification
00112 time_t lastModified(const fileName&);
00113 
00114 //- Read a directory and return the entries as a string list
00115 fileNameList readDir
00116 (
00117     const fileName&,
00118     const fileName::Type=fileName::FILE,
00119     const bool filtergz=true
00120 );
00121 
00122 //- Copy, recursively if necessary, the source to the destination
00123 bool cp(const fileName& srcFile, const fileName& destFile);
00124 
00125 //- Rename srcFile destFile
00126 bool mv(const fileName& srcFile, const fileName& destFile);
00127 
00128 //- Remove a file returning true if successful otherwise false
00129 bool rm(const fileName&);
00130 
00131 //- Remove a dirctory and it's contents
00132 bool rmDir(const fileName&);
00133 
00134 //- Sleep for the specified number of seconds
00135 unsigned int sleep(const unsigned int);
00136 
00137 //- Close file descriptor
00138 void fdClose(const int);
00139 
00140 //- Check if machine is up by pinging given port
00141 bool ping(const word&, const label port, const label timeOut);
00142 
00143 //- Check if machine is up by ping port 22 = ssh and 222 = rsh
00144 bool ping(const word&, const label timeOut=10);
00145 
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 } // End namespace Foam
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 #endif
00154 
00155 // ************************************************************************* //
For further information go to www.openfoam.org