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

Copyright © 1997-2005 Jeroen van der Zijp