ZenLib
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
ZenLib
File.h
Go to the documentation of this file.
1
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2
*
3
* Use of this source code is governed by a zlib-style license that can
4
* be found in the License.txt file in the root of the source tree.
5
*/
6
7
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
//
9
// File functions
10
//
11
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13
//---------------------------------------------------------------------------
14
#ifndef ZenLib_FileH
15
#define ZenLib_FileH
16
//---------------------------------------------------------------------------
17
18
//---------------------------------------------------------------------------
19
#include "
ZenLib/Ztring.h
"
20
//---------------------------------------------------------------------------
21
22
namespace
ZenLib
23
{
24
25
//***************************************************************************
26
/// @brief File manipulation
27
//***************************************************************************
28
29
class
File
30
{
31
public
:
32
//---------------------------------------------------------------------------
33
/// @brief Options for Open method
34
enum
access_t
35
{
36
Access_Read
= 0,
///< Read permission
37
Access_Write
= 1,
///< Write permission
38
Access_Read_Write
= 2,
///< Read and Write permissions
39
Access_Write_Append
= 3,
///< Write permission without deleting old file
40
Access_Write_Excluding
= 4
///< Write permission preventing reading
41
};
42
43
//---------------------------------------------------------------------------
44
/// @brief Options for Move method
45
enum
move_t
46
{
47
FromBegin
= 0,
///< Begin of file
48
FromCurrent
= 1,
///< Current position
49
FromEnd
= 2
///< End of file
50
};
51
52
//Constructor/Destructor
53
File
();
54
File
(
ZenLib::Ztring
File_Name
,
access_t
Access=
Access_Read
);
55
~File
();
56
57
//Open/close
58
bool
Open
(
const
tstring
&
File_Name
,
access_t
Access=
Access_Read
);
59
bool
Create
(
const
ZenLib::Ztring
&
File_Name
,
bool
OverWrite=
true
);
60
void
Close
();
61
62
//Read/Write
63
size_t
Read
(int8u* Buffer,
size_t
Buffer_Size);
64
size_t
Write
(
const
int8u* Buffer,
size_t
Buffer_Size);
65
size_t
Write
(
const
Ztring
&ToWrite);
66
bool
Truncate
(int64u Offset=(int64u)-1);
67
68
//Moving
69
bool
GoTo
(int64s
Position
,
move_t
MoveMethod=
FromBegin
);
70
int64u
Position_Get
();
71
72
//Attributes
73
int64u
Size_Get
();
74
Ztring
Created_Get
();
75
Ztring
Created_Local_Get
();
76
Ztring
Modified_Get
();
77
Ztring
Modified_Local_Get
();
78
bool
Opened_Get
();
79
80
//Helpers
81
static
int64u
Size_Get
(
const
Ztring
&
File_Name
);
82
static
Ztring
Created_Get
(
const
Ztring
&
File_Name
);
83
static
Ztring
Modified_Get
(
const
Ztring
&
File_Name
);
84
static
bool
Exists
(
const
Ztring
&
File_Name
);
85
static
bool
Copy
(
const
Ztring
&Source,
const
Ztring
&Destination,
bool
OverWrite=
false
);
86
static
bool
Move
(
const
Ztring
&Source,
const
Ztring
&Destination,
bool
OverWrite=
false
);
87
static
bool
Delete
(
const
Ztring
&
File_Name
);
88
89
//Temp
90
Ztring
File_Name
;
91
int64u
Position
;
//Position is saved, may be not good because position may change
92
int64u
Size
;
//Size is saved, may be not good because size may change
93
void
*
File_Handle
;
94
};
95
96
}
//NameSpace
97
98
#endif
Generated on Sun Apr 24 2016 16:46:23 for ZenLib by
1.8.1.2