Fix disk access path separator on Linux

This commit is contained in:
Kuba Szczodrzyński 2024-02-07 23:12:23 +01:00
parent a884fbf705
commit e922042a3d
No known key found for this signature in database
GPG Key ID: 43037AC62A600562
5 changed files with 31 additions and 18 deletions

View File

@ -62,11 +62,11 @@ void PosixDevice::show_info()
if(uname(&uts) < 0) {
LOG_ERROR(0, "uname() error");
} else {
LOG_VERBOSE(0, "Sysname: %s", uts.sysname);
LOG_VERBOSE(0, "Nodename: %s", uts.nodename);
LOG_VERBOSE(0, "Release: %s", uts.release);
LOG_VERBOSE(0, "Version: %s", uts.version);
LOG_VERBOSE(0, "Machine: %s", uts.machine);
LOG_VERBOSE(0, "Sysname : %s", uts.sysname);
LOG_VERBOSE(0, "Nodename : %s", uts.nodename);
LOG_VERBOSE(0, "Release : %s", uts.release);
LOG_VERBOSE(0, "Version : %s", uts.version);
LOG_VERBOSE(0, "Machine : %s", uts.machine);
}
LOG_VERBOSE(0, "Processor : %s", "unknown");

View File

@ -800,7 +800,11 @@ void dispatch_run_script(const char*, const char* payload, uint8_t source)
path[0] = '.';
path[1] = '\0';
strcat(path, filename);
#if defined(WINDOWS)
path[1] = '\\';
#elif defined(POSIX)
path[1] = '/';
#endif
LOG_TRACE(TAG_HASP, F("Loading %s from disk..."), path);
std::ifstream f(path); // taking file as inputstream

View File

@ -244,7 +244,11 @@ void Page::load_jsonl(const char* pagesfile)
path[0] = '.';
path[1] = '\0';
strcat(path, pagesfile);
#if defined(WINDOWS)
path[1] = '\\';
#elif defined(POSIX)
path[1] = '/';
#endif
LOG_TRACE(TAG_HASP, F("Loading %s from disk..."), path);
std::ifstream f(path); // taking file as inputstream

View File

@ -29,6 +29,7 @@
#if defined(POSIX)
#include <unistd.h>
#include <linux/limits.h>
#define cwd getcwd
#endif

View File

@ -17,6 +17,7 @@
#if defined(POSIX)
#include <netdb.h>
#include <unistd.h>
#include <linux/limits.h>
#define cwd getcwd
#define cd chdir
#endif
@ -104,16 +105,19 @@ void InitializeConsoleOutput()
void usage(const char* progName, const char* version)
{
std::cout
<< "\n"
std::cout << "\n"
<< progName << " " << version << " [options]" << std::endl
<< std::endl
<< "Options:" << std::endl
<< " -h | --help Print this help" << std::endl
<< " -W | --width Width of the window" << std::endl
<< " -H | --height Height of the window" << std::endl
<< " -C | --config Configuration directory (default: '~/.local/share/hasp' or 'AppData\\hasp\\hasp')"
<< std::endl
<< " -C | --config Configuration directory" << std::endl
#if defined(WINDOWS)
<< " (default: 'AppData\\hasp\\hasp')" << std::endl
#elif defined(POSIX)
<< " (default: '~/.local/share/hasp/hasp')" << std::endl
#endif
<< std::endl;
fflush(stdout);
}