| 436 | } |
| 437 | |
| 438 | static int dfs_win32_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) |
| 439 | { |
| 440 | WIN32_FIND_DATA fileInfo; |
| 441 | HANDLE hFind; |
| 442 | char *fp; |
| 443 | fp = winpath_dirdup(WIN32_DIRDISK_ROOT, path); |
| 444 | if (fp == RT_NULL) |
| 445 | { |
| 446 | rt_kprintf("out of memory.\n"); |
| 447 | return -ENOMEM; |
| 448 | } |
| 449 | |
| 450 | hFind = FindFirstFile(fp, &fileInfo); |
| 451 | rt_free(fp); |
| 452 | |
| 453 | if (hFind == INVALID_HANDLE_VALUE) |
| 454 | goto __err; |
| 455 | |
| 456 | st->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH | |
| 457 | S_IWUSR | S_IWGRP | S_IWOTH; |
| 458 | |
| 459 | /* convert file info to dfs stat structure */ |
| 460 | if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| 461 | { |
| 462 | st->st_mode &= ~S_IFREG; |
| 463 | st->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; |
| 464 | } |
| 465 | |
| 466 | st->st_dev = 0; |
| 467 | st->st_size = fileInfo.nFileSizeLow; |
| 468 | |
| 469 | /* get st_mtime. */ |
| 470 | { |
| 471 | LARGE_INTEGER time_tmp; |
| 472 | time_tmp.LowPart = fileInfo.ftLastWriteTime.dwLowDateTime; |
| 473 | time_tmp.HighPart = fileInfo.ftLastWriteTime.dwHighDateTime; |
| 474 | |
| 475 | /* removes the diff between 1970 and 1601. */ |
| 476 | time_tmp.QuadPart -= 11644473600000 * 10000; |
| 477 | /* converts back from 100-nanoseconds to seconds. */ |
| 478 | time_tmp.QuadPart /= 10UL * 1000 * 1000; |
| 479 | |
| 480 | st->st_mtime = time_tmp.QuadPart; |
| 481 | } |
| 482 | |
| 483 | FindClose(hFind); |
| 484 | |
| 485 | return 0; |
| 486 | |
| 487 | __err: |
| 488 | return win32_result_to_dfs(GetLastError()); |
| 489 | } |
| 490 | |
| 491 | static const struct dfs_file_ops dfs_win32_file_ops = |
| 492 | { |
nothing calls this directly
no test coverage detected