PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info) { int rv; BY_HANDLE_FILE_INFORMATION hinfo; rv = GetFileInformationByHandle((HANDLE)fd->secret->md.osfd, &hinfo); if (rv == FALSE) { _PR_MD_MAP_FSTAT_ERROR(GetLastError()); return -1; } if (hinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) info->type = PR_FILE_DIRECTORY; else info->type = PR_FILE_FILE; info->size = hinfo.nFileSizeHigh; info->size = (info->size << 32) + hinfo.nFileSizeLow; _PR_FileTimeToPRTime(&hinfo.ftLastWriteTime, &(info->modifyTime) ); _PR_FileTimeToPRTime(&hinfo.ftCreationTime, &(info->creationTime) ); return 0; }
PR_IMPLEMENT(PRInt32) _amigaos_Getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info) { struct stat sb; PRInt32 rv; rv = fstat(fd->secret->md.osfd, &sb); if (rv < 0) { _PR_MD_MAP_FSTAT_ERROR(_MD_ERRNO()); } else if (NULL != info) { rv = _amigaos_convert_stat_to_fileinfo64(&sb, info); } return rv; }
PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info) { /* For once, the VAC compiler/library did a nice thing. * The file handle used by the C runtime is the same one * returned by the OS when you call DosOpen(). This means * that you can take an OS HFILE and use it with C file * functions. The only caveat is that you have to call * _setmode() first to initialize some junk. This is * immensely useful because I did not have a clue how to * implement this function otherwise. The windows folks * took the source from the Microsoft C library source, but * IBM wasn't kind enough to ship the source with VAC. * On second thought, the needed function could probably * be gotten from the OS/2 GNU library source, but the * point is now moot. */ struct stat hinfo; PRInt64 s, s2us; _setmode(fd->secret->md.osfd, O_BINARY); if(fstat((int)fd->secret->md.osfd, &hinfo) != NO_ERROR) { _PR_MD_MAP_FSTAT_ERROR(errno); return -1; } if (hinfo.st_mode & S_IFDIR) info->type = PR_FILE_DIRECTORY; else info->type = PR_FILE_FILE; info->size = hinfo.st_size; LL_I2L(s2us, PR_USEC_PER_SEC); LL_I2L(s, hinfo.st_mtime); LL_MUL(s, s, s2us); info->modifyTime = s; LL_I2L(s, hinfo.st_ctime); LL_MUL(s, s, s2us); info->creationTime = s; return 0; }