📄 hpackage.h
字号:
/********************************************************************
*
* =-----------------------------------------------------------------=
* = ____ _________ =
* = / _ \ \___ __/ =
* = / /_/ / ____ / / =
* = / _ \ ● / _ \ / / =
* = / /_/ // // / / // / =
* = \______//_//_/ /_//_/ =
* = =
* = Copyright (c) BIN Technology studio,2004 =
* = LET'Z BT =
* =-----------------------------------------------------------------=
*
* FileName : hPackage.h
* Description : 封装文件包的操作,支持ZIP MPQ PCK
* 封装INI操作
*
* Author : 风间苍月(TuQbasic)
* Email : tuqbasic@sohu.com
*
* Create : 2003.08.07
* LastChange : 2004.02.03
*
* History :
********************************************************************/
#pragma once
#include "hXFile.h"
// 包文件类型
#define PACKAGE_ZIP 0x1
#define PACKAGE_MPQ 0x2
#define PACKAGE_PCK 0x3
// *************************************************************************
// *-----------------------------INI文件访问接口----------------------------
class IFileINI
{
public:
virtual ~IFileINI(void) {}
// 设置访问的INI文件名
virtual void setINIFileName(const char* szINIFile) = 0;
// 查询段是否存在
virtual bool sectionExists(const char* szSection) = 0;
// 设置和获取字段
// 设置成功返回true,否则false
virtual bool setKey(const char* szValue, const char* szKey, const char* szSection) = 0;
// 字段不存在则返回空
virtual const char* getKeyValue(const char* szKey, const char* szSection) = 0;
// 设置和获取数字值
// 设置成功返回true,否则false
virtual bool setKeyDouble(double Value, const char* szKey, const char* szSection) = 0;
// 字段不存在则返回0
virtual double getKeyValueDouble(const char* szKey, const char* szSection) = 0;
// 设置成功返回true,否则false
virtual bool setKeyLong(long dVaule, const char* szKey, const char* szSection) = 0;
// 字段不存在则返回0
virtual long getKeyValueLong(const char* szKey, const char* szSection) = 0;
// 设置和获取布尔值
// 设置成功返回true,否则false
virtual bool setKeyBool(bool bValue, const char* szKey, const char* szSection) = 0;
// 字段不存在则返回false
virtual bool getKeyValueBool(const char* szKey, const char* szSection) = 0;
};
typedef IFileINI * LPI_FILEINI;
// *************************************************************************
// *-----------------------------文件包读取接口-----------------------------
class IFilePackage
{
public:
virtual ~IFilePackage() {}
// 打开和关闭当前文件包
// 打开时会关闭当前Package,打开成功则返回true
virtual bool OpenPackage(const char* szFileName) = 0;
virtual void ClosePackage(void) = 0;
// 获取已打开文件包的名字
virtual const char* GetPackageFileName() = 0;
// 在包中定位当前文件,成功返回true
virtual bool LocateFile(const char* szFileName) = 0;
// 获取包中当前文件的长度,失败返回-1
virtual int GetFileLength(void) = 0;
// 从包中读取当前文件中读取内容,*bufsize为缓冲区长度
// 返回读取的字节数,同时*bufsize也返回字节数
// 如果失败则都返回-1
virtual int ReadFromFile(void* buf, int* bufsize) = 0;
};
typedef IFilePackage * LPI_PACKAGE;
// *************************************************************************
// *--------创建并打开一个INI文件,失败(文件不存在)返回NULL----------------
SAM_API LPI_FILEINI CreateFileINI(const char* szFileName);
// *************************************************************************
// *-------创建并打开文件包,失败(文件不存在或类型错误)返回NULL-------------
// *-----------------lPackage指定包文件的类型-------------------------------
SAM_API LPI_PACKAGE CreatePackage(const char* szFileName, long lPackage);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -