14 if (!value || (!allow_empty && value_len == 0) || value_len >= out_size) {
18 memcpy(out, value, value_len);
19 out[value_len] =
'\0';
32 const size_t path_len = sdslen(path);
33 size_t len = path_len;
38 if (len == path_len) {
47 sdsrange(path, 0, (
int)len - 1);
51 if (ch >=
'A' && ch <=
'Z') {
52 return (
char)(ch -
'A' +
'a');
59 for (
size_t i = 0; i <
n; i++) {
69 return copy_path_value(out, out_size, value, value ? strlen(value) : 0,
false);
73 return copy_path_value(out, out_size, value, value ? sdslen(value) : 0,
true);
77 return ch ==
'\\' || ch ==
'/';
99 return segment_len == 0 || (segment_len == 1 && segment[0] ==
'.')
100 || (segment_len == 2 && segment[0] ==
'.' && segment[1] ==
'.');
104 return path && path[0] && path[1] ==
':';
112 const char *p = path;
136 sds normalized = sdsempty();
141 bool previous_separator =
false;
142 for (
const char *p = path; *p; p++) {
144 const char ch = is_separator ?
'/' : *p;
146 if (previous_separator) {
150 previous_separator =
true;
152 previous_separator =
false;
168 const bool matches = normalized_lhs && normalized_rhs
169 && strcmp(normalized_lhs, normalized_rhs) == 0;
170 sdsfree(normalized_lhs);
171 sdsfree(normalized_rhs);
188 return GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES;
193 DWORD len = GetCurrentDirectoryA((
DWORD)
sizeof(cwd), cwd);
194 if (len == 0 || len >=
sizeof(cwd)) {
203 const DWORD len = GetModuleFileNameA((HMODULE)module, path, (
DWORD)
sizeof(path));
204 if (len == 0 || len >=
sizeof(path)) {
208 char *last_sep = strrchr(path,
'\\');
237 sds resolved = sdsnew(base_dir ? base_dir :
"");
263 sds next = sdscatlen(*path, &ch, 1);
277 const size_t len = sdslen(*path);
284 sds next = sdscat(*path, segment);
DTTR_Graphics_COM_Direct3DDevice7 void *status DTTR_Graphics_COM_Direct3DDevice7 DWORD DWORD void DWORD n
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL
#define DTTR_PATH_NATIVE_SEPARATOR
static const char * skip_dot_separators(const char *path)
bool DTTR_Path_AsciiIeqN(const char *lhs, const char *rhs, size_t n)
sds DTTR_Path_NativeRoot(const char *path, const char **rest)
bool DTTR_Path_IsSeparator(char ch)
static void trim_trailing_separators(sds path)
const char * DTTR_Path_SkipSeparators(const char *path)
sds DTTR_Path_CurrentDir()
sds DTTR_Path_ModuleSibling(void *module, const char *relative_path)
bool DTTR_Path_IsRelativeSegment(const char *segment, size_t segment_len)
bool DTTR_Path_CopyString(char *out, size_t out_size, const char *value)
bool DTTR_Path_CopySds(char *out, size_t out_size, sds value)
bool DTTR_Path_ExactExists(const char *path)
bool DTTR_Path_AppendChar(sds *path, char ch)
bool DTTR_Path_IsWindowsAbsolute(const char *path)
sds DTTR_Path_ResolveRelativeTo(const char *base_dir, const char *path)
static bool path_has_windows_drive_prefix(const char *path)
sds DTTR_Path_ModuleDir(void *module)
bool DTTR_Path_IsAnyAbsolute(const char *path)
static bool copy_path_value(char *out, size_t out_size, const char *value, size_t value_len, bool allow_empty)
bool DTTR_Path_AppendSeparator(sds *path, char separator)
bool DTTR_Path_AppendSegment(sds *path, const char *segment, char separator)
static sds normalize_path_for_compare(const char *path)
char DTTR_Path_AsciiLower(char ch)
size_t DTTR_Path_SegmentLen(const char *path)
bool DTTR_Path_IsSafeRelative(const char *path)
bool DTTR_Path_MatchesNormalized(const char *lhs, const char *rhs)