PTLib
Version 2.10.10
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
file.h
Go to the documentation of this file.
1
/*
2
* file.h
3
*
4
* Operating System file I/O channel class.
5
*
6
* Portable Windows Library
7
*
8
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9
*
10
* The contents of this file are subject to the Mozilla Public License
11
* Version 1.0 (the "License"); you may not use this file except in
12
* compliance with the License. You may obtain a copy of the License at
13
* http://www.mozilla.org/MPL/
14
*
15
* Software distributed under the License is distributed on an "AS IS"
16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17
* the License for the specific language governing rights and limitations
18
* under the License.
19
*
20
* The Original Code is Portable Windows Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25
* All Rights Reserved.
26
*
27
* Contributor(s): ______________________________________.
28
*
29
* $Revision: 24177 $
30
* $Author: rjongbloed $
31
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
32
*/
33
34
35
#ifndef PTLIB_FILE_H
36
#define PTLIB_FILE_H
37
38
#ifdef P_USE_PRAGMA
39
#pragma interface
40
#endif
41
42
#ifndef _WIN32
43
#include <sys/stat.h>
44
#endif
45
46
47
49
// Binary Files
50
60
class
PFile
:
public
PChannel
61
{
62
PCLASSINFO(
PFile
,
PChannel
);
63
64
public
:
71
PFile
();
72
77
enum
OpenMode
{
78
ReadOnly
,
79
WriteOnly
,
80
ReadWrite
81
};
82
93
enum
OpenOptions
{
95
ModeDefault
= -1,
97
MustExist
= 0,
99
Create
= 1,
101
Truncate
= 2,
103
Exclusive
= 4,
105
Temporary
= 8,
107
DenySharedRead
= 16,
109
DenySharedWrite
= 32
110
};
111
120
PFile
(
121
OpenMode
mode,
122
int
opts =
ModeDefault
123
);
124
131
PFile
(
132
const
PFilePath
& name,
133
OpenMode
mode =
ReadWrite
,
134
int
opts =
ModeDefault
135
);
136
138
~PFile
();
140
141
150
Comparison
Compare
(
151
const
PObject
& obj
152
)
const
;
154
155
164
virtual
PString
GetName
()
const
;
165
177
virtual
PBoolean
Read
(
178
void
* buf,
179
PINDEX len
180
);
181
191
virtual
PBoolean
Write
(
192
const
void
* buf,
193
PINDEX len
194
);
195
199
virtual
PBoolean
Close
();
201
202
212
static
PBoolean
Exists
(
213
const
PFilePath
& name
214
);
215
223
PBoolean
Exists
()
const
;
224
234
static
PBoolean
Access
(
235
const
PFilePath
& name,
236
OpenMode
mode
237
);
238
249
PBoolean
Access
(
250
OpenMode
mode
251
);
252
265
static
PBoolean
Remove
(
266
const
PFilePath
& name,
// Name of file to delete.
267
PBoolean
force =
false
// Force deletion even if file is protected.
268
);
269
static
PBoolean
Remove
(
270
const
PString
& name,
// Name of file to delete.
271
PBoolean
force =
false
// Force deletion even if file is protected.
272
);
273
286
PBoolean
Remove
(
287
PBoolean
force =
false
// Force deletion even if file is protected.
288
);
289
305
static
PBoolean
Rename
(
306
const
PFilePath
& oldname,
307
const
PString
& newname,
308
PBoolean
force =
false
310
);
311
328
PBoolean
Rename
(
329
const
PString
& newname,
330
PBoolean
force =
false
332
);
333
339
static
PBoolean
Copy
(
340
const
PFilePath
& oldname,
341
const
PFilePath
& newname,
342
PBoolean
force =
false
344
);
345
351
PBoolean
Copy
(
352
const
PFilePath
& newname,
353
PBoolean
force =
false
355
);
356
366
static
PBoolean
Move
(
367
const
PFilePath
& oldname,
368
const
PFilePath
& newname,
369
PBoolean
force =
false
371
);
372
382
PBoolean
Move
(
383
const
PFilePath
& newname,
384
PBoolean
force =
false
386
);
388
397
const
PFilePath
&
GetFilePath
()
const
;
398
402
void
SetFilePath
(
403
const
PString
&
path
404
);
405
406
418
virtual
PBoolean
Open
(
419
OpenMode
mode =
ReadWrite
,
// Mode in which to open the file.
420
int
opts =
ModeDefault
// Options for open operation.
421
);
422
433
virtual
PBoolean
Open
(
434
const
PFilePath
& name,
// Name of file to open.
435
OpenMode
mode =
ReadWrite
,
// Mode in which to open the file.
436
int
opts =
ModeDefault
// <code>OpenOptions</code> enum# for open operation.
437
);
438
444
virtual
off_t
GetLength
()
const
;
445
452
virtual
PBoolean
SetLength
(
453
off_t len
// New length of file.
454
);
455
457
enum
FilePositionOrigin
{
459
Start
= SEEK_SET,
461
Current
= SEEK_CUR,
463
End
= SEEK_END
464
};
465
476
virtual
PBoolean
SetPosition
(
477
off_t pos,
478
FilePositionOrigin
origin =
Start
479
);
480
487
virtual
off_t
GetPosition
()
const
;
488
495
PBoolean
IsEndOfFile
()
const
;
496
502
static
PBoolean
GetInfo
(
503
const
PFilePath
& name,
// Name of file to get the information on.
504
PFileInfo
& info
505
// <code>PFileInfo</code> structure to receive the information.
506
);
507
513
PBoolean
GetInfo
(
514
PFileInfo
& info
515
// <code>PFileInfo</code> structure to receive the information.
516
);
517
523
static
PBoolean
SetPermissions
(
524
const
PFilePath
& name,
// Name of file to change the permission of.
525
int
permissions
// New permissions mask for the file.
526
);
532
PBoolean
SetPermissions
(
533
int
permissions
// New permissions mask for the file.
534
);
536
537
protected
:
538
// Member variables
539
540
PFilePath
path
;
541
PBoolean
removeOnClose
;
542
543
544
// Include platform dependent part of class
545
#ifdef _WIN32
546
#include "msos/ptlib/file.h"
547
#else
548
#include "unix/ptlib/file.h"
549
#endif
550
};
551
552
553
#endif // PTLIB_FILE_H
554
555
556
// End Of File ///////////////////////////////////////////////////////////////
include
ptlib
file.h
Generated on Mon Mar 4 2013 13:14:08 for PTLib by
1.8.3.1