00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Benjamin Hadorn (bhadorn@swissinfo.org) * 00003 *************************************************************************** 00004 * Projekt : Zeus 00005 * Module : DirectoryItem 00006 * Package : System 00007 * Author : Benjamin Hadorn 00008 * Datum : $Date: 10.09.09 16:59 $ 00009 * Ablage : $File$ 00010 * System : Cell Computing Model 00011 *************************************************************************** 00012 * Licence: * 00013 * This library is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU Lesser General Public License as * 00015 * published by the Free Software Foundation; either version * 00016 * 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00026 ***************************************************************************/ 00027 00028 /*************************************************************************** 00029 Changes : 00030 $Log: /Development_F/StuderWIN/dev/Zeus/src/zeusbase/System/DirectoryItem.h $ 00031 ** 00032 ** 11 10.09.09 16:59 Bha 00033 ** changed directory item type 00034 ** 00035 ** 10 27.03.09 15:11 Bha 00036 ** new version 1.0 implemented 00037 ** 00038 ** 9 26.02.07 9:00 bha 00039 ***************************************************************************/ 00040 //--------------------------------------------------------------------------- 00041 00042 #ifndef DirectoryItemH 00043 #define DirectoryItemH 00044 //--------------------------------------------------------------------------- 00045 00046 #include <zeusbase/System/String.h> 00047 #include <zeusbase/System/ZObject.h> 00048 00049 00050 #if defined(ENABLE_LINUX_BINDING) 00051 struct dirent; 00052 //#include <dirent.h> 00053 00054 #elif defined(ENABLE_WIN32_BINDING) 00055 00056 #if defined(_MSC_VER) 00057 struct _wfinddata_t; 00058 #else 00059 namespace std 00060 { 00061 struct _wffblk; 00062 }; 00063 #endif 00064 00065 #endif 00066 00067 00068 BEGIN_NAMESPACE_Zeus 00069 00070 /***************************************************************************/ 00073 /***************************************************************************/ 00074 zeusbase_class TDirectoryItem : public TZObject 00075 { 00076 public: 00077 #if defined(ENABLE_LINUX_BINDING) 00078 TDirectoryItem(const TString& rDirName,struct dirent& rFileBlock); 00079 #elif defined(ENABLE_WIN32_BINDING) 00080 00081 #if defined(_MSC_VER) 00082 TDirectoryItem(const TString& rDirName, struct _wfinddata_t& rFileBlock); 00083 #else 00084 TDirectoryItem(const TString& rDirName, struct std::_wffblk& rFileBlock); 00085 #endif 00086 #endif 00087 TDirectoryItem(); 00088 TDirectoryItem(const TDirectoryItem& rInPar); 00089 virtual ~TDirectoryItem(); 00090 00091 TString getName() const; 00092 TString getAbsoluteName() const; 00093 Timeval getModificationTime() const; 00094 Int64 getSize() const; 00095 Uint64 getFileStamp() const; 00096 bool isDirectory() const; 00097 bool isFile() const; 00098 bool isHidden() const; 00099 bool isSystem() const; 00100 00101 bool operator==(const TDirectoryItem& rInPar) const; 00102 TDirectoryItem& operator=(const TDirectoryItem& rInPar); 00103 00104 protected: 00106 TString m_strName; 00108 TString m_strDirName; 00109 00110 private: 00111 //File attributes 00112 Uint m_uiFileAttributes; 00114 Int64 m_ldSize; 00116 Timeval m_tmModificationTime; 00117 }; 00118 00119 //inline methods 00120 /***************************************************************************/ 00123 /***************************************************************************/ 00124 inline TString TDirectoryItem::getName() const 00125 { 00126 return m_strName; 00127 } 00128 00129 /***************************************************************************/ 00132 /***************************************************************************/ 00133 inline TString TDirectoryItem::getAbsoluteName() const 00134 { 00135 return TString(m_strDirName + m_strName); 00136 } 00137 00138 00139 /***************************************************************************/ 00142 /***************************************************************************/ 00143 inline Timeval TDirectoryItem::getModificationTime() const 00144 { 00145 return m_tmModificationTime; 00146 } 00147 00148 /***************************************************************************/ 00151 /***************************************************************************/ 00152 inline Int64 TDirectoryItem::getSize() const 00153 { 00154 return m_ldSize; 00155 } 00156 00157 /***************************************************************************/ 00160 /***************************************************************************/ 00161 inline Uint64 TDirectoryItem::getFileStamp() const 00162 { 00163 Uint64 uldFileAttr = m_uiFileAttributes; 00164 return (uldFileAttr << 32) | m_tmModificationTime; 00165 } 00166 00167 00168 /***************************************************************************/ 00171 /***************************************************************************/ 00172 inline bool TDirectoryItem::isFile() const 00173 { 00174 return !isDirectory(); 00175 } 00176 00177 /***************************************************************************/ 00180 /***************************************************************************/ 00181 inline bool TDirectoryItem::operator==(const TDirectoryItem& rInPar) const 00182 { 00183 return (m_strName == rInPar.m_strName && 00184 m_strDirName == rInPar.m_strDirName && 00185 m_uiFileAttributes == rInPar.m_uiFileAttributes && 00186 m_ldSize == rInPar.m_ldSize && 00187 m_tmModificationTime == rInPar.m_tmModificationTime); 00188 } 00189 00190 /***************************************************************************/ 00193 /***************************************************************************/ 00194 inline TDirectoryItem& TDirectoryItem::operator=(const TDirectoryItem& rInPar) 00195 { 00196 this->m_strName = rInPar.m_strName; 00197 this->m_strDirName = rInPar.m_strDirName; 00198 this->m_uiFileAttributes = rInPar.m_uiFileAttributes; 00199 this->m_ldSize = rInPar.m_ldSize; 00200 this->m_tmModificationTime = rInPar.m_tmModificationTime; 00201 return *this; 00202 } 00203 00204 00205 END_NAMESPACE_Zeus 00206 00207 #endif