X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=platform%2Flinux%2Fplat.c;h=5788d1d53e90c02afab193464113d0a73e1d9fb7;hb=93a7109873b7050a1b347972711982eac1ad7fbc;hp=f5742b92f678b8259a3e2f034ab36f0f0042c582;hpb=77189b7d9c3e513a4ea612cdcc77955dbc07f75d;p=picodrive.git diff --git a/platform/linux/plat.c b/platform/linux/plat.c index f5742b9..5788d1d 100644 --- a/platform/linux/plat.c +++ b/platform/linux/plat.c @@ -1,6 +1,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -22,17 +23,22 @@ int plat_is_dir(const char *path) int plat_get_root_dir(char *dst, int len) { - extern char **g_argv; - int j; + int j, ret; + + ret = readlink("/proc/self/exe", dst, len - 1); + if (ret < 0) { + perror("readlink"); + ret = 0; + } + dst[ret] = 0; - strncpy(dst, g_argv[0], len); - len -= 32; // reserve - if (len < 0) len = 0; - dst[len] = 0; for (j = strlen(dst); j > 0; j--) - if (dst[j] == '/') { dst[j+1] = 0; break; } + if (dst[j] == '/') { + dst[++j] = 0; + break; + } - return j + 1; + return 0; } #ifdef __GP2X__ @@ -142,3 +148,13 @@ void plat_munmap(void *ptr, size_t size) munmap(ptr, size); } +/* lprintf */ +void lprintf(const char *fmt, ...) +{ + va_list vl; + + va_start(vl, fmt); + vprintf(fmt, vl); + va_end(vl); +} +