Add compat_access (#272)
This commit is contained in:
parent
aa99b2e1d3
commit
a8815229a0
10
src/game.cc
10
src/game.cc
|
@ -3,12 +3,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <io.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h> // access
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "animation.h"
|
#include "animation.h"
|
||||||
#include "art.h"
|
#include "art.h"
|
||||||
|
@ -1336,12 +1330,12 @@ static int gameDbInit()
|
||||||
for (patch_index = 0; patch_index < 1000; patch_index++) {
|
for (patch_index = 0; patch_index < 1000; patch_index++) {
|
||||||
snprintf(filename, sizeof(filename), "patch%03d.dat", patch_index);
|
snprintf(filename, sizeof(filename), "patch%03d.dat", patch_index);
|
||||||
|
|
||||||
if (access(filename, 0) == 0) {
|
if (compat_access(filename, 0) == 0) {
|
||||||
dbOpen(filename, 0, NULL, 1);
|
dbOpen(filename, 0, NULL, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access("f2_res.dat", 0) == 0) {
|
if (compat_access("f2_res.dat", 0) == 0) {
|
||||||
dbOpen("f2_res.dat", 0, NULL, 1);
|
dbOpen("f2_res.dat", 0, NULL, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -364,6 +364,15 @@ void compat_resolve_path(char* path)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compat_access(const char* path, int mode)
|
||||||
|
{
|
||||||
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
|
strcpy(nativePath, path);
|
||||||
|
compat_windows_path_to_native(nativePath);
|
||||||
|
compat_resolve_path(nativePath);
|
||||||
|
return access(nativePath, mode);
|
||||||
|
}
|
||||||
|
|
||||||
char* compat_strdup(const char* string)
|
char* compat_strdup(const char* string)
|
||||||
{
|
{
|
||||||
return SDL_strdup(string);
|
return SDL_strdup(string);
|
||||||
|
|
|
@ -41,6 +41,7 @@ int compat_remove(const char* path);
|
||||||
int compat_rename(const char* oldFileName, const char* newFileName);
|
int compat_rename(const char* oldFileName, const char* newFileName);
|
||||||
void compat_windows_path_to_native(char* path);
|
void compat_windows_path_to_native(char* path);
|
||||||
void compat_resolve_path(char* path);
|
void compat_resolve_path(char* path);
|
||||||
|
int compat_access(const char* path, int mode);
|
||||||
char* compat_strdup(const char* string);
|
char* compat_strdup(const char* string);
|
||||||
long getFileSize(FILE* stream);
|
long getFileSize(FILE* stream);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue