| 140 | } |
| 141 | |
| 142 | txString fxRealDirectoryPath(txParser* parser, txString path) |
| 143 | { |
| 144 | #if mxWindows |
| 145 | char buffer[C_PATH_MAX]; |
| 146 | DWORD attributes; |
| 147 | if (_fullpath(buffer, path, C_PATH_MAX) != NULL) { |
| 148 | attributes = GetFileAttributes(buffer); |
| 149 | if ((attributes != 0xFFFFFFFF) && (attributes & FILE_ATTRIBUTE_DIRECTORY)) { |
| 150 | strcat(buffer, "\\"); |
| 151 | return fxNewParserString(parser, buffer, mxStringLength(buffer)); |
| 152 | } |
| 153 | } |
| 154 | #else |
| 155 | char buffer[C_PATH_MAX]; |
| 156 | struct stat a_stat; |
| 157 | if (realpath(path, buffer) != NULL) { |
| 158 | if (stat(buffer, &a_stat) == 0) { |
| 159 | if (S_ISDIR(a_stat.st_mode)) { |
| 160 | strcat(buffer, "/"); |
| 161 | return fxNewParserString(parser, buffer, mxStringLength(buffer)); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | #endif |
| 166 | parser->error = C_EINVAL; |
| 167 | fprintf(stderr, "# directory not found: %s!\n", path); |
| 168 | c_longjmp(parser->firstJump->jmp_buf, 1); |
| 169 | } |
| 170 | |
| 171 | txString fxRealFilePath(txParser* parser, txString path) |
| 172 | { |
no test coverage detected