00001 #ifndef __STORE_PRIV_H
00002 #define __STORE_PRIV_H
00003
00004 #include "StoreCommon.h"
00005
00006 class StorageItem;
00007 class StorageObj;
00008 class StorageKit;
00009
00010 enum NodeRelation
00011 {
00012 NodeChild,
00013 NodeNext,
00014 NodePrev,
00015 };
00016
00017 #define GSUBFILE_NOBUFFERING 0
00018
00019 class GSubFilePtr;
00020 class GSubFile : public GFile
00021 {
00022 GSemaphore *Lck;
00023 GArray<GSubFilePtr*> Ptrs;
00024
00025 #if GSUBFILE_NOBUFFERING
00026 bool Buffer;
00027 uint8 *Buf;
00028 int Block;
00029 int Shift;
00030 int64 Cur;
00031 int64 Pos;
00032 bool Dirty;
00033
00034 bool SetBlock(int64 b);
00035 #endif
00036
00037 public:
00038 GSubFile(GSemaphore *lock, bool Buffering = true);
00039 ~GSubFile();
00040
00041 GSubFilePtr *Create(char *file, int line);
00042 void Detach(GSubFilePtr *Ptr);
00043 bool Lock();
00044 bool LockWithTimeout(int Timeout );
00045 void Unlock();
00046
00047 #if GSUBFILE_NOBUFFERING
00048 int Open(char *Str = 0, int Int = 0);
00049 int Read(void *Buffer, int Size, int Flags = 0);
00050 int Write(const void *Buffer, int Size, int Flags = 0);
00051 int64 GetPos();
00052 int64 SetPos(int64 pos);
00053 #endif
00054 };
00055
00056 class GSubFilePtr : public GFile
00057 {
00058 friend class GSubFile;
00059 GSubFile *File;
00060
00061
00062 bool Sub;
00063 int64 Start;
00064 int64 Len;
00065
00066
00067 char *SrcFile;
00068 int SrcLine;
00069
00070
00071 int64 OurPos;
00072 bool OurStatus;
00073
00074
00075 int64 ActualPos;
00076 bool ActualStatus;
00077 bool ActualSwap;
00078
00079 bool SaveState();
00080 bool RestoreState();
00081
00082 public:
00083 GSubFilePtr(GSubFile *Parent, char *file, int line);
00084 ~GSubFilePtr();
00085
00087 void SetSub
00088 (
00090 int start,
00092 int len
00093 );
00094
00096 void ClearSub();
00097
00098
00099 int Open(char *Str = 0, int Int = 0);
00100 bool IsOpen();
00101 int Close();
00102 int64 GetSize();
00103 int64 SetSize(int64 Size);
00104 int64 GetPos();
00105 int64 SetPos(int64 pos);
00106 int64 Seek(int64 To, int Whence);
00107 GStreamI *Clone();
00108 bool Eof();
00109 bool GetStatus();
00110 void SetStatus(bool s);
00111 int Read(void *Buffer, int Size, int Flags = 0);
00112 int Write(const void *Buffer, int Size, int Flags = 0);
00113 int ReadStr(char *Buf, int Size);
00114 int WriteStr(char *Buf, int Size);
00115 int Print(char *Format, ...);
00116 };
00117
00118 #endif