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

Function fxRealFilePathIf

xs/tools/xsc.c:198–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198txString fxRealFilePathIf(txParser* parser, txString path)
199{
200#if mxWindows
201 char buffer[C_PATH_MAX];
202 DWORD attributes;
203 if (_fullpath(buffer, path, C_PATH_MAX) != NULL) {
204 attributes = GetFileAttributes(buffer);
205 if ((attributes != 0xFFFFFFFF) && (!(attributes & FILE_ATTRIBUTE_DIRECTORY))) {
206 return fxNewParserString(parser, buffer, mxStringLength(buffer));
207 }
208 }
209#else
210 char buffer[C_PATH_MAX];
211 struct stat a_stat;
212 if (realpath(path, buffer) != NULL) {
213 if (stat(buffer, &a_stat) == 0) {
214 if (S_ISREG(a_stat.st_mode)) {
215 return fxNewParserString(parser, buffer, mxStringLength(buffer));
216 }
217 }
218 }
219#endif
220 return NULL;
221}
222
223
224void fxWriteBuffer(txScript* script, FILE* file, txString name, txU1* buffer, txSize size)

Callers 1

mainFunction · 0.85

Calls 2

fxNewParserStringFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected