![]() |
|
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 fileStat 00027 00028 Description 00029 Wrapper for stat() system call. 00030 00031 WARNING: on Linux (an maybe on others) a stat() of an nfs mounted (remote) 00032 file does never timeout and cannot be interrupted! So e.g. Foam::ping first 00033 and hope nfs is running. 00034 00035 SourceFiles 00036 fileStat.C 00037 00038 \*---------------------------------------------------------------------------*/ 00039 00040 #ifndef fileStat_H 00041 #define fileStat_H 00042 00043 #include <sys/stat.h> 00044 #include <sys/types.h> 00045 00046 #include "label.H" 00047 #include "fileName.H" 00048 00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00050 00051 namespace Foam 00052 { 00053 00054 /*---------------------------------------------------------------------------*\ 00055 Class fileStat Declaration 00056 \*---------------------------------------------------------------------------*/ 00057 00058 class fileStat 00059 { 00060 // Private data 00061 00062 struct stat status_; 00063 00064 bool isValid_; 00065 00066 00067 public: 00068 00069 // Constructors 00070 00071 //- Empty constructor 00072 fileStat(); 00073 00074 //- Construct from components 00075 fileStat(const fileName& fName, const unsigned int maxTime=0); 00076 00077 //- Construct from Istream 00078 fileStat(Istream&); 00079 00080 00081 // Member Functions 00082 00083 // Access 00084 00085 //- Raw status 00086 const struct stat& status() const 00087 { 00088 return status_; 00089 } 00090 00091 //- Did constructor fail 00092 bool isValid() const 00093 { 00094 return isValid_; 00095 } 00096 00097 00098 // Check 00099 00100 //- compare two fileStats for same device 00101 bool sameDevice(const fileStat& stat2) const; 00102 00103 //- compare two fileStats for same Inode 00104 bool sameINode(const fileStat& stat2) const; 00105 00106 //- compare state against inode 00107 bool sameINode(const label iNode) const; 00108 00109 00110 // IOstream Operators 00111 00112 friend Istream& operator>>(Istream&, fileStat&); 00113 friend Ostream& operator<<(Ostream&, const fileStat&); 00114 }; 00115 00116 00117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00118 00119 } // End namespace Foam 00120 00121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00122 00123 #endif 00124 00125 // ************************************************************************* //