MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxRealDirectoryPath

Function fxRealDirectoryPath

xs/tools/xsc.c:142–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142txString 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
171txString fxRealFilePath(txParser* parser, txString path)
172{

Callers 3

mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70

Calls 2

fxNewParserStringFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected