92 lines
1.9 KiB
C++
92 lines
1.9 KiB
C++
#pragma once
|
|
#include "superlist.h"
|
|
|
|
#include "ACString.h"
|
|
|
|
#include "WCString.h"
|
|
|
|
#include <fstream>
|
|
#include "TGGiStreamFile.h"
|
|
|
|
class TGGiSlibStorage
|
|
{
|
|
friend class DlgSlbMan;
|
|
public:
|
|
|
|
TGGiSlibStorage(const TCHAR *fname, const TCHAR *ext = g_Option::instance().SLD_EXT, const TCHAR *t = g_Option::instance().SLB_TITLE, int opMode = (std::ios_base::in | std::ios_base::out | std::ios_base::binary));
|
|
|
|
virtual ~TGGiSlibStorage();
|
|
//拷贝第 n 个记录到磁盘文件
|
|
virtual int Copy(int n, const TCHAR *sldfile);
|
|
|
|
virtual int QuickCopy(const TCHAR *sldfile);
|
|
|
|
// 往库文件添加一个记录
|
|
virtual int Append(const TCHAR *sldfile, const TCHAR *szEntryName = NULL);
|
|
|
|
//移第 n 个记录到磁盘文件
|
|
virtual int Move(int n, const TCHAR *sldfile);
|
|
|
|
int operator !();
|
|
|
|
int Open(const TCHAR *file = NULL, int mode = (std::ios_base::in | std::ios_base::out | std::ios_base::binary));
|
|
|
|
// 文件打开状态可用
|
|
//取得库文件的第 n 个记录
|
|
int GetRecord(int n, STCatalogue *rec);
|
|
|
|
//取得所有幻灯列表
|
|
int GetAll(PtrList<TCHAR> &res);
|
|
int GetAll(PtrList<STCatalogue> &res);
|
|
|
|
//取得记录的个数
|
|
int Length();
|
|
|
|
// 判断一记录在库文件里是否存在
|
|
int IsExist(const TCHAR *sldname, int *index);
|
|
|
|
// 删除库文件第 n 个记录
|
|
int Remove(int n);
|
|
int Remove(const TCHAR *sld);
|
|
|
|
//改第 n 个记录的名称
|
|
int Rename(int n, const TCHAR *sldfile);
|
|
|
|
void Close();
|
|
|
|
char * ReadItem(const TCHAR *szItemName, unsigned *nLen);
|
|
|
|
protected:
|
|
|
|
enum FileOperation
|
|
{
|
|
File_Add,
|
|
File_Del,
|
|
File_Copy,
|
|
File_Move
|
|
};
|
|
|
|
int MoveFilePtr(int n); //把文件指针移到第 n 个记录的起始
|
|
|
|
// 必须以读或写方式打开
|
|
int MainTain(const TCHAR *sldname, FileOperation opr, const TCHAR *szItem = NULL);
|
|
|
|
int MoveOrCopy(int n, const TCHAR *sldfile, FileOperation opr);
|
|
|
|
protected:
|
|
|
|
#if (ARX>15)
|
|
std::fstream _libfile;
|
|
#else
|
|
fstream _libfile;
|
|
#endif
|
|
|
|
int openMode;
|
|
|
|
TCString slbfile;
|
|
TCString libExt, itemExt;
|
|
ACString title;
|
|
TGGiStreamFile* m_pStreamFile;
|
|
};
|
|
|