Rename smcore to bridge, and use it as a pointer.
This commit is contained in:
@@ -99,54 +99,54 @@ public:
|
||||
}
|
||||
|
||||
static ValveFile *Open(const char *filename, const char *mode, const char *pathID) {
|
||||
FileHandle_t handle = smcore.filesystem->Open(filename, mode, pathID);
|
||||
FileHandle_t handle = bridge->filesystem->Open(filename, mode, pathID);
|
||||
if (!handle)
|
||||
return NULL;
|
||||
return new ValveFile(handle);
|
||||
}
|
||||
|
||||
static bool Delete(const char *filename, const char *pathID) {
|
||||
if (!smcore.filesystem->FileExists(filename, pathID))
|
||||
if (!bridge->filesystem->FileExists(filename, pathID))
|
||||
return false;
|
||||
|
||||
smcore.filesystem->RemoveFile(filename, pathID);
|
||||
bridge->filesystem->RemoveFile(filename, pathID);
|
||||
|
||||
if (smcore.filesystem->FileExists(filename, pathID))
|
||||
if (bridge->filesystem->FileExists(filename, pathID))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Read(void *pOut, int size) override {
|
||||
return (size_t)smcore.filesystem->Read(pOut, size, handle_);
|
||||
return (size_t)bridge->filesystem->Read(pOut, size, handle_);
|
||||
}
|
||||
char *ReadLine(char *pOut, int size) override {
|
||||
return smcore.filesystem->ReadLine(pOut, size, handle_);
|
||||
return bridge->filesystem->ReadLine(pOut, size, handle_);
|
||||
}
|
||||
size_t Write(const void *pData, int size) override {
|
||||
return (size_t)smcore.filesystem->Write(pData, size, handle_);
|
||||
return (size_t)bridge->filesystem->Write(pData, size, handle_);
|
||||
}
|
||||
bool Seek(int pos, int seek_type) override {
|
||||
smcore.filesystem->Seek(handle_, pos, seek_type);
|
||||
bridge->filesystem->Seek(handle_, pos, seek_type);
|
||||
return !HasError();
|
||||
}
|
||||
int Tell() override {
|
||||
return smcore.filesystem->Tell(handle_);
|
||||
return bridge->filesystem->Tell(handle_);
|
||||
}
|
||||
bool HasError() override {
|
||||
return !handle_ || !smcore.filesystem->IsOk(handle_);
|
||||
return !handle_ || !bridge->filesystem->IsOk(handle_);
|
||||
}
|
||||
bool Flush() override {
|
||||
smcore.filesystem->Flush(handle_);
|
||||
bridge->filesystem->Flush(handle_);
|
||||
return true;
|
||||
}
|
||||
bool EndOfFile() override {
|
||||
return smcore.filesystem->EndOfFile(handle_);
|
||||
return bridge->filesystem->EndOfFile(handle_);
|
||||
}
|
||||
void Close() override {
|
||||
if (!handle_)
|
||||
return;
|
||||
smcore.filesystem->Close(handle_);
|
||||
bridge->filesystem->Close(handle_);
|
||||
handle_ = NULL;
|
||||
}
|
||||
virtual ValveFile *AsValveFile() {
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
else if (type == g_ValveDirType)
|
||||
{
|
||||
ValveDirectory *valveDir = (ValveDirectory *)object;
|
||||
smcore.filesystem->FindClose(valveDir->hndl);
|
||||
bridge->filesystem->FindClose(valveDir->hndl);
|
||||
delete valveDir;
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ static cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
ValveDirectory *valveDir = new ValveDirectory;
|
||||
|
||||
const char *pFirst = smcore.filesystem->FindFirstEx(wildcardedPath, pathID, &valveDir->hndl);
|
||||
const char *pFirst = bridge->filesystem->FindFirstEx(wildcardedPath, pathID, &valveDir->hndl);
|
||||
if (!pFirst)
|
||||
{
|
||||
delete valveDir;
|
||||
@@ -419,7 +419,7 @@ static cell_t sm_ReadDirEntry(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
else
|
||||
{
|
||||
pEntry = smcore.filesystem->FindNext(valveDir->hndl);
|
||||
pEntry = bridge->filesystem->FindNext(valveDir->hndl);
|
||||
}
|
||||
|
||||
valveDir->bHandledFirstPath = true;
|
||||
@@ -443,7 +443,7 @@ static cell_t sm_ReadDirEntry(IPluginContext *pContext, const cell_t *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (smcore.filesystem->FindIsDirectory(valveDir->hndl))
|
||||
if (bridge->filesystem->FindIsDirectory(valveDir->hndl))
|
||||
{
|
||||
*filetype = 1;
|
||||
} else {
|
||||
@@ -557,7 +557,7 @@ static cell_t sm_FileExists(IPluginContext *pContext, const cell_t *params)
|
||||
if (params[0] >= 3)
|
||||
pContext->LocalToStringNULL(params[3], &pathID);
|
||||
|
||||
return smcore.filesystem->FileExists(name, pathID) ? 1 : 0;
|
||||
return bridge->filesystem->FileExists(name, pathID) ? 1 : 0;
|
||||
}
|
||||
|
||||
char realpath[PLATFORM_MAX_PATH];
|
||||
@@ -598,7 +598,7 @@ static cell_t sm_RenameFile(IPluginContext *pContext, const cell_t *params)
|
||||
char *pathID;
|
||||
pContext->LocalToStringNULL(params[4], &pathID);
|
||||
|
||||
smcore.filesystem->RenameFile(oldpath, newpath, pathID);
|
||||
bridge->filesystem->RenameFile(oldpath, newpath, pathID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ static cell_t sm_DirExists(IPluginContext *pContext, const cell_t *params)
|
||||
char *pathID;
|
||||
pContext->LocalToStringNULL(params[3], &pathID);
|
||||
|
||||
return smcore.filesystem->IsDirectory(name, pathID) ? 1 : 0;
|
||||
return bridge->filesystem->IsDirectory(name, pathID) ? 1 : 0;
|
||||
}
|
||||
|
||||
char realpath[PLATFORM_MAX_PATH];
|
||||
@@ -671,9 +671,9 @@ static cell_t sm_FileSize(IPluginContext *pContext, const cell_t *params)
|
||||
if (params[0] >= 3)
|
||||
pContext->LocalToStringNULL(params[3], &pathID);
|
||||
|
||||
if (!smcore.filesystem->FileExists(name, pathID))
|
||||
if (!bridge->filesystem->FileExists(name, pathID))
|
||||
return -1;
|
||||
return smcore.filesystem->Size(name, pathID);
|
||||
return bridge->filesystem->Size(name, pathID);
|
||||
}
|
||||
|
||||
char realpath[PLATFORM_MAX_PATH];
|
||||
@@ -730,12 +730,12 @@ static cell_t sm_CreateDirectory(IPluginContext *pContext, const cell_t *params)
|
||||
char *pathID;
|
||||
pContext->LocalToStringNULL(params[4], &pathID);
|
||||
|
||||
if (smcore.filesystem->IsDirectory(name, pathID))
|
||||
if (bridge->filesystem->IsDirectory(name, pathID))
|
||||
return 0;
|
||||
|
||||
smcore.filesystem->CreateDirHierarchy(name, pathID);
|
||||
bridge->filesystem->CreateDirHierarchy(name, pathID);
|
||||
|
||||
if (smcore.filesystem->IsDirectory(name, pathID))
|
||||
if (bridge->filesystem->IsDirectory(name, pathID))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -783,8 +783,8 @@ static cell_t sm_WriteFileLine(IPluginContext *pContext, const cell_t *params)
|
||||
if (SystemFile *sysfile = file->AsSystemFile()) {
|
||||
fprintf(sysfile->fp(), "%s\n", buffer);
|
||||
} else if (ValveFile *vfile = file->AsValveFile()) {
|
||||
smcore.filesystem->FPrint(vfile->handle(), buffer);
|
||||
smcore.filesystem->FPrint(vfile->handle(), "\n");
|
||||
bridge->filesystem->FPrint(vfile->handle(), buffer);
|
||||
bridge->filesystem->FPrint(vfile->handle(), "\n");
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
@@ -840,7 +840,7 @@ static cell_t sm_LogToGame(IPluginContext *pContext, const cell_t *params)
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
smcore.LogToGame(buffer);
|
||||
bridge->LogToGame(buffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user