1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 22:09:35 +00:00

Add simple check for absolute paths to texture filter folders.

Relative path is not supported and must be substituted by default one.
This commit is contained in:
Sergey Lipskiy 2019-02-28 13:31:11 +07:00
parent 08e15767a6
commit 4a925e1490
5 changed files with 24 additions and 3 deletions

View File

@ -1,4 +1,5 @@
#include <stdarg.h>
#include <osal_files.h>
#include "GLideNHQ/Ext_TxFilter.h"
#include <Graphics/Context.h>
#include <Graphics/Parameters.h>
@ -78,7 +79,8 @@ void TextureFilterHandler::init()
wchar_t txPath[PLUGIN_PATH_SIZE + 16];
wchar_t * pTexPackPath = config.textureFilter.txPath;
if (::wcslen(config.textureFilter.txPath) == 0) {
if (::wcslen(config.textureFilter.txPath) == 0 ||
osal_is_absolute_path(config.textureFilter.txPath) == 0) {
api().GetUserDataPath(txPath);
gln_wcscat(txPath, wst("/hires_texture"));
pTexPackPath = txPath;
@ -86,7 +88,8 @@ void TextureFilterHandler::init()
wchar_t txCachePath[PLUGIN_PATH_SIZE + 16];
wchar_t * pTexCachePath = config.textureFilter.txCachePath;
if (::wcslen(config.textureFilter.txCachePath) == 0) {
if (::wcslen(config.textureFilter.txCachePath) == 0 ||
osal_is_absolute_path(config.textureFilter.txCachePath) == 0) {
api().GetUserCachePath(txCachePath);
gln_wcscat(txCachePath, wst("/cache"));
pTexCachePath = txCachePath;
@ -94,7 +97,8 @@ void TextureFilterHandler::init()
wchar_t txDumpPath[PLUGIN_PATH_SIZE + 16];
wchar_t * pTexDumpPath = config.textureFilter.txDumpPath;
if (::wcslen(config.textureFilter.txDumpPath) == 0) {
if (::wcslen(config.textureFilter.txDumpPath) == 0 ||
osal_is_absolute_path(config.textureFilter.txDumpPath) == 0) {
api().GetUserCachePath(txDumpPath);
gln_wcscat(txDumpPath, wst("/texture_dump"));
pTexDumpPath = txDumpPath;

View File

@ -50,6 +50,8 @@ extern "C" {
// Returns 1 if name contains path to a directory, 0 otherwise
EXPORT int CALL osal_is_directory(const wchar_t* name);
// Returns 1 if name contains an absolute path, 0 otherwise. Path validity not tested.
EXPORT int CALL osal_is_absolute_path(const wchar_t* name);
// Returns 1 if path points to file or directory, 0 otherwise
EXPORT int CALL osal_path_existsA(const char *path);
// Returns 1 if path points to file or directory, 0 otherwise

View File

@ -20,6 +20,11 @@ EXPORT int CALL osal_path_existsW(const wchar_t *_path)
return [[NSFileManager defaultManager] fileExistsAtPath:nsPath];
}
EXPORT int CALL osal_is_absolute_path(const wchar_t* name)
{
return name[0] == L'/';
}
EXPORT int CALL osal_is_directory(const wchar_t * _name)
{
NSString* nsPath = [[NSString alloc] initWithBytes:_name length:wcslen(_name)*sizeof(*_name) encoding:NSUTF32LittleEndianStringEncoding];

View File

@ -53,6 +53,11 @@ EXPORT int CALL osal_path_existsW(const wchar_t *_path)
return stat(path, &fileinfo) == 0 ? 1 : 0;
}
EXPORT int CALL osal_is_absolute_path(const wchar_t* name)
{
return name[0] == L'/';
}
EXPORT int CALL osal_is_directory(const wchar_t * _name)
{
char name[PATH_MAX + 1];

View File

@ -51,6 +51,11 @@ EXPORT int CALL osal_path_existsW(const wchar_t *path)
return _wstat(path, &fileinfo) == 0 ? 1 : 0;
}
EXPORT int CALL osal_is_absolute_path(const wchar_t* name)
{
return wcschr(name, L':') != NULL || name[0] == L'\\' || name[0] == L'/';
}
EXPORT int CALL osal_is_directory(const wchar_t* _name)
{
wchar_t DirName[MAX_PATH + 1];