MCPcopy Create free account
hub / github.com/TurningWheel/Barony / completePath

Function completePath

src/files.cpp:2113–2152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2111
2112
2113bool 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
2154File* openDataFile(const char * const filename, const char * const mode) {
2155 char path[PATH_MAX];

Callers 15

saveAllScoresJSONFunction · 0.85
saveAllScoresFunction · 0.85
loadAllScoresJSONFunction · 0.85
loadAllScoresFunction · 0.85
deleteSaveGameFunction · 0.85
saveGameExistsFunction · 0.85
getSaveGameInfoFunction · 0.85
saveGameFunction · 0.85
readFromFileMethod · 0.85
writeToFileMethod · 0.85
writeUnlocksSaveDataMethod · 0.85
writeItemsSaveDataMethod · 0.85

Calls 3

isCurrentHolidayFunction · 0.85
getCurrentHolidayFunction · 0.85
dataPathExistsFunction · 0.85

Tested by

no test coverage detected