plugy/PlugY/INIfile.h

69 lines
1.8 KiB
C
Raw Permalink Normal View History

/******************************************************************************
File modified by Yohann NICOLAS.
NAME
inifile.h
DESCRIPTION
Memory cached INI file read/write class to replace legacy MS code
COPYRIGHT
<EFBFBD>1999-2004 Ultrafunk (www.ultrafunk.com) - info@ultrafunk.com
******************************************************************************/
2017-01-23 19:34:12 +00:00
#pragma once
#include <windows.h>
#define INIFILE_READ 10
#define INIFILE_WRITE 20
#define INIFILE_MPQREAD 30
#define MAX_SECTIONNAME_LENGTH 128
#define MAX_KEYNAME_LENGTH 128
class INIFile
{
public:
INIFile();
~INIFile();
2017-01-23 19:34:12 +00:00
BOOL InitReadWrite(const char *path, int readWrite, DWORD writeCacheSize);
BOOL close();
int GetPrivateProfileString(const char *section, const char *key, const char *def, char *dest, DWORD size);
BOOL WritePrivateProfileString(char *section, char *key, char *string);
private:
2017-01-23 19:34:12 +00:00
char m_currentSection[MAX_SECTIONNAME_LENGTH];
char *m_cache;
char *m_sectionStart;
char *m_sectionEnd;
int m_readWrite;
char m_path[_MAX_PATH];
HANDLE m_file;
DWORD m_cacheWritePos;
};
2017-01-23 19:34:12 +00:00
class INIFileW
{
public:
INIFileW();
~INIFileW();
2017-01-23 19:34:12 +00:00
BOOL InitReadWrite(const char *path, int readWrite, DWORD writeCacheSize);
BOOL close();
int GetPrivateProfileString(LPCWSTR section, LPCWSTR key, LPCWSTR def, LPWSTR dest, DWORD size);
int GetPrivateProfileStringList(LPCWSTR section, LPCWSTR key, DWORD** codes, LPWSTR** values);
//BOOL WritePrivateProfileString(char *section, char *key, char *string);
LPWSTR m_cache;
2017-01-23 19:34:12 +00:00
private:
WCHAR m_currentSection[MAX_SECTIONNAME_LENGTH];
LPCWSTR m_sectionStart;
LPCWSTR m_sectionEnd;
int m_readWrite;
char m_path[_MAX_PATH];
HANDLE m_file;
DWORD m_cacheWritePos;
};
/*================================= END OF FILE =================================*/