internal static bool GetFileAttributesEx(String name, int fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation) { if (name == null) { return(false); } unsafe { var data = new stat_data(); fixed(byte *filename_ascii = ToAsciiString(name)) { var returnCode = stat(filename_ascii, &data.st_dev); if (returnCode != 0) { return(false); } var fileAttributes = FILE_ATTRIBUTE_NORMAL; // if this is folder, return false if ((data.st_mode & S_IFMT) == S_IFDIR) { fileAttributes = FILE_ATTRIBUTE_DIRECTORY; } lpFileInformation.fileAttributes = (int)fileAttributes; lpFileInformation.fileSizeLow = data.st_size; lpFileInformation.fileSizeHigh = 0; return(true); } } }
internal static int GetFileSize(SafeFileHandle hFile, out int highSize) { highSize = 0; unsafe { var data = new stat_data(); var returnCode = fstat(hFile.DangerousGetHandle().ToInt32(), &data.st_dev); if (returnCode != 0) { return(0); } return(data.st_size); } }