int32_t omrfile_attr(struct OMRPortLibrary *portLibrary, const char *path) { struct stat buffer; Trc_PRT_file_attr_Entry(path); /* Neutrino does not handle NULL for stat */ if (stat(path, &buffer)) { int32_t setError = portLibrary->error_set_last_error(portLibrary, errno, findError(errno)); Trc_PRT_file_attr_ExitFail(setError); return setError; } if (S_ISDIR(buffer.st_mode)) { Trc_PRT_file_attr_ExitDir(EsIsDir); return EsIsDir; } Trc_PRT_file_attr_ExitFile(EsIsFile); return EsIsFile; }
int32_t omrfile_attr(struct OMRPortLibrary *portLibrary, const char *path) { DWORD result; wchar_t unicodeBuffer[UNICODE_BUFFER_SIZE], *unicodePath; Trc_PRT_file_attr_Entry(path); /* Convert the filename from UTF8 to Unicode */ unicodePath = file_get_unicode_path(portLibrary, path, unicodeBuffer, UNICODE_BUFFER_SIZE); if (NULL == unicodePath) { return -1; } result = GetFileAttributesW(unicodePath); if (unicodeBuffer != unicodePath) { portLibrary->mem_free_memory(portLibrary, unicodePath); } if (result == INVALID_FILE_ATTRIBUTES) { int32_t setError; result = GetLastError(); setError = portLibrary->error_set_last_error(portLibrary, result, findError(result)); Trc_PRT_file_attr_ExitFail(setError); return setError; } if (result & FILE_ATTRIBUTE_DIRECTORY) { Trc_PRT_file_attr_ExitDir(EsIsDir); return EsIsDir; } /* otherwise assume it's a normal file */ Trc_PRT_file_attr_ExitFile(EsIsFile); return EsIsFile; }