ZenLib

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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
ZenLib::File::Position
int64u Position
Definition: File.h:91
ZenLib::File::Access_Read_Write
Read and Write permissions.
Definition: File.h:38
ZenLib::File::Size_Get
int64u Size_Get()
ZenLib::File::Create
bool Create(const ZenLib::Ztring &File_Name, bool OverWrite=true)
ZenLib::File::Access_Write
Write permission.
Definition: File.h:37
ZenLib::File::Position_Get
int64u Position_Get()
ZenLib::File::Modified_Local_Get
Ztring Modified_Local_Get()
ZenLib::File::Delete
static bool Delete(const Ztring &File_Name)
ZenLib::File::move_t
move_t
Options for Move method.
Definition: File.h:45
ZenLib::File::Access_Write_Excluding
Write permission preventing reading.
Definition: File.h:40
ZenLib::File
File manipulation.
Definition: File.h:29
ZenLib::File::File_Name
Ztring File_Name
Definition: File.h:90
ZenLib::File::Open
bool Open(const tstring &File_Name, access_t Access=Access_Read)
ZenLib::File::File
File()
ZenLib
Definition: BitStream.h:23
ZenLib::File::FromEnd
End of file.
Definition: File.h:49
ZenLib::File::Size
int64u Size
Definition: File.h:92
ZenLib::File::FromBegin
Begin of file.
Definition: File.h:47
ZenLib::File::Read
size_t Read(int8u *Buffer, size_t Buffer_Size)
ZenLib::File::Exists
static bool Exists(const Ztring &File_Name)
ZenLib::tstring
std::basic_string< Char, std::char_traits< Char >, std::allocator< Char > > tstring
Definition: Ztring.h:28
ZenLib::File::Write
size_t Write(const int8u *Buffer, size_t Buffer_Size)
ZenLib::File::Access_Read
Read permission.
Definition: File.h:36
ZenLib::File::~File
~File()
ZenLib::File::GoTo
bool GoTo(int64s Position, move_t MoveMethod=FromBegin)
ZenLib::File::Modified_Get
Ztring Modified_Get()
ZenLib::Ztring
String manipulation (based on std::(w)string)
Definition: Ztring.h:49
ZenLib::File::Created_Local_Get
Ztring Created_Local_Get()
ZenLib::File::File_Handle
void * File_Handle
Definition: File.h:93
ZenLib::File::FromCurrent
Current position.
Definition: File.h:48
ZenLib::File::Opened_Get
bool Opened_Get()
ZenLib::File::Close
void Close()
ZenLib::File::Access_Write_Append
Write permission without deleting old file.
Definition: File.h:39
ZenLib::File::Move
static bool Move(const Ztring &Source, const Ztring &Destination, bool OverWrite=false)
ZenLib::File::Copy
static bool Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite=false)
ZenLib::File::Created_Get
Ztring Created_Get()
ZenLib::File::access_t
access_t
Options for Open method.
Definition: File.h:34
ZenLib::File::Truncate
bool Truncate(int64u Offset=(int64u)-1)
Ztring.h