| 103 | } |
| 104 | |
| 105 | void Dirname(const char* path, char* out, uint32_t out_size) |
| 106 | { |
| 107 | char buf[DMPATH_MAX_PATH]; |
| 108 | Normalize(path, buf, sizeof(buf)); |
| 109 | |
| 110 | if (strcmp(buf, ".") == 0) |
| 111 | { |
| 112 | // Special case |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | char* last_slash = strrchr(buf, '/'); |
| 117 | if (last_slash) |
| 118 | { |
| 119 | if (last_slash != buf) |
| 120 | { |
| 121 | // Truncate string if slash found isn't |
| 122 | // the first character (edge case for path "/") |
| 123 | *last_slash = '\0'; |
| 124 | } |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | buf[0] = '\0'; |
| 129 | } |
| 130 | } |
| 131 | dmStrlCpy(out, buf, out_size); |
| 132 | } |
| 133 | |
| 134 | void Concat(const char* path1, const char* path2, char* out, uint32_t out_size) |
| 135 | { |