Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

pdirect.h

Go to the documentation of this file.
00001 /* 00002 * pdirect.h 00003 * 00004 * File system directory class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Log: pdirect.h,v $ 00030 * Revision 1.41 2003/09/17 05:41:58 csoutheren 00031 * Removed recursive includes 00032 * 00033 * Revision 1.40 2003/09/17 01:18:02 csoutheren 00034 * Removed recursive include file system and removed all references 00035 * to deprecated coooperative threading support 00036 * 00037 * Revision 1.39 2003/06/06 15:04:17 dsandras 00038 * 00039 * Fixed compilation warning with gcc 3.3 by removing the PINLINE 00040 * 00041 * Revision 1.38 2002/11/20 00:13:43 robertj 00042 * Fixed some documentation 00043 * 00044 * Revision 1.37 2002/11/19 12:07:02 robertj 00045 * Added function to get root directory. 00046 * 00047 * Revision 1.36 2002/11/19 10:34:59 robertj 00048 * Added function to extract a path as an array of directories components. 00049 * 00050 * Revision 1.35 2002/09/16 01:08:59 robertj 00051 * Added #define so can select if #pragma interface/implementation is used on 00052 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00053 * 00054 * Revision 1.34 2001/05/22 12:49:32 robertj 00055 * Did some seriously wierd rewrite of platform headers to eliminate the 00056 * stupid GNU compiler warning about braces not matching. 00057 * 00058 * Revision 1.33 2001/02/13 06:55:21 robertj 00059 * Fixed problem with operator= in PDirectory class, part of larger change previously made. 00060 * 00061 * Revision 1.32 2000/06/26 11:17:19 robertj 00062 * Nucleus++ port (incomplete). 00063 * 00064 * Revision 1.31 2000/04/03 18:41:27 robertj 00065 * Fixed BeOS compatibility problem with openlog() function. 00066 * 00067 * Revision 1.30 1999/03/09 02:59:50 robertj 00068 * Changed comments to doc++ compatible documentation. 00069 * 00070 * Revision 1.29 1999/02/16 08:11:09 robertj 00071 * MSVC 6.0 compatibility changes. 00072 * 00073 * Revision 1.28 1998/09/23 06:21:06 robertj 00074 * Added open source copyright license. 00075 * 00076 * Revision 1.27 1998/03/05 12:44:34 robertj 00077 * Added cluster size. 00078 * 00079 * Revision 1.26 1997/03/31 11:34:00 robertj 00080 * Fixed default permissions for directories , different from that for files. 00081 * 00082 * Revision 1.25 1997/01/12 04:22:21 robertj 00083 * Added function to get disk size and free space. 00084 * 00085 * Revision 1.24 1995/12/23 03:45:31 robertj 00086 * Added constructor for C string literals. 00087 * 00088 * Revision 1.23 1995/11/09 12:17:23 robertj 00089 * Added platform independent base type access classes. 00090 * 00091 * Revision 1.22 1995/10/14 15:02:22 robertj 00092 * Added function to get parent directory. 00093 * 00094 * Revision 1.21 1995/06/17 11:12:52 robertj 00095 * Documentation update. 00096 * 00097 * Revision 1.20 1995/03/14 12:42:00 robertj 00098 * Updated documentation to use HTML codes. 00099 * 00100 * Revision 1.19 1995/03/12 04:42:48 robertj 00101 * Updated documentation. 00102 * Changed return type of functions to the correct case string. 00103 * 00104 * Revision 1.18 1995/02/22 10:50:33 robertj 00105 * Changes required for compiling release (optimised) version. 00106 * 00107 * Revision 1.17 1995/01/06 10:42:25 robertj 00108 * Moved identifiers into different scope. 00109 * Changed file size to 64 bit integer. 00110 * Documentation 00111 * 00112 * Revision 1.16 1994/10/24 00:07:03 robertj 00113 * Changed PFilePath and PDirectory so descends from either PString or 00114 * PCaselessString depending on the platform. 00115 * 00116 * Revision 1.15 1994/10/23 04:49:25 robertj 00117 * Chnaged PDirectory to descend of PString. 00118 * Added PDirectory Exists() function. 00119 * 00120 * Revision 1.14 1994/08/23 11:32:52 robertj 00121 * Oops 00122 * 00123 * Revision 1.13 1994/08/22 00:46:48 robertj 00124 * Added pragma fro GNU C++ compiler. 00125 * 00126 * Revision 1.12 1994/06/25 11:55:15 robertj 00127 * Unix version synchronisation. 00128 * 00129 * Revision 1.11 1994/04/20 12:17:44 robertj 00130 * Split name into PFilePath 00131 * 00132 * Revision 1.10 1994/04/11 14:16:27 robertj 00133 * Added function for determining if character is a valid directory separator. 00134 * 00135 * Revision 1.9 1994/04/01 14:14:57 robertj 00136 * Put platform independent file permissions and type codes back. 00137 * 00138 * Revision 1.7 1994/01/13 03:17:55 robertj 00139 * Added functions to get the name of the volume the directory is contained in 00140 * and a function to determine if the directory is a root directory of the 00141 * volume (ie is does not have a parent directory). 00142 * 00143 * Revision 1.6 1994/01/03 04:42:23 robertj 00144 * Mass changes to common container classes and interactors etc etc etc. 00145 * 00146 * Revision 1.5 1993/12/31 06:45:38 robertj 00147 * Made inlines optional for debugging purposes. 00148 * 00149 * Revision 1.4 1993/08/21 01:50:33 robertj 00150 * Made Clone() function optional, default will assert if called. 00151 * 00152 * Revision 1.3 1993/07/14 12:49:16 robertj 00153 * Fixed RCS keywords. 00154 * 00155 */ 00156 00157 00158 #ifndef _PDIRECTORY 00159 #define _PDIRECTORY 00160 00161 #ifdef P_USE_PRAGMA 00162 #pragma interface 00163 #endif 00164 00165 #ifdef Fifo 00166 #undef Fifo 00167 #endif 00168 00169 #ifdef _WIN32 00170 #define PDIR_SEPARATOR '\\' 00171 const PINDEX P_MAX_PATH = _MAX_PATH; 00172 typedef PCaselessString PFilePathString; 00173 #else 00174 #define PDIR_SEPARATOR '/' 00175 #define P_MAX_PATH (_POSIX_PATH_MAX) 00176 typedef PString PFilePathString; 00177 #endif 00178 00180 // File System 00181 00186 class PFileInfo : public PObject 00187 { 00188 PCLASSINFO(PFileInfo, PObject); 00189 00190 public: 00195 enum FileTypes { 00197 RegularFile = 1, 00199 SymbolicLink = 2, 00201 SubDirectory = 4, 00203 CharDevice = 8, 00205 BlockDevice = 16, 00207 Fifo = 32, 00209 SocketDevice = 64, 00211 UnknownFileType = 256, 00213 AllFiles = 0x1ff 00214 }; 00215 00217 FileTypes type; 00218 00222 PTime created; 00223 00225 PTime modified; 00226 00230 PTime accessed; 00231 00235 PUInt64 size; 00236 00238 enum Permissions { 00240 WorldExecute = 1, 00242 WorldWrite = 2, 00244 WorldRead = 4, 00246 GroupExecute = 8, 00248 GroupWrite = 16, 00250 GroupRead = 32, 00252 UserExecute = 64, 00254 UserWrite = 128, 00256 UserRead = 256, 00258 AllPermissions = 0x1ff, 00260 DefaultPerms = UserRead|UserWrite|GroupRead|WorldRead, 00262 DefaultDirPerms = DefaultPerms|UserExecute|GroupExecute|WorldExecute 00263 00264 }; 00265 00271 int permissions; 00272 00277 BOOL hidden; 00278 }; 00279 00280 00305 class PDirectory : public PFilePathString 00306 { 00307 PCONTAINERINFO(PDirectory, PFilePathString); 00308 00309 public: 00312 00313 PDirectory(); 00314 00319 PDirectory( 00320 const char * cpathname 00321 ); 00322 00327 PDirectory( 00328 const PString & pathname 00329 ); 00330 00333 PDirectory & operator=( 00334 const PString & pathname 00335 ); 00336 00339 PDirectory & operator=( 00340 const char * cpathname 00341 ); 00343 00353 PDirectory GetParent() const; 00354 00365 PFilePathString GetVolume() const; 00366 00372 BOOL IsRoot() const; 00373 00379 PDirectory GetRoot() const; 00380 00385 PStringArray GetPath() const; 00386 00393 PINLINE static BOOL IsSeparator( 00394 char ch 00395 ); 00396 00407 BOOL GetVolumeSpace( 00408 PInt64 & total, 00409 PInt64 & free, 00410 DWORD & clusterSize 00411 ) const; 00413 00421 BOOL Exists() const; 00422 00428 static BOOL Exists( 00429 const PString & path 00430 ); 00431 00437 BOOL Change() const; 00438 00444 static BOOL Change( 00445 const PString & path 00446 ); 00447 00453 BOOL Create( 00454 int perm = PFileInfo::DefaultDirPerms // Permission on new directory. 00455 ) const; 00461 static BOOL Create( 00462 const PString & p, 00463 int perm = PFileInfo::DefaultDirPerms 00464 ); 00465 00471 BOOL Remove(); 00472 00478 static BOOL Remove( 00479 const PString & path 00480 ); 00482 00500 BOOL Open( 00501 int scanMask = PFileInfo::AllFiles 00502 ); 00503 00518 BOOL Restart( 00519 int scanMask = PFileInfo::AllFiles 00520 ); 00521 00533 BOOL Next(); 00534 00536 void Close(); 00537 00552 PFilePathString GetEntryName() const; 00553 00563 BOOL IsSubDir() const; 00564 00570 BOOL GetInfo( 00571 PFileInfo & info 00572 ) const; 00574 00575 00576 protected: 00577 // New functions for class 00578 void Construct(); 00579 // Common constructor code 00580 00581 00582 // Member variables 00584 int scanMask; 00585 00586 // Include platform dependent part of class 00587 #ifdef _WIN32 00588 #include "msos/ptlib/pdirect.h" 00589 #else 00590 #include "unix/ptlib/pdirect.h" 00591 #endif 00592 00593 }; 00594 00595 #endif 00596 00597 // End Of File ///////////////////////////////////////////////////////////////

Generated on Sat Jul 24 15:35:56 2004 for PWLib by doxygen 1.3.7