Skip to content

Commit 1509d46

Browse files
committed
log more stuff
1 parent 2cf996b commit 1509d46

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

file_path_special.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,30 @@
7272
#include "paths.h"
7373
#include "verbosity.h"
7474

75+
#include <stdio.h>
76+
#include <stdarg.h>
77+
78+
void retroarch_log3(const char *fmt, ...)
79+
{
80+
va_list args;
81+
82+
va_start(args, fmt);
83+
vprintf(fmt, args);
84+
fflush(stdout);
85+
va_end(args);
86+
87+
FILE *f = fopen("/tmp/retroarch.log", "a");
88+
if (!f)
89+
return;
90+
91+
va_start(args, fmt);
92+
vfprintf(f, fmt, args);
93+
fflush(f);
94+
va_end(args);
95+
96+
fclose(f);
97+
}
98+
7599
bool fill_pathname_application_data(char *s, size_t len)
76100
{
77101
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
@@ -162,6 +186,7 @@ bool fill_pathname_application_data(char *s, size_t len)
162186
/* On Haiku, it is set by default to /home/user/config/settings */
163187
if (xdg)
164188
{
189+
retroarch_log3("fill_pathname_application_data: XDG_CONFIG_HOME is set to: %s\n", xdg);
165190
fill_pathname_join(s, xdg, "retroarch/", len);
166191
return true;
167192
}
@@ -173,6 +198,7 @@ bool fill_pathname_application_data(char *s, size_t len)
173198
fill_pathname_join(s, appdata,
174199
"config/settings/retroarch/", len);
175200
#else
201+
retroarch_log3("fill_pathname_application_data: HOME is set to: %s\n", appdata);
176202
fill_pathname_join(s, appdata,
177203
".config/retroarch/", len);
178204
#endif

libretro-common/file/file_path_io.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,30 @@ int32_t path_get_size(const char *path)
9898
return -1;
9999
}
100100

101+
#include <stdio.h>
102+
#include <stdarg.h>
103+
104+
void retroarch_log(const char *fmt, ...)
105+
{
106+
va_list args;
107+
108+
va_start(args, fmt);
109+
vprintf(fmt, args);
110+
fflush(stdout);
111+
va_end(args);
112+
113+
FILE *f = fopen("/tmp/retroarch.log", "a");
114+
if (!f)
115+
return;
116+
117+
va_start(args, fmt);
118+
vfprintf(f, fmt, args);
119+
fflush(f);
120+
va_end(args);
121+
122+
fclose(f);
123+
}
124+
101125
/**
102126
* path_mkdir:
103127
* @dir : directory
@@ -110,6 +134,8 @@ int32_t path_get_size(const char *path)
110134
**/
111135
bool path_mkdir(const char *dir)
112136
{
137+
retroarch_log("path_mkdir: Creating directory: %s\n", dir);
138+
113139
bool norecurse = false;
114140
char *basedir = NULL;
115141

retroarch.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5951,6 +5951,34 @@ void main_exit(void *args)
59515951
#endif
59525952
}
59535953

5954+
#include <stdio.h>
5955+
#include <stdarg.h>
5956+
5957+
void retroarch_log2(const char *fmt, ...)
5958+
{
5959+
va_list args;
5960+
5961+
va_start(args, fmt);
5962+
vprintf(fmt, args);
5963+
fflush(stdout);
5964+
va_end(args);
5965+
5966+
FILE *f = fopen("/tmp/retroarch.log", "a");
5967+
if (!f)
5968+
return;
5969+
5970+
va_start(args, fmt);
5971+
vfprintf(f, fmt, args);
5972+
fflush(f);
5973+
va_end(args);
5974+
5975+
fclose(f);
5976+
}
5977+
5978+
#include <sys/stat.h>
5979+
#include <sys/types.h>
5980+
5981+
59545982
/**
59555983
* main_entry:
59565984
*
@@ -5990,12 +6018,70 @@ int rarch_main(int argc, char *argv[], void *data)
59906018
#if defined(WEBOS)
59916019
/* compatibility with webOS 1 */
59926020
const char *home = getenv("HOME");
6021+
const char *xdg_config_home = getenv("XDG_CONFIG_HOME");
6022+
6023+
retroarch_log2("rarch_main: BEFORE - HOME='%s', XDG_CONFIG_HOME='%s'\n",
6024+
home ? home : "(null)",
6025+
xdg_config_home ? xdg_config_home : "(null)");
6026+
6027+
if (access("/media/developer/apps/usr/palm/applications/com.retroarch.webos", F_OK) == 0) {
6028+
6029+
struct stat st;
6030+
if (stat("/media/developer/apps/usr/palm/applications/com.retroarch.webos", &st) == 0) {
6031+
retroarch_log2("rarch_main: '%s' exists, mode=%04o\n",
6032+
"/media/developer/apps/usr/palm/applications/com.retroarch.webos", st.st_mode & 0777);
6033+
6034+
char perms[10]; perms[0] = (st.st_mode & S_IRUSR) ? 'r' : '-';
6035+
perms[1] = (st.st_mode & S_IWUSR) ? 'w' : '-';
6036+
perms[2] = (st.st_mode & S_IXUSR) ? 'x' : '-';
6037+
perms[3] = (st.st_mode & S_IRGRP) ? 'r' : '-';
6038+
perms[4] = (st.st_mode & S_IWGRP) ? 'w' : '-';
6039+
perms[5] = (st.st_mode & S_IXGRP) ? 'x' : '-';
6040+
perms[6] = (st.st_mode & S_IROTH) ? 'r' : '-';
6041+
perms[7] = (st.st_mode & S_IWOTH) ? 'w' : '-';
6042+
perms[8] = (st.st_mode & S_IXOTH) ? 'x' : '-';
6043+
perms[9] = '\0';
6044+
retroarch_log2("rarch_main: permissions: %s\n", perms);
6045+
}
6046+
}
6047+
59936048
if (home == NULL || strcmp(home, "/media/developer/") == 0)
59946049
{
59956050
char cwd[PATH_MAX];
59966051
if (getcwd(cwd, sizeof(cwd)) != NULL)
59976052
setenv("HOME", cwd, 1);
59986053
}
6054+
6055+
if (xdg_config_home == NULL || strcmp(xdg_config_home, "/media/developer/") == 0)
6056+
{
6057+
char cwd2[PATH_MAX];
6058+
if (getcwd(cwd2, sizeof(cwd2)) != NULL)
6059+
{
6060+
char new_path[PATH_MAX + 16];
6061+
snprintf(new_path, sizeof(new_path), "%s/.config", cwd2);
6062+
setenv("XDG_CONFIG_HOME", new_path, 1);
6063+
6064+
if (access(new_path, F_OK) == 0)
6065+
{
6066+
retroarch_log2("rarch_main: '%s' exists\n", new_path);
6067+
}
6068+
else {
6069+
retroarch_log2("rarch_main: '%s' does not exist, so creating it\n", new_path);
6070+
if (mkdir(new_path, 0775) != 0)
6071+
{
6072+
retroarch_log2("mkdir failed");
6073+
}
6074+
}
6075+
}
6076+
}
6077+
6078+
home = getenv("HOME");
6079+
xdg_config_home = getenv("XDG_CONFIG_HOME");
6080+
6081+
retroarch_log2("rarch_main: NOW - HOME='%s', XDG_CONFIG_HOME='%s'\n",
6082+
home ? home : "(null)",
6083+
xdg_config_home ? xdg_config_home : "(null)");
6084+
59996085
/* compatibility with webOS 3 - 5 */
60006086
if (getenv("EGL_PLATFORM") == NULL)
60016087
setenv("EGL_PLATFORM", "wayland", 0);

0 commit comments

Comments
 (0)