/usr/include/ptlib/pdirect.h is in libpt-1.10.10-dev 1.10.10-3.1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | /*
* pdirect.h
*
* File system directory class.
*
* Portable Windows Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Log: pdirect.h,v $
* Revision 1.43 2005/11/25 03:43:47 csoutheren
* Fixed function argument comments to be compatible with Doxygen
*
* Revision 1.42 2004/09/17 03:51:15 csoutheren
* More fixes for PDirectory problem
*
* Revision 1.42 2004/09/15 05:11:39 csoutheren
* Fixed problem with PDirectory destructor not calling Close()
* Thanks to Paul Long
*
* Revision 1.41 2003/09/17 05:41:58 csoutheren
* Removed recursive includes
*
* Revision 1.40 2003/09/17 01:18:02 csoutheren
* Removed recursive include file system and removed all references
* to deprecated coooperative threading support
*
* Revision 1.39 2003/06/06 15:04:17 dsandras
*
* Fixed compilation warning with gcc 3.3 by removing the PINLINE
*
* Revision 1.38 2002/11/20 00:13:43 robertj
* Fixed some documentation
*
* Revision 1.37 2002/11/19 12:07:02 robertj
* Added function to get root directory.
*
* Revision 1.36 2002/11/19 10:34:59 robertj
* Added function to extract a path as an array of directories components.
*
* Revision 1.35 2002/09/16 01:08:59 robertj
* Added #define so can select if #pragma interface/implementation is used on
* platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
*
* Revision 1.34 2001/05/22 12:49:32 robertj
* Did some seriously wierd rewrite of platform headers to eliminate the
* stupid GNU compiler warning about braces not matching.
*
* Revision 1.33 2001/02/13 06:55:21 robertj
* Fixed problem with operator= in PDirectory class, part of larger change previously made.
*
* Revision 1.32 2000/06/26 11:17:19 robertj
* Nucleus++ port (incomplete).
*
* Revision 1.31 2000/04/03 18:41:27 robertj
* Fixed BeOS compatibility problem with openlog() function.
*
* Revision 1.30 1999/03/09 02:59:50 robertj
* Changed comments to doc++ compatible documentation.
*
* Revision 1.29 1999/02/16 08:11:09 robertj
* MSVC 6.0 compatibility changes.
*
* Revision 1.28 1998/09/23 06:21:06 robertj
* Added open source copyright license.
*
* Revision 1.27 1998/03/05 12:44:34 robertj
* Added cluster size.
*
* Revision 1.26 1997/03/31 11:34:00 robertj
* Fixed default permissions for directories , different from that for files.
*
* Revision 1.25 1997/01/12 04:22:21 robertj
* Added function to get disk size and free space.
*
* Revision 1.24 1995/12/23 03:45:31 robertj
* Added constructor for C string literals.
*
* Revision 1.23 1995/11/09 12:17:23 robertj
* Added platform independent base type access classes.
*
* Revision 1.22 1995/10/14 15:02:22 robertj
* Added function to get parent directory.
*
* Revision 1.21 1995/06/17 11:12:52 robertj
* Documentation update.
*
* Revision 1.20 1995/03/14 12:42:00 robertj
* Updated documentation to use HTML codes.
*
* Revision 1.19 1995/03/12 04:42:48 robertj
* Updated documentation.
* Changed return type of functions to the correct case string.
*
* Revision 1.18 1995/02/22 10:50:33 robertj
* Changes required for compiling release (optimised) version.
*
* Revision 1.17 1995/01/06 10:42:25 robertj
* Moved identifiers into different scope.
* Changed file size to 64 bit integer.
* Documentation
*
* Revision 1.16 1994/10/24 00:07:03 robertj
* Changed PFilePath and PDirectory so descends from either PString or
* PCaselessString depending on the platform.
*
* Revision 1.15 1994/10/23 04:49:25 robertj
* Chnaged PDirectory to descend of PString.
* Added PDirectory Exists() function.
*
* Revision 1.14 1994/08/23 11:32:52 robertj
* Oops
*
* Revision 1.13 1994/08/22 00:46:48 robertj
* Added pragma fro GNU C++ compiler.
*
* Revision 1.12 1994/06/25 11:55:15 robertj
* Unix version synchronisation.
*
* Revision 1.11 1994/04/20 12:17:44 robertj
* Split name into PFilePath
*
* Revision 1.10 1994/04/11 14:16:27 robertj
* Added function for determining if character is a valid directory separator.
*
* Revision 1.9 1994/04/01 14:14:57 robertj
* Put platform independent file permissions and type codes back.
*
* Revision 1.7 1994/01/13 03:17:55 robertj
* Added functions to get the name of the volume the directory is contained in
* and a function to determine if the directory is a root directory of the
* volume (ie is does not have a parent directory).
*
* Revision 1.6 1994/01/03 04:42:23 robertj
* Mass changes to common container classes and interactors etc etc etc.
*
* Revision 1.5 1993/12/31 06:45:38 robertj
* Made inlines optional for debugging purposes.
*
* Revision 1.4 1993/08/21 01:50:33 robertj
* Made Clone() function optional, default will assert if called.
*
* Revision 1.3 1993/07/14 12:49:16 robertj
* Fixed RCS keywords.
*
*/
#ifndef _PDIRECTORY
#define _PDIRECTORY
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#ifdef Fifo
#undef Fifo
#endif
#ifdef _WIN32
#define PDIR_SEPARATOR '\\'
const PINDEX P_MAX_PATH = _MAX_PATH;
typedef PCaselessString PFilePathString;
#else
#define PDIR_SEPARATOR '/'
#define P_MAX_PATH (_POSIX_PATH_MAX)
typedef PString PFilePathString;
#endif
///////////////////////////////////////////////////////////////////////////////
// File System
/**Class containing the system information on a file path. Information can be
obtained on any directory entry event if it is not a "file" in the strictest
sense. Sub-directories, devices etc may also have information retrieved.
*/
class PFileInfo : public PObject
{
PCLASSINFO(PFileInfo, PObject);
public:
/**All types that a particular file path may be. Not all platforms support
all of the file types. For example under DOS no file may be of the
type #SymbolicLink#.
*/
enum FileTypes {
/// Ordinary disk file.
RegularFile = 1,
/// File path is a symbolic link.
SymbolicLink = 2,
/// File path is a sub-directory
SubDirectory = 4,
/// File path is a character device name.
CharDevice = 8,
/// File path is a block device name.
BlockDevice = 16,
/// File path is a fifo (pipe) device.
Fifo = 32,
/// File path is a socket device.
SocketDevice = 64,
/// File path is of an unknown type.
UnknownFileType = 256,
/// Mask for all file types.
AllFiles = 0x1ff
};
/// File type for this file. Only one bit is set at a time here.
FileTypes type;
/**Time of file creation of the file. Not all platforms support a separate
creation time in which case the last modified time is returned.
*/
PTime created;
/// Time of last modifiaction of the file.
PTime modified;
/**Time of last access to the file. Not all platforms support a separate
access time in which case the last modified time is returned.
*/
PTime accessed;
/**Size of the file in bytes. This is a quadword or 8 byte value to allow
for files greater than 4 gigabytes.
*/
PUInt64 size;
/// File access permissions for the file.
enum Permissions {
/// File has world execute permission
WorldExecute = 1,
/// File has world write permission
WorldWrite = 2,
/// File has world read permission
WorldRead = 4,
/// File has group execute permission
GroupExecute = 8,
/// File has group write permission
GroupWrite = 16,
/// File has group read permission
GroupRead = 32,
/// File has owner execute permission
UserExecute = 64,
/// File has owner write permission
UserWrite = 128,
/// File has owner read permission
UserRead = 256,
/// All possible permissions.
AllPermissions = 0x1ff,
/// Owner read & write plus group and world read permissions.
DefaultPerms = UserRead|UserWrite|GroupRead|WorldRead,
/// Owner read & write & execute plus group and world read & exectute permissions.
DefaultDirPerms = DefaultPerms|UserExecute|GroupExecute|WorldExecute
};
/**A bit mask of all the file acces permissions. See the
#Permissions enum# for the possible bit values.
Not all platforms support all permissions.
*/
int permissions;
/**File is a hidden file. What constitutes a hidden file is platform
dependent, for example under unix it is a file beginning with a '.'
character while under MS-DOS there is a file system attribute for it.
*/
BOOL hidden;
};
/**Class to represent a directory in the operating system file system. A
directory is a special file that contains a list of file paths.
The directory paths are highly platform dependent and a minimum number of
assumptions should be made.
The PDirectory object is a string consisting of a possible volume name, and
a series directory names in the path from the volumes root to the directory
that the object represents. Each directory is separated by the platform
dependent separator character which is defined by the PDIR_SEPARATOR macro.
The path always has a trailing separator.
Some platforms allow more than one character to act as a directory separator
so when doing any processing the #IsSeparator()# function should be
used to determine if a character is a possible separator.
The directory may be opened to gain access to the list of files that it
contains. Note that the directory does {\bf not} contain the "." and ".."
entries that some platforms support.
The ancestor class is dependent on the platform. For file systems that are
case sensitive, eg Unix, the ancestor is #PString#. For other
platforms, the ancestor class is #PCaselessString#.
*/
class PDirectory : public PFilePathString
{
PCONTAINERINFO(PDirectory, PFilePathString);
public:
/**@name Construction */
//@{
/// Create a directory object of the current working directory
PDirectory();
/**Create a directory object of the specified directory. The
#pathname# parameter may be a relative directory which is
made absolute by the creation of the #PDirectory# object.
*/
PDirectory(
const char * cpathname ///< Directory path name for new object.
);
/**Create a directory object of the specified directory. The
#pathname# parameter may be a relative directory which is
made absolute by the creation of the #PDirectory# object.
*/
PDirectory(
const PString & pathname ///< Directory path name for new object.
);
/**Set the directory to the specified path.
*/
PDirectory & operator=(
const PString & pathname ///< Directory path name for new object.
);
/**Set the directory to the specified path.
*/
PDirectory & operator=(
const char * cpathname ///< Directory path name for new object.
);
//@}
/**@name Access functions */
//@{
/**Get the directory for the parent to the current directory. If the
directory is already the root directory it returns the root directory
again.
@return
parent directory.
*/
PDirectory GetParent() const;
/**Get the volume name that the directory is in.
This is platform dependent, for example for MS-DOS it is the 11
character volume name for the drive, eg "DOS_DISK", and for Macintosh it
is the disks volume name eg "Untitled". For a unix platform it is the
device name for the file system eg "/dev/sda1".
@return
string for the directory volume.
*/
PFilePathString GetVolume() const;
/**Determine if the directory is the root directory of a volume.
@return
TRUE if the object is a root directory.
*/
BOOL IsRoot() const;
/**Get the root directory of a volume.
@return
root directory.
*/
PDirectory GetRoot() const;
/**Get the directory path as an array of strings.
The first element in the array is the volume string, eg under Win32 it
is "c:" or "\\machine", while under unix it is an empty string.
*/
PStringArray GetPath() const;
/**Determine if the character #ch# is a directory path
separator.
@return
TRUE if may be used to separate directories in a path.
*/
PINLINE static BOOL IsSeparator(
char ch ///< Character to check as being a separator.
);
/**Determine the total number of bytes and number of bytes free on the
volume that this directory is contained on.
Note that the free space will be the physical limit and if user quotas
are in force by the operating system, the use may not actually be able
to use all of these bytes.
@return
TRUE if the information could be determined.
*/
BOOL GetVolumeSpace(
PInt64 & total, ///< Total number of bytes available on volume
PInt64 & free, ///< Number of bytes unused on the volume
DWORD & clusterSize ///< "Quantisation factor" in bytes for files on volume
) const;
//@}
/**@name File system functions */
//@{
/**Test for if the directory exists.
@return
TRUE if directory exists.
*/
BOOL Exists() const;
/**Test for if the specified directory exists.
@return
TRUE if directory exists.
*/
static BOOL Exists(
const PString & path ///< Directory file path.
);
/**Change the current working directory to the objects location.
@return
TRUE if current working directory was changed.
*/
BOOL Change() const;
/**Change the current working directory to that specified..
@return
TRUE if current working directory was changed.
*/
static BOOL Change(
const PString & path ///< Directory file path.
);
/**Create a new directory with the specified permissions.
@return
TRUE if directory created.
*/
BOOL Create(
int perm = PFileInfo::DefaultDirPerms // Permission on new directory.
) const;
/**Create a new directory as specified with the specified permissions.
@return
TRUE if directory created.
*/
static BOOL Create(
const PString & p, ///< Directory file path.
int perm = PFileInfo::DefaultDirPerms ///< Permission on new directory.
);
/**Delete the directory.
@return
TRUE if directory was deleted.
*/
BOOL Remove();
/**Delete the specified directory.
@return
TRUE if directory was deleted.
*/
static BOOL Remove(
const PString & path ///< Directory file path.
);
//@}
/**@name Directory listing functions */
//@{
/**Open the directory for scanning its list of files. Once opened the
#GetEntryName()# function may be used to get the current directory
entry and the #Next()# function used to move to the next directory
entry.
Only files that are of a type that is specified in the mask will be
returned.
Note that the directory scan will {\bf not} return the "." and ".."
entries that some platforms support.
@return
TRUE if directory was successfully opened, and there was at least one
file in it of the specified types.
*/
virtual BOOL Open(
int scanMask = PFileInfo::AllFiles ///< Mask of files to provide.
);
/**Restart file list scan from the beginning of directory. This is similar
to the #Open()# command but does not require that the directory be
closed (using #Close()#) first.
Only files that are of a type that is specified in the mask will be
returned.
Note that the directory scan will {\bf not} return the "." and ".."
entries that some platforms support.
@return
TRUE if directory was successfully opened, and there was at least one
file in it of the specified types.
*/
virtual BOOL Restart(
int scanMask = PFileInfo::AllFiles ///< Mask of files to provide.
);
/**Move to the next file in the directory scan.
Only files that are of a type that is specified in the mask passed to
the #Open()# or #Restart()# functions will be returned.
Note that the directory scan will {\bf not} return the "." and ".."
entries that some platforms support.
@return
TRUE if there is another valid file in the directory.
*/
BOOL Next();
/// Close the directory during or after a file list scan.
virtual void Close();
/**Get the name (without the volume or directory path) of the current
entry in the directory scan. This may be the name of a file or a
subdirectory or even a link or device for operating systems that support
them.
To get a full path name concatenate the PDirectory object itself with
the entry name.
Note that the directory scan will {\bf not} return the "." and ".."
entries that some platforms support.
@return
string for directory entry.
*/
virtual PFilePathString GetEntryName() const;
/**Determine if the directory entry currently being scanned is itself
another directory entry.
Note that the directory scan will {\bf not} return the "." and ".."
entries that some platforms support.
@return
TRUE if entry is a subdirectory.
*/
virtual BOOL IsSubDir() const;
/**Get file information on the current directory entry.
@return
TRUE if file information was successfully retrieved.
*/
virtual BOOL GetInfo(
PFileInfo & info ///< Object to receive the file information.
) const;
//@}
protected:
// New functions for class
void Construct();
void Destruct()
{ Close(); PFilePathString::Destruct(); }
// Member variables
/// Mask of file types that the directory scan will return.
int scanMask;
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/pdirect.h"
#else
#include "unix/ptlib/pdirect.h"
#endif
};
#endif
// End Of File ///////////////////////////////////////////////////////////////
|