rewrite gpathtable and path resolution

This commit is contained in:
Ondřej Novák 2025-01-30 22:39:52 +01:00
parent ccebc91f0d
commit 4a0c7d4fd0
125 changed files with 889 additions and 901 deletions

View file

@ -1 +0,0 @@

View file

@ -66,7 +66,7 @@ INI_CONFIG* ini_open(const char *filename) {
return c;
}
void ini_close(const INI_CONFIG *config) {
void ini_close(INI_CONFIG *config) {
delete config;
}

View file

@ -1,4 +1,6 @@
#include "platform.h"
#include <cstdarg>
#include <filesystem>
@ -62,3 +64,23 @@ FILE *fopen_icase(const char *pathname, const char *mode) {
std::filesystem::path path = try_to_find_file(convert_pathname_to_path(pathname));
return fopen(path.c_str(), mode);
}
static thread_local std::string build_pathname_buffer;
const char * build_pathname(size_t nparts, const char *part1, ...) {
va_list lst;
va_start(lst, part1);
std::filesystem::path p = part1;
for (size_t i = 1; i < nparts; ++i) {
p = p / va_arg(lst, const char *);
}
build_pathname_buffer = p;
return build_pathname_buffer.c_str();
}
char create_directories(const char *path) {
std::filesystem::path p(path);
std::error_code ec;
return std::filesystem::create_directories(p, ec)?1:0;
}

View file

@ -8,7 +8,7 @@
extern "C" {
#endif
#include <event.h>
#include <libs/event.h>
typedef void (*TaskerFunctionName)(va_list);

View file

@ -7,7 +7,7 @@
#define BGSWITCHBIT 0x0020
#define SKELDALINI "wskeldal.ini"
#define SKELDALINI "skeldal.ini"
#ifdef __cplusplus
extern "C"
@ -27,6 +27,21 @@ uint32_t _bios_keybrd(int mode);
#define RGB555(r,g,b) ((unsigned short)(((r)<<11) | ((g)<<6) | (b)))
///build pathname from parts
/**
* @param nparts count of parts (must be > 0)
* @param part first part
* @return complete path - statically allocated buffer
*/
const char * build_pathname(size_t nparts, const char *part1, ...);
///creates directories recursively
/**
* @param path path
* @retval 1 success
* @retval 0 failure
*/
char create_directories(const char *path);
void *map_file_to_memory(const char *name, size_t *sz);

View file

@ -13,7 +13,7 @@
extern "C" {
#endif
#include <devices.h>
#include <libs/devices.h>
char get_control_key_state(void);

View file

@ -5,7 +5,7 @@
#include <SDL2/SDL.h>
#include <thread>
#include <vector>
#include <mouse.h>
#include <libs/mouse.h>
#include <queue>

View file

@ -1,5 +1,5 @@
#include "../platform.h"
#include <zvuk.h>
#include <libs/zvuk.h>
#include <thread>
void set_mixing_device(int mix_dev,int mix_freq,...) {