| 2111 | |
| 2112 | |
| 2113 | bool completePath(char *dest, const char * const filename, const char *base) { |
| 2114 | if (!(filename && filename[0])) { |
| 2115 | return false; |
| 2116 | } |
| 2117 | |
| 2118 | // Already absolute |
| 2119 | if (filename[0] == '/') { |
| 2120 | strcpy(dest, filename); |
| 2121 | return true; |
| 2122 | } |
| 2123 | |
| 2124 | #ifdef NINTENDO |
| 2125 | // Already absolute on nintendo |
| 2126 | if (strncmp(filename, base, strlen(base)) == 0) { |
| 2127 | strcpy(dest, filename); |
| 2128 | return true; |
| 2129 | } |
| 2130 | #endif |
| 2131 | |
| 2132 | #ifdef WINDOWS |
| 2133 | // Already absolute (drive letter in path) |
| 2134 | if ( filename[1] == ':' ) { |
| 2135 | strncpy(dest, filename, PATH_MAX); |
| 2136 | return true; |
| 2137 | } |
| 2138 | #endif |
| 2139 | |
| 2140 | if (base == datadir && isCurrentHoliday()) { |
| 2141 | const auto holiday = getCurrentHoliday(); |
| 2142 | const auto holiday_dir = holidayThemeDirs[holiday]; |
| 2143 | assert(holiday_dir[0]); |
| 2144 | snprintf(dest, PATH_MAX, "%s/%s%s", base, holiday_dir, filename); |
| 2145 | if (!dataPathExists(dest, false)) { |
| 2146 | snprintf(dest, PATH_MAX, "%s/%s", base, filename); |
| 2147 | } |
| 2148 | } else { |
| 2149 | snprintf(dest, PATH_MAX, "%s/%s", base, filename); |
| 2150 | } |
| 2151 | return true; |
| 2152 | } |
| 2153 | |
| 2154 | File* openDataFile(const char * const filename, const char * const mode) { |
| 2155 | char path[PATH_MAX]; |
no test coverage detected