mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-02-18 10:23:35 +00:00
Updated readonly support
This commit is contained in:
@@ -657,7 +657,24 @@ __EXPORT_TYPE ILibSimpleDataStore ILibSimpleDataStore_CreateEx2(char* filePath,
|
||||
if (retVal->dataFile != NULL) { ILibSimpleDataStore_RebuildKeyTable(retVal); }
|
||||
return retVal;
|
||||
}
|
||||
void ILibSimpleDataStore_ReOpenReadOnly(ILibSimpleDataStore dataStore, char* filePath)
|
||||
{
|
||||
ILibSimpleDataStore_Root *root = (ILibSimpleDataStore_Root*)dataStore;
|
||||
|
||||
if (root->dataFile != NULL)
|
||||
{
|
||||
#ifdef _POSIX
|
||||
flock(fileno(root->dataFile), LOCK_UN);
|
||||
#endif
|
||||
fclose(root->dataFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
root->filePath = ILibString_Copy(filePath, (int)strnlen_s(filePath, ILibSimpleDataStore_MaxFilePath));
|
||||
}
|
||||
root->dataFile = ILibSimpleDataStore_OpenFileEx2(root->filePath, 0, 1);
|
||||
if (root->dataFile != NULL) { ILibSimpleDataStore_RebuildKeyTable(root); }
|
||||
}
|
||||
void ILibSimpleDataStore_CacheClear_Sink(ILibHashtable sender, void *Key1, char* Key2, int Key2Len, void *Data, void *user)
|
||||
{
|
||||
if (Data != NULL) { free(Data); }
|
||||
|
||||
@@ -46,6 +46,7 @@ __EXPORT_TYPE ILibSimpleDataStore ILibSimpleDataStore_CreateEx2(char* filePath,
|
||||
#define ILibSimpleDataStore_Create(filePath) ILibSimpleDataStore_CreateEx2(filePath, 0, 0)
|
||||
#define ILibSimpleDataStore_CreateEx(filePath, userExtraMemorySize) ILibSimpleDataStore_CreateEx2(filePath, userExtraMemorySize, 0)
|
||||
#define ILibSimpleDataStore_CreateCachedOnly() ILibSimpleDataStore_Create(NULL)
|
||||
void ILibSimpleDataStore_ReOpenReadOnly(ILibSimpleDataStore dataStore, char* filePath);
|
||||
int ILibSimpleDataStore_IsCacheOnly(ILibSimpleDataStore ds);
|
||||
|
||||
// Check if the data store exists
|
||||
|
||||
Reference in New Issue
Block a user