PTLib
Version 2.12.9
Main Page
Related Pages
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: 27039 $
30
* $Author: rjongbloed $
31
* $Date: 2012-02-22 18:19:46 +1100 (Wed, 22 Feb 2012) $
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
#include <
ptlib/bitwise_enum.h
>
47
48
50
// Binary Files
51
61
class
PFile
:
public
PChannel
62
{
63
PCLASSINFO(
PFile
,
PChannel
);
64
65
public
:
72
PFile
();
73
78
enum
OpenMode
{
79
ReadOnly
,
80
WriteOnly
,
81
ReadWrite
82
};
83
94
P_DECLARE_BITWISE_ENUM_EX
(OpenOptions, 6,
95
(MustExist,
96
Create,
97
Truncate,
98
Exclusive,
99
Temporary,
100
DenySharedRead,
101
DenySharedWrite
102
),
103
ModeDefault = -1
104
);
105
114
PFile
(
115
OpenMode
mode,
116
OpenOptions opts = ModeDefault
117
);
118
125
PFile
(
126
const
PFilePath
& name,
127
OpenMode
mode =
ReadWrite
,
128
OpenOptions opts = ModeDefault
129
);
130
132
~PFile
();
134
135
144
Comparison
Compare
(
145
const
PObject
& obj
146
)
const
;
148
149
158
virtual
PString
GetName
()
const
;
159
171
virtual
PBoolean
Read
(
172
void
* buf,
173
PINDEX len
174
);
175
185
virtual
PBoolean
Write
(
186
const
void
* buf,
187
PINDEX len
188
);
189
193
virtual
PBoolean
Close
();
195
196
206
static
PBoolean
Exists
(
207
const
PFilePath
& name
208
);
209
217
PBoolean
Exists
()
const
;
218
228
static
PBoolean
Access
(
229
const
PFilePath
& name,
230
OpenMode
mode
231
);
232
243
PBoolean
Access
(
244
OpenMode
mode
245
);
246
259
static
PBoolean
Remove
(
260
const
PFilePath
& name,
// Name of file to delete.
261
PBoolean
force =
false
// Force deletion even if file is protected.
262
);
263
static
PBoolean
Remove
(
264
const
PString
& name,
// Name of file to delete.
265
PBoolean
force =
false
// Force deletion even if file is protected.
266
);
267
280
PBoolean
Remove
(
281
PBoolean
force =
false
// Force deletion even if file is protected.
282
);
283
299
static
PBoolean
Rename
(
300
const
PFilePath
& oldname,
301
const
PString
& newname,
302
PBoolean
force =
false
304
);
305
322
PBoolean
Rename
(
323
const
PString
& newname,
324
PBoolean
force =
false
326
);
327
333
static
PBoolean
Copy
(
334
const
PFilePath
& oldname,
335
const
PFilePath
& newname,
336
PBoolean
force =
false
338
);
339
345
PBoolean
Copy
(
346
const
PFilePath
& newname,
347
PBoolean
force =
false
349
);
350
360
static
PBoolean
Move
(
361
const
PFilePath
& oldname,
362
const
PFilePath
& newname,
363
PBoolean
force =
false
365
);
366
376
PBoolean
Move
(
377
const
PFilePath
& newname,
378
PBoolean
force =
false
380
);
382
391
const
PFilePath
&
GetFilePath
()
const
;
392
396
void
SetFilePath
(
397
const
PString
&
path
398
);
399
400
412
virtual
PBoolean
Open
(
413
OpenMode
mode =
ReadWrite
,
// Mode in which to open the file.
414
OpenOptions opts = ModeDefault
// Options for open operation.
415
);
416
427
virtual
PBoolean
Open
(
428
const
PFilePath
& name,
// Name of file to open.
429
OpenMode
mode =
ReadWrite
,
// Mode in which to open the file.
430
OpenOptions opts = ModeDefault
// <code>OpenOptions</code> enum# for open operation.
431
);
432
438
virtual
off_t
GetLength
()
const
;
439
446
virtual
PBoolean
SetLength
(
447
off_t len
// New length of file.
448
);
449
451
enum
FilePositionOrigin
{
453
Start
= SEEK_SET,
455
Current
= SEEK_CUR,
457
End
= SEEK_END
458
};
459
470
virtual
PBoolean
SetPosition
(
471
off_t pos,
472
FilePositionOrigin
origin =
Start
473
);
474
481
virtual
off_t
GetPosition
()
const
;
482
489
PBoolean
IsEndOfFile
()
const
;
490
496
static
PBoolean
GetInfo
(
497
const
PFilePath
& name,
// Name of file to get the information on.
498
PFileInfo
& info
499
// <code>PFileInfo</code> structure to receive the information.
500
);
501
507
PBoolean
GetInfo
(
508
PFileInfo
& info
509
// <code>PFileInfo</code> structure to receive the information.
510
);
511
517
static
PBoolean
SetPermissions
(
518
const
PFilePath
& name,
// Name of file to change the permission of.
519
int
permissions
// New permissions mask for the file.
520
);
526
PBoolean
SetPermissions
(
527
int
permissions
// New permissions mask for the file.
528
);
530
531
protected
:
532
// Member variables
533
534
PFilePath
path
;
535
PBoolean
removeOnClose
;
536
537
538
// Include platform dependent part of class
539
#ifdef _WIN32
540
#include "msos/ptlib/file.h"
541
#else
542
#include "unix/ptlib/file.h"
543
#endif
544
};
545
546
547
#endif // PTLIB_FILE_H
548
549
550
// End Of File ///////////////////////////////////////////////////////////////
include
ptlib
file.h
Generated on Mon Feb 17 2014 13:12:51 for PTLib by
1.8.3.1