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

Function fxRealFilePath

xs/tools/xsc.c:171–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171txString fxRealFilePath(txParser* parser, txString path)
172{
173#if mxWindows
174 char buffer[C_PATH_MAX];
175 DWORD attributes;
176 if (_fullpath(buffer, path, C_PATH_MAX) != NULL) {
177 attributes = GetFileAttributes(buffer);
178 if ((attributes != 0xFFFFFFFF) && (!(attributes & FILE_ATTRIBUTE_DIRECTORY))) {
179 return fxNewParserString(parser, buffer, mxStringLength(buffer));
180 }
181 }
182#else
183 char buffer[C_PATH_MAX];
184 struct stat a_stat;
185 if (realpath(path, buffer) != NULL) {
186 if (stat(buffer, &a_stat) == 0) {
187 if (S_ISREG(a_stat.st_mode)) {
188 return fxNewParserString(parser, buffer, mxStringLength(buffer));
189 }
190 }
191 }
192#endif
193 parser->error = C_EINVAL;
194 fprintf(stderr, "# file not found: %s!\n", path);
195 c_longjmp(parser->firstJump->jmp_buf, 1);
196}
197
198txString fxRealFilePathIf(txParser* parser, txString path)
199{

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