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

FXStat.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * F i l e S t a t i s t i c s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXStat.h,v 1.24 2006/01/22 17:58:10 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXSTAT_H
25 #define FXSTAT_H
26 
27 
28 namespace FX {
29 
30 
31 class FXFile;
32 
33 
34 /// Statistics about a file or directory
35 class FXAPI FXStat {
36  friend class FXFile;
37 private:
38  FXuint modeFlags; /// Mode bits
39  FXuint userNumber; /// User number
40  FXuint groupNumber; /// Group number
41  FXTime createTime; /// Create time
42  FXTime accessTime; /// Access time
43  FXTime modifyTime; /// Modify time
44  FXlong fileSize; /// File size
45 public:
46 
47  /// Get statistics of the file into the stat buffer info
48  static bool statFile(const FXString& file,FXStat& info);
49 
50  /// Get statistice of the link into the stat buffer info
51  static bool statLink(const FXString& file,FXStat& info);
52 
53  /// Get statistics of already open file into stat buffer info
54  static bool stat(const FXFile& file,FXStat& info);
55 
56  /// Return the mode flags for this file
57  FXuint mode() const { return modeFlags; }
58 
59  /// Return file size in bytes
60  FXlong size() const { return fileSize; }
61 
62  /// Return user number
63  FXuint user() const { return userNumber; }
64 
65  /// Return group number
66  FXuint group() const { return groupNumber; }
67 
68  /// Return time when last modified
69  FXTime modified() const { return modifyTime; }
70 
71  /// Return time when last accessed
72  FXTime accessed() const { return accessTime; }
73 
74  /// Return time when file was created
75  FXTime created() const { return createTime; }
76 
77  /// Return time anything was changed
78  FXTime touched() const;
79 
80  /// Return true if it is a hidden file (Windows-only)
81  bool isHidden() const;
82 
83  /// Return true if it is a regular file
84  bool isFile() const;
85 
86  /// Return true if it is a link
87  bool isLink() const;
88 
89  /// Return true if character device
90  bool isCharacter() const;
91 
92  /// Return true if block device
93  bool isBlock() const;
94 
95  /// Return true if socket device
96  bool isSocket() const;
97 
98  /// Return true if fifo (pipe) device
99  bool isFifo() const;
100 
101  /// Return true if input path is a directory
102  bool isDirectory() const;
103 
104  /// Return true if file is readable
105  bool isReadable() const;
106 
107  /// Return true if file is writable
108  bool isWritable() const;
109 
110  /// Return true if file is executable
111  bool isExecutable() const;
112 
113  /// Return true if owner has read-write-execute permissions
114  bool isOwnerReadWriteExecute() const;
115 
116  /// Return true if owner has read permissions
117  bool isOwnerReadable() const;
118 
119  /// Return true if owner has write permissions
120  bool isOwnerWritable() const;
121 
122  /// Return true if owner has execute permissions
123  bool isOwnerExecutable() const;
124 
125  /// Return true if group has read-write-execute permissions
126  bool isGroupReadWriteExecute() const;
127 
128  /// Return true if group has read permissions
129  bool isGroupReadable() const;
130 
131  /// Return true if group has write permissions
132  bool isGroupWritable() const;
133 
134  /// Return true if group has execute permissions
135  bool isGroupExecutable() const;
136 
137  /// Return true if others have read-write-execute permissions
138  bool isOtherReadWriteExecute() const;
139 
140  /// Return true if others have read permissions
141  bool isOtherReadable() const;
142 
143  /// Return true if others have write permissions
144  bool isOtherWritable() const;
145 
146  /// Return true if others have execute permissions
147  bool isOtherExecutable() const;
148 
149  /// Return true if the file sets the user id on execution
150  bool isSetUid() const;
151 
152  /// Return true if the file sets the group id on execution
153  bool isSetGid() const;
154 
155  /// Return true if the file has the sticky bit set
156  bool isSetSticky() const;
157 
158  /// Return the mode flags for this file
159  static FXuint mode(const FXString& file);
160 
161  /// Change the mode flags for this file
162  static bool mode(const FXString& file,FXuint perm);
163 
164  /// Return true if file exists
165  static bool exists(const FXString& file);
166 
167  /// Return file size in bytes
168  static FXlong size(const FXString& file);
169 
170  /**
171  * Return last modified time for this file, on filesystems
172  * where this is supported. This is the time when any data
173  * in the file was last modified.
174  */
175  static FXTime modified(const FXString& file);
176 
177  /**
178  * Return last accessed time for this file, on filesystems
179  * where this is supported.
180  */
181  static FXTime accessed(const FXString& file);
182 
183  /**
184  * Return created time for this file, on filesystems
185  * where this is supported. This is also the time when
186  * ownership, permissions, links, and other meta-data may
187  * have changed.
188  */
189  static FXTime created(const FXString& file);
190 
191  /**
192  * Return touched time for this file, on filesystems
193  * where this is supported. This is the time when anything
194  * at all, either contents or meta-data, about the file was
195  * changed.
196  */
197  static FXTime touched(const FXString& file);
198 
199  /// Return true if file is hidden
200  static bool isHidden(const FXString& file);
201 
202  /// Return true if input path is a file name
203  static bool isFile(const FXString& file);
204 
205  /// Return true if input path is a link
206  static bool isLink(const FXString& file);
207 
208  /// Return true if input path is a directory
209  static bool isDirectory(const FXString& file);
210 
211  /// Return true if file is readable
212  static bool isReadable(const FXString& file);
213 
214  /// Return true if file is writable
215  static bool isWritable(const FXString& file);
216 
217  /// Return true if file is executable
218  static bool isExecutable(const FXString& file);
219 
220  /// Return true if owner has read-write-execute permissions
221  static bool isOwnerReadWriteExecute(const FXString& file);
222 
223  /// Return true if owner has read permissions
224  static bool isOwnerReadable(const FXString& file);
225 
226  /// Return true if owner has write permissions
227  static bool isOwnerWritable(const FXString& file);
228 
229  /// Return true if owner has execute permissions
230  static bool isOwnerExecutable(const FXString& file);
231 
232  /// Return true if group has read-write-execute permissions
233  static bool isGroupReadWriteExecute(const FXString& file);
234 
235  /// Return true if group has read permissions
236  static bool isGroupReadable(const FXString& file);
237 
238  /// Return true if group has write permissions
239  static bool isGroupWritable(const FXString& file);
240 
241  /// Return true if group has execute permissions
242  static bool isGroupExecutable(const FXString& file);
243 
244  /// Return true if others have read-write-execute permissions
245  static bool isOtherReadWriteExecute(const FXString& file);
246 
247  /// Return true if others have read permissions
248  static bool isOtherReadable(const FXString& file);
249 
250  /// Return true if others have write permissions
251  static bool isOtherWritable(const FXString& file);
252 
253  /// Return true if others have execute permissions
254  static bool isOtherExecutable(const FXString& file);
255 
256  /// Return true if the file sets the user id on execution
257  static bool isSetUid(const FXString& file);
258 
259  /// Return true if the file sets the group id on execution
260  static bool isSetGid(const FXString& file);
261 
262  /// Return true if the file has the sticky bit set
263  static bool isSetSticky(const FXString& file);
264 
265  };
266 
267 
268 }
269 
270 #endif
Statistics about a file or directory.
Definition: FXStat.h:35
unsigned int FXuint
Definition: fxdefs.h:396
#define FXAPI
Definition: fxdefs.h:122
FXuint group()
Get effective group id.
long FXTime
Definition: fxdefs.h:448
Definition: FX4Splitter.h:31
FXuint user()
Get effective user id.
Low level file access.
Definition: FXFile.h:38
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp