Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXStat.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                        F i l e   S t a t i s t i c s                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2005,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXStat.h,v 1.33 2009/01/06 13:07:27 fox Exp $                            *
00022 ********************************************************************************/
00023 #ifndef FXSTAT_H
00024 #define FXSTAT_H
00025 
00026 
00027 namespace FX {
00028 
00029 
00030 class FXFile;
00031 
00032 
00033 /// Statistics about a file or directory
00034 class FXAPI FXStat {
00035   friend class FXFile;
00036 private:
00037   FXuint  modeFlags;            /// Mode bits
00038   FXuint  userNumber;           /// User number
00039   FXuint  groupNumber;          /// Group number
00040   FXuint  linkCount;            /// Number of links
00041   FXTime  createTime;           /// Create time (ns)
00042   FXTime  accessTime;           /// Access time (ns)
00043   FXTime  modifyTime;           /// Modify time (ns)
00044   FXlong  fileVolume;           /// File volume (device)
00045   FXlong  fileIndex;            /// File index (inode)
00046   FXlong  fileSize;             /// File size
00047 public:
00048 
00049   /// Get statistics of the file into the stat buffer info
00050   static FXbool statFile(const FXString& file,FXStat& info);
00051 
00052   /// Get statistice of the link into the stat buffer info
00053   static FXbool statLink(const FXString& file,FXStat& info);
00054 
00055   /// Get statistics of already open file into stat buffer info
00056   static FXbool stat(const FXFile& file,FXStat& info);
00057 
00058   /// Return the mode flags for this file
00059   FXuint mode() const { return modeFlags; }
00060 
00061   /// Return file size in bytes
00062   FXlong size() const { return fileSize; }
00063 
00064   /// Return user number
00065   FXuint user() const { return userNumber; }
00066 
00067   /// Return group number
00068   FXuint group() const { return groupNumber; }
00069 
00070   /// Return number of links to file
00071   FXuint links() const { return linkCount; }
00072 
00073   /// Return file volume number
00074   FXlong volume() const { return fileVolume; }
00075 
00076   /// Return file index number
00077   FXlong index() const { return fileIndex; }
00078 
00079   /// Return time when last modified, in nanoseconds
00080   FXTime modified() const { return modifyTime; }
00081 
00082   /// Return time when last accessed, in nanoseconds
00083   FXTime accessed() const { return accessTime; }
00084 
00085   /// Return time when file was created, in nanoseconds
00086   FXTime created() const { return createTime; }
00087 
00088   /// Return true if it is a hidden file (Windows-only)
00089   FXbool isHidden() const;
00090 
00091   /// Return true if it is a regular file
00092   FXbool isFile() const;
00093 
00094   /// Return true if it is a link
00095   FXbool isLink() const;
00096 
00097   /// Return true if character device
00098   FXbool isCharacter() const;
00099 
00100   /// Return true if block device
00101   FXbool isBlock() const;
00102 
00103   /// Return true if socket device
00104   FXbool isSocket() const;
00105 
00106   /// Return true if fifo (pipe) device
00107   FXbool isFifo() const;
00108 
00109   /// Return true if input path is a directory
00110   FXbool isDirectory() const;
00111 
00112   /// Return true if file is readable
00113   FXbool isReadable() const;
00114 
00115   /// Return true if file is writable
00116   FXbool isWritable() const;
00117 
00118   /// Return true if file is executable
00119   FXbool isExecutable() const;
00120 
00121   /// Return true if owner has read-write-execute permissions
00122   FXbool isOwnerReadWriteExecute() const;
00123 
00124   /// Return true if owner has read permissions
00125   FXbool isOwnerReadable() const;
00126 
00127   /// Return true if owner has write permissions
00128   FXbool isOwnerWritable() const;
00129 
00130   /// Return true if owner has execute permissions
00131   FXbool isOwnerExecutable() const;
00132 
00133   /// Return true if group has read-write-execute permissions
00134   FXbool isGroupReadWriteExecute() const;
00135 
00136   /// Return true if group has read permissions
00137   FXbool isGroupReadable() const;
00138 
00139   /// Return true if group has write permissions
00140   FXbool isGroupWritable() const;
00141 
00142   /// Return true if group has execute permissions
00143   FXbool isGroupExecutable() const;
00144 
00145   /// Return true if others have read-write-execute permissions
00146   FXbool isOtherReadWriteExecute() const;
00147 
00148   /// Return true if others have read permissions
00149   FXbool isOtherReadable() const;
00150 
00151   /// Return true if others have write permissions
00152   FXbool isOtherWritable() const;
00153 
00154   /// Return true if others have execute permissions
00155   FXbool isOtherExecutable() const;
00156 
00157   /// Return true if the file sets the user id on execution
00158   FXbool isSetUid() const;
00159 
00160   /// Return true if the file sets the group id on execution
00161   FXbool isSetGid() const;
00162 
00163   /// Return true if the file has the sticky bit set
00164   FXbool isSetSticky() const;
00165 
00166   /// Return the mode flags for this file
00167   static FXuint mode(const FXString& file);
00168 
00169   /// Change the mode flags for this file
00170   static FXbool mode(const FXString& file,FXuint perm);
00171 
00172   /// Return true if file exists
00173   static FXbool exists(const FXString& file);
00174 
00175   /// Return file size in bytes
00176   static FXlong size(const FXString& file);
00177 
00178   /// Return file volume number
00179   static FXlong volume(const FXString& file);
00180 
00181   /// Return file index number
00182   static FXlong index(const FXString& file);
00183 
00184   /// Return number of links to file
00185   static FXuint links(const FXString& file);
00186 
00187   /**
00188   * Return last modified time for this file, on filesystems
00189   * where this is supported.  This is the time when any data
00190   * in the file was last modified, in nanoseconds since Epoch.
00191   */
00192   static FXTime modified(const FXString& file);
00193 
00194   /**
00195   * Return last accessed time for this file, on filesystems
00196   * where this is supported, in nanoseconds since Epoch.
00197   */
00198   static FXTime accessed(const FXString& file);
00199 
00200   /**
00201   * Return created time for this file, on filesystems
00202   * where this is supported.  This is also the time when
00203   * ownership, permissions, links, and other meta-data may
00204   * have changed, in nanoseconds since Epoch.
00205   */
00206   static FXTime created(const FXString& file);
00207 
00208   /// Return true if file is hidden
00209   static FXbool isHidden(const FXString& file);
00210 
00211   /// Return true if input path is a file name
00212   static FXbool isFile(const FXString& file);
00213 
00214   /// Return true if input path is a link
00215   static FXbool isLink(const FXString& file);
00216 
00217   /// Return true if input path is a directory
00218   static FXbool isDirectory(const FXString& file);
00219 
00220   /// Return true if file is readable
00221   static FXbool isReadable(const FXString& file);
00222 
00223   /// Return true if file is writable
00224   static FXbool isWritable(const FXString& file);
00225 
00226   /// Return true if file is executable
00227   static FXbool isExecutable(const FXString& file);
00228 
00229   /// Return true if owner has read-write-execute permissions
00230   static FXbool isOwnerReadWriteExecute(const FXString& file);
00231 
00232   /// Return true if owner has read permissions
00233   static FXbool isOwnerReadable(const FXString& file);
00234 
00235   /// Return true if owner has write permissions
00236   static FXbool isOwnerWritable(const FXString& file);
00237 
00238   /// Return true if owner has execute permissions
00239   static FXbool isOwnerExecutable(const FXString& file);
00240 
00241   /// Return true if group has read-write-execute permissions
00242   static FXbool isGroupReadWriteExecute(const FXString& file);
00243 
00244   /// Return true if group has read permissions
00245   static FXbool isGroupReadable(const FXString& file);
00246 
00247   /// Return true if group has write permissions
00248   static FXbool isGroupWritable(const FXString& file);
00249 
00250   /// Return true if group has execute permissions
00251   static FXbool isGroupExecutable(const FXString& file);
00252 
00253   /// Return true if others have read-write-execute permissions
00254   static FXbool isOtherReadWriteExecute(const FXString& file);
00255 
00256   /// Return true if others have read permissions
00257   static FXbool isOtherReadable(const FXString& file);
00258 
00259   /// Return true if others have write permissions
00260   static FXbool isOtherWritable(const FXString& file);
00261 
00262   /// Return true if others have execute permissions
00263   static FXbool isOtherExecutable(const FXString& file);
00264 
00265   /// Return true if the file sets the user id on execution
00266   static FXbool isSetUid(const FXString& file);
00267 
00268   /// Return true if the file sets the group id on execution
00269   static FXbool isSetGid(const FXString& file);
00270 
00271   /// Return true if the file has the sticky bit set
00272   static FXbool isSetSticky(const FXString& file);
00273 
00274   };
00275 
00276 
00277 }
00278 
00279 #endif

Copyright © 1997-2009 Jeroen van der Zijp