File.h
Go to the documentation of this file.
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a zlib-style license that can
* be found in the License.txt file in the root of the source tree.
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// File functions
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------------
#ifndef ZenLib_FileH
#define ZenLib_FileH
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "ZenLib/Ztring.h"
//---------------------------------------------------------------------------
namespace ZenLib
{
//***************************************************************************
/// @brief File manipulation
//***************************************************************************
class File
{
public :
//---------------------------------------------------------------------------
/// @brief Options for Open method
enum access_t
{
Access_Read = 0, ///< Read permission
Access_Write = 1, ///< Write permission
Access_Read_Write = 2, ///< Read and Write permissions
Access_Write_Append = 3, ///< Write permission without deleting old file
Access_Write_Excluding = 4 ///< Write permission preventing reading
};
//---------------------------------------------------------------------------
/// @brief Options for Move method
enum move_t
{
FromBegin = 0, ///< Begin of file
FromCurrent = 1, ///< Current position
FromEnd = 2 ///< End of file
};
//Constructor/Destructor
File ();
File (ZenLib::Ztring File_Name, access_t Access=Access_Read);
~File ();
//Open/close
bool Open (const tstring &File_Name, access_t Access=Access_Read);
bool Create(const ZenLib::Ztring &File_Name, bool OverWrite=true);
void Close ();
//Read/Write
size_t Read (int8u* Buffer, size_t Buffer_Size);
size_t Write (const int8u* Buffer, size_t Buffer_Size);
size_t Write (const Ztring &ToWrite);
bool Truncate (int64u Offset=(int64u)-1);
//Moving
bool GoTo (int64s Position, move_t MoveMethod=FromBegin);
int64u Position_Get ();
//Attributes
int64u Size_Get();
Ztring Created_Get();
Ztring Created_Local_Get();
Ztring Modified_Get();
Ztring Modified_Local_Get();
bool Opened_Get();
//Helpers
static int64u Size_Get(const Ztring &File_Name);
static Ztring Created_Get(const Ztring &File_Name);
static Ztring Modified_Get(const Ztring &File_Name);
static bool Exists(const Ztring &File_Name);
static bool Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite=false);
static bool Move(const Ztring &Source, const Ztring &Destination, bool OverWrite=false);
static bool Delete(const Ztring &File_Name);
//Temp
Ztring File_Name;
int64u Position; //Position is saved, may be not good because position may change
int64u Size; //Size is saved, may be not good because size may change
void* File_Handle;
};
} //NameSpace
#endif
Ztring.h
ZenLib::File::Size
int64u Size
Definition File.h:93
ZenLib::File::move_t
move_t
Options for Move method.
Definition File.h:47
ZenLib::File::FromCurrent
@ FromCurrent
Current position.
Definition File.h:49
ZenLib::File::FromEnd
@ FromEnd
End of file.
Definition File.h:50
ZenLib::File::FromBegin
@ FromBegin
Begin of file.
Definition File.h:48
ZenLib::File::Size_Get
static int64u Size_Get(const Ztring &File_Name)
ZenLib::File::Created_Get
static Ztring Created_Get(const Ztring &File_Name)
ZenLib::File::Read
size_t Read(int8u *Buffer, size_t Buffer_Size)
ZenLib::File::Move
static bool Move(const Ztring &Source, const Ztring &Destination, bool OverWrite=false)
ZenLib::File::Create
bool Create(const ZenLib::Ztring &File_Name, bool OverWrite=true)
ZenLib::File::Truncate
bool Truncate(int64u Offset=(int64u) -1)
ZenLib::File::Write
size_t Write(const int8u *Buffer, size_t Buffer_Size)
ZenLib::File::GoTo
bool GoTo(int64s Position, move_t MoveMethod=FromBegin)
ZenLib::File::Copy
static bool Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite=false)
ZenLib::File::Close
void Close()
ZenLib::File::Modified_Get
static Ztring Modified_Get(const Ztring &File_Name)
ZenLib::File::~File
~File()
ZenLib::File::access_t
access_t
Options for Open method.
Definition File.h:36
ZenLib::File::Access_Read_Write
@ Access_Read_Write
Read and Write permissions.
Definition File.h:39
ZenLib::File::Access_Read
@ Access_Read
Read permission.
Definition File.h:37
ZenLib::File::Access_Write
@ Access_Write
Write permission.
Definition File.h:38
ZenLib::File::Access_Write_Append
@ Access_Write_Append
Write permission without deleting old file.
Definition File.h:40
ZenLib::File::Access_Write_Excluding
@ Access_Write_Excluding
Write permission preventing reading.
Definition File.h:41
ZenLib::File::Modified_Local_Get
Ztring Modified_Local_Get()
ZenLib::File::Created_Local_Get
Ztring Created_Local_Get()
ZenLib::File::Position
int64u Position
Definition File.h:92
ZenLib::File::Open
bool Open(const tstring &File_Name, access_t Access=Access_Read)
ZenLib::File::File
File(ZenLib::Ztring File_Name, access_t Access=Access_Read)
ZenLib::File::Write
size_t Write(const Ztring &ToWrite)
ZenLib::File::Delete
static bool Delete(const Ztring &File_Name)
ZenLib::File::Modified_Get
Ztring Modified_Get()
ZenLib::File::Exists
static bool Exists(const Ztring &File_Name)
ZenLib::File::File_Name
Ztring File_Name
Definition File.h:91
ZenLib::File::Position_Get
int64u Position_Get()
ZenLib::File::File
File()
ZenLib::File::Opened_Get
bool Opened_Get()
ZenLib::File::Created_Get
Ztring Created_Get()
ZenLib::File::Size_Get
int64u Size_Get()
ZenLib::File::File_Handle
void * File_Handle
Definition File.h:94
ZenLib::Ztring
String manipulation (based on std::(w)string).
Definition Ztring.h:50
ZenLib
Definition BitStream.h:24
ZenLib::tstring
std::basic_string< Char, std::char_traits< Char >, std::allocator< Char > > tstring
Definition Ztring.h:28