Constructs a path in the local file system's syntax newPath: stores the constructed path absolutePathHeader: absolute path on which the sub directories will be appended (specified in local file system syntax) takes a variable number of subdirectories which will be concatenated on to the path the last argument in the list of sub dirs *MUST* be NULL to terminate the list
| 237 | // takes a variable number of subdirectories which will be concatenated on to the path |
| 238 | // the last argument in the list of sub dirs *MUST* be NULL to terminate the list |
| 239 | void ddio_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) { |
| 240 | const char delimiter = '\\'; |
| 241 | va_list args; |
| 242 | char *currentDir = NULL; |
| 243 | int pathLength = 0; |
| 244 | |
| 245 | assert(newPath); |
| 246 | assert(absolutePathHeader); |
| 247 | assert(subDir); |
| 248 | |
| 249 | if (newPath != absolutePathHeader) { |
| 250 | strcpy(newPath, absolutePathHeader); |
| 251 | } |
| 252 | |
| 253 | // Add the first sub directory |
| 254 | pathLength = strlen(newPath); |
| 255 | if (newPath[pathLength - 1] != delimiter) { |
| 256 | newPath[pathLength] = delimiter; // add the delimiter |
| 257 | newPath[pathLength + 1] = 0; // terminate the string |
| 258 | } |
| 259 | strcat(newPath, subDir); |
| 260 | |
| 261 | // Add the additional subdirectories |
| 262 | va_start(args, subDir); |
| 263 | while ((currentDir = va_arg(args, char *)) != NULL) { |
| 264 | pathLength = strlen(newPath); |
| 265 | if (newPath[pathLength - 1] != delimiter) { |
| 266 | newPath[pathLength] = delimiter; // add the delimiter |
| 267 | newPath[pathLength + 1] = 0; // terminate the string |
| 268 | } |
| 269 | strcat(newPath, currentDir); |
| 270 | } |
| 271 | va_end(args); |
| 272 | } |
| 273 | |
| 274 | bool ddio_GetTempFileName(const char *basedir, const char *prefix, char *filename) { |
| 275 |
no outgoing calls
no test coverage detected