core: As an experiment, handle running from a subdirectory (generally out/debug or out/release, since people tend to do that). Remove unused File.stat().
Some checks failed
Build Tilde Friends / Build-All (push) Failing after 4m49s

This commit is contained in:
2025-01-31 20:37:14 -05:00
parent 916aa5abbd
commit 192a81ede7
5 changed files with 121 additions and 101 deletions

View File

@ -155,6 +155,7 @@ typedef struct _tf_task_t
int _https_port;
char _db_path[256];
char _zip_path[256];
char _root_path[256];
unzFile _zip;
const char* _args;
@ -363,7 +364,16 @@ static const char* _task_loadFile(tf_task_t* task, const char* fileName, size_t*
}
else
{
FILE* file = fopen(fileName, "rb");
const char* actual = fileName;
if (*task->_root_path)
{
size_t size = strlen(task->_root_path) + strlen(fileName) + 2;
char* buffer = alloca(size);
snprintf(buffer, size, "%s/%s", task->_root_path, fileName);
actual = fileName;
}
tf_printf("opening %s\n", actual);
FILE* file = fopen(actual, "rb");
if (file)
{
fseek(file, 0, SEEK_END);
@ -2015,11 +2025,21 @@ void tf_task_set_zip_path(tf_task_t* task, const char* zip_path)
}
}
void tf_task_set_root_path(tf_task_t* task, const char* path)
{
snprintf(task->_root_path, sizeof(task->_root_path), "%s", path ? path : "");
}
const char* tf_task_get_zip_path(tf_task_t* task)
{
return task->_zip ? task->_zip_path : NULL;
}
const char* tf_task_get_root_path(tf_task_t* task)
{
return *task->_root_path ? task->_root_path : NULL;
}
void tf_task_set_args(tf_task_t* task, const char* args)
{
task->_args = args;