~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to NuxCore/FileManager/NFileManagerGNU.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-01 19:25:37 UTC
  • Revision ID: neil.patel@canonical.com-20100901192537-mfz7rm6q262pewg6
Import and build NuxCore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef NFILEMANAGERGNU_H
 
2
#define NFILEMANAGERGNU_H
 
3
 
 
4
#include <time.h>
 
5
 
 
6
/*-----------------------------------------------------------------------------
 
7
File Manager.
 
8
-----------------------------------------------------------------------------*/
 
9
NAMESPACE_BEGIN
 
10
// File manager.
 
11
class NGNUSerialFileReader : public NSerializer
 
12
{
 
13
public:
 
14
    NGNUSerialFileReader(t_int InFileDescriptor, NOutputDevice& InError, t_int InSize);
 
15
    ~NGNUSerialFileReader();
 
16
 
 
17
    virtual bool Precache(t_int PrecacheOffset, t_int PrecacheSize);
 
18
    virtual t_s64 Seek(t_s64 InPos, NSerializer::SeekPos seekpos);
 
19
    virtual t_s64 Tell();
 
20
    virtual t_s64 GetFileSize();
 
21
    virtual bool Close();
 
22
    virtual void SerializeFinal(void* V, t_u64 Length);
 
23
    virtual bool isReader() {return true;}
 
24
    virtual bool isWriter() {return false;}
 
25
 
 
26
protected:
 
27
    t_int               m_FileDescriptor;
 
28
    NOutputDevice& m_Error;
 
29
    t_s64               m_FileSize;
 
30
    t_s64               m_FilePos;
 
31
    t_s64               m_BufferBase;
 
32
    t_int               m_BufferCount;
 
33
    BYTE*               m_Buffer;
 
34
    static const t_int  sBufferSize;
 
35
};
 
36
 
 
37
class NGNUSerialFileWriter : public NSerializer
 
38
{
 
39
public:
 
40
    NGNUSerialFileWriter(t_int InFileDescriptor, NOutputDevice& InError, t_int InPos);
 
41
    ~NGNUSerialFileWriter();
 
42
 
 
43
    virtual t_s64 Seek(t_s64 InPos, NSerializer::SeekPos seekpos);
 
44
    virtual t_s64 Tell();
 
45
    virtual bool Close();
 
46
    virtual void SerializeFinal(void* V, t_u64 Length);
 
47
    virtual void Flush();
 
48
    virtual t_s64 GetFileSize();
 
49
    virtual bool isReader() {return false;}
 
50
    virtual bool isWriter() {return true;}
 
51
 
 
52
protected:
 
53
    void _Flush();
 
54
    t_int               m_FileDescriptor;
 
55
    NOutputDevice& m_Error;
 
56
    t_s64               m_Pos;
 
57
    t_int               m_BufferCount;
 
58
    BYTE*               m_Buffer;
 
59
    static const t_int  sBufferSize;
 
60
    NCriticalSection m_CriticalSection;
 
61
};
 
62
 
 
63
class NFileManagerGNU : public NFileManagerGeneric
 
64
{
 
65
    INL_DECLARE_GLOBAL_OBJECT(NFileManagerGNU, NGlobalSingletonInitializer);
 
66
public:
 
67
    // Flags is a combination of
 
68
    //  NSerializer::OutputErrorIfFail
 
69
    //  NSerializer::NoOverWrite
 
70
    //  NSerializer::OverWriteReadOnly
 
71
    //  NSerializer::Unbuffered
 
72
    //  NSerializer::Append
 
73
    //  NSerializer::Read
 
74
    virtual NSerializer* CreateFileReader(const TCHAR* Filename, DWORD Flags, NOutputDevice& Error = GNullDevice);
 
75
    virtual NSerializer* CreateFileWriter(const TCHAR* Filename, DWORD Flags, NOutputDevice& Error = GNullDevice);
 
76
    /*!
 
77
    @return Size of the File. Return -1 if an error occurs.
 
78
    */
 
79
    t_s64 FileSize(const TCHAR* Filename);
 
80
    bool FileExist(const TCHAR* Filename);
 
81
    int Copy(const TCHAR* DestFile, const TCHAR* SrcFile, bool OverWriteExisting, bool OverWriteReadOnly, NFileTransferMonitor* Monitor);
 
82
    bool Move(const TCHAR* Dest, const TCHAR* Src, bool OverWriteExisting = true, bool OverWriteReadOnly = false, NFileTransferMonitor* Monitor = NULL);
 
83
    bool Delete(const TCHAR* Filename, bool OverWriteReadOnly = false);
 
84
    bool IsReadOnly(const TCHAR* Filename);
 
85
    bool IsDirectory(const TCHAR* DirectoryName);
 
86
    bool IsHidden(const TCHAR* Filename);
 
87
    /*!
 
88
    @return TRUE is the file exist.
 
89
    */
 
90
    bool GetFileAttribute(const TCHAR* Filename, bool& isDirectory, bool& isReadOnly, bool& isHidden, t_s64& Size);
 
91
    bool MakeDirectory(const TCHAR* Path, bool CreateCompletePath = false);
 
92
    bool DeleteDirectory(const TCHAR* Path, bool DeleteContentFirst = false);
 
93
 
 
94
 
 
95
    void FindFiles(std::vector<NString>& Result, const TCHAR* Filename, bool Files, bool Directories) {};
 
96
    void ListFilesInDirectory(std::vector<NString>& Result, const TCHAR* DirName) {};
 
97
    double GetFileAgeSeconds(const TCHAR* Filename) {return 0;};
 
98
    time_t GetFileLastModified(const TCHAR* Filename) {return 0;};
 
99
    bool SetDefaultDirectory() {return false;};
 
100
    NString GetCurrentDirectory() {return NString();};
 
101
    bool GetTimeStamp(const TCHAR* Filename, FileTimeStamp& Timestamp) {return false;};
 
102
};
 
103
 
 
104
 
 
105
NAMESPACE_END
 
106
 
 
107
#endif // NFILEMANAGERGNU_H