Merge pull request #4011 from fritsch/vdpau-settings
[vuplus_xbmc] / lib / UnrarXLib / file.hpp
1 #ifndef _RAR_FILE_
2 #define _RAR_FILE_
3
4 #ifdef _WIN_32
5 typedef HANDLE FileHandle;
6 #define BAD_HANDLE INVALID_HANDLE_VALUE
7 #else
8 typedef FILE* FileHandle;
9 #define BAD_HANDLE NULL
10 #endif
11
12 class RAROptions;
13
14 enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD,FILE_HANDLEERR};
15
16 enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR};
17
18 struct FileStat
19 {
20   uint FileAttr;
21   uint FileTime;
22   Int64 FileSize;
23   bool IsDir;
24 };
25
26 namespace XFILE {
27   class CFile;
28 };
29
30 class File
31 {
32   private:
33     //void AddFileToList(FileHandle hFile);
34     void AddFileToList();
35
36     //FileHandle hFile;
37     XFILE::CFile &m_File;
38
39     bool LastWrite;
40     FILE_HANDLETYPE HandleType;
41     bool SkipClose;
42     bool IgnoreReadErrors;
43     bool NewFile;
44     bool AllowDelete;
45     bool AllowExceptions;
46   protected:
47     bool OpenShared;
48   public:
49     char FileName[NM];
50     wchar FileNameW[NM];
51
52     FILE_ERRORTYPE ErrorType;
53
54     uint CloseCount;
55   public:
56     File();
57     virtual ~File();
58     void operator = (File &SrcFile);
59     bool Open(const char *Name,const wchar *NameW=NULL,bool OpenShared=false,bool Update=false);
60     void TOpen(const char *Name,const wchar *NameW=NULL);
61     bool WOpen(const char *Name,const wchar *NameW=NULL);
62     bool Create(const char *Name,const wchar *NameW=NULL);
63     void TCreate(const char *Name,const wchar *NameW=NULL);
64     bool WCreate(const char *Name,const wchar *NameW=NULL);
65     bool Close();
66     void Flush();
67     bool Delete();
68     bool Rename(const char *NewName);
69     void Write(const void *Data,int Size);
70     int Read(void *Data,int Size);
71     int DirectRead(void *Data,int Size);
72     void Seek(Int64 Offset,int Method);
73     bool RawSeek(Int64 Offset,int Method);
74     Int64 Tell();
75     void Prealloc(Int64 Size);
76     byte GetByte();
77     void PutByte(byte Byte);
78     bool Truncate();
79     void SetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL);
80     void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL);
81     static void SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta);
82     void SetOpenFileStat(RarTime *ftm,RarTime *ftc,RarTime *fta);
83     void SetCloseFileStat(RarTime *ftm,RarTime *fta,uint FileAttr);
84     void GetOpenFileTime(RarTime *ft);
85     //bool IsOpened() {return(hFile!=BAD_HANDLE);};
86     bool IsOpened() {return true;}; // wtf
87     Int64 FileLength();
88     void SetHandleType(FILE_HANDLETYPE Type);
89     FILE_HANDLETYPE GetHandleType() {return(HandleType);};
90     bool IsDevice();
91     void fprintf(const char *fmt,...);
92     static bool RemoveCreated();
93     //FileHandle GetHandle() {return(hFile);};
94     void SetIgnoreReadErrors(bool Mode) {IgnoreReadErrors=Mode;};
95     char *GetName() {return(FileName);}
96     long Copy(File &Dest,Int64 Length=INT64ERR);
97     void SetAllowDelete(bool Allow) {AllowDelete=Allow;}
98     void SetExceptions(bool Allow) {AllowExceptions=Allow;}
99 };
100
101 #endif