summaryrefslogtreecommitdiff
path: root/ted-base.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-18 12:11:03 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-18 12:11:03 -0500
commit44f374480888812456892f59a9f25f475e564819 (patch)
tree444cc5b5547fca9a0bad720ca8a4c49c14a63092 /ted-base.c
parent6db2ef3ce69c17f6291b30fcb9278e7d4df53c71 (diff)
got windows build to partly work
Diffstat (limited to 'ted-base.c')
-rw-r--r--ted-base.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/ted-base.c b/ted-base.c
index ca0fbbb..ab6ec98 100644
--- a/ted-base.c
+++ b/ted-base.c
@@ -1,4 +1,3 @@
-
// this is a macro so we get -Wformat warnings
#define ted_seterr(buffer, ...) \
snprintf(ted->error, sizeof ted->error - 1, __VA_ARGS__)
@@ -35,34 +34,32 @@ static void *ted_realloc(Ted *ted, void *p, size_t new_size) {
// should the working directory be searched for files? set to true if the executable isn't "installed"
static bool ted_search_cwd = false;
+static char const ted_global_data_dir[] =
#if _WIN32
-// @TODO
+ "C:\\Program Files\\ted";
#else
-static char const *const ted_global_data_dir = "/usr/share/ted";
+ "/usr/share/ted";
#endif
+static char ted_local_data_dir[TED_PATH_MAX]; // filled out in main()
// Check the various places a file could be, and return the full path.
static Status ted_get_file(char const *name, char *out, size_t outsz) {
-#if _WIN32
- #error "@TODO(windows)"
-#else
if (ted_search_cwd && fs_file_exists(name)) {
// check in current working directory
str_cpy(out, outsz, name);
return true;
}
-
- char *home = getenv("HOME");
- if (home) {
- str_printf(out, outsz, "%s/.local/share/ted/%s", home, name);
- if (!fs_file_exists(out)) {
- str_printf(out, outsz, "%s/%s", ted_global_data_dir, name);
- if (!fs_file_exists(out))
- return false;
- }
+ if (*ted_local_data_dir) {
+ str_printf(out, outsz, "%s" PATH_SEPARATOR "%s", ted_local_data_dir, name);
+ if (fs_file_exists(out))
+ return true;
}
- return true;
-#endif
+ if (*ted_global_data_dir) {
+ str_printf(out, outsz, "%s" PATH_SEPARATOR "%s", ted_global_data_dir, name);
+ if (fs_file_exists(out))
+ return true;
+ }
+ return false;
}
static void ted_load_font(Ted *ted) {