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
| 126 | // takes a variable number of subdirectories which will be concatenated on to the path |
| 127 | // the last argument in the list of sub dirs *MUST* be NULL to terminate the list |
| 128 | static void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) { |
| 129 | const char delimiter = '\\'; |
| 130 | va_list args; |
| 131 | char *currentDir = NULL; |
| 132 | int pathLength = 0; |
| 133 | |
| 134 | assert(newPath); |
| 135 | assert(absolutePathHeader); |
| 136 | assert(subDir); |
| 137 | |
| 138 | if (newPath != absolutePathHeader) { |
| 139 | strcpy(newPath, absolutePathHeader); |
| 140 | } |
| 141 | // Add the first sub directory |
| 142 | pathLength = strlen(newPath); |
| 143 | if (newPath[pathLength - 1] != delimiter) { |
| 144 | newPath[pathLength] = delimiter; // add the delimiter |
| 145 | newPath[pathLength + 1] = 0; // terminate the string |
| 146 | } |
| 147 | strcat(newPath, subDir); |
| 148 | |
| 149 | // Add the additional subdirectories |
| 150 | va_start(args, subDir); |
| 151 | while ((currentDir = va_arg(args, char *)) != NULL) { |
| 152 | pathLength = strlen(newPath); |
| 153 | if (newPath[pathLength - 1] != delimiter) { |
| 154 | newPath[pathLength] = delimiter; // add the delimiter |
| 155 | newPath[pathLength + 1] = 0; // terminate the string |
| 156 | } |
| 157 | strcat(newPath, currentDir); |
| 158 | } |
| 159 | va_end(args); |
| 160 | } |
| 161 | #elif defined(POSIX) |
| 162 | // Split a pathname into its component parts |
| 163 | static void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { |
no outgoing calls
no test coverage detected