Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sets the file_info struct for the file with the given handle. This sets the
- // file size, creation time, etc.
- NTSTATUS CloudStorageFs::GetFileInfoHelper(const FileDescription& file_description, Fsp::FileSystemBase::FileInfo* file_info) {
- BY_HANDLE_FILE_INFORMATION by_handle_file_info;
- if (!GetFileInformationByHandle(file_description.handle, &by_handle_file_info)) {
- return FspNtStatusFromWin32(GetLastError());
- }
- file_info->FileAttributes = by_handle_file_info.dwFileAttributes;
- file_info->ReparseTag = 0;
- file_info->AllocationSize = RoundToAllocationUnit(file_info->FileSize);
- file_info->CreationTime = GetUint64FromLowAndHigh(
- by_handle_file_info.ftCreationTime.dwLowDateTime,
- by_handle_file_info.ftCreationTime.dwHighDateTime);
- file_info->LastAccessTime = GetUint64FromLowAndHigh(
- by_handle_file_info.ftLastAccessTime.dwLowDateTime,
- by_handle_file_info.ftLastAccessTime.dwHighDateTime);
- file_info->LastWriteTime = GetUint64FromLowAndHigh(
- by_handle_file_info.ftLastWriteTime.dwLowDateTime,
- by_handle_file_info.ftLastWriteTime.dwHighDateTime);
- file_info->ChangeTime = file_info->LastWriteTime;
- file_info->IndexNumber = 0;
- file_info->HardLinks = 0;
- // If a ghost file, we have to pull the size from GCS.
- if (file_description.is_ghost) {
- std::uint64_t size;
- bool exists = gcs_client_.GetSize(file_description.name, &size);
- if (!exists) {
- return ERROR_FILE_NOT_FOUND;
- }
- file_info->FileSize = size;
- return STATUS_SUCCESS;
- }
- // Otherwise get the file size as normal.
- file_info->FileSize = GetUint64FromLowAndHigh(
- by_handle_file_info.nFileSizeLow, by_handle_file_info.nFileSizeHigh);
- // Finally set directory attributes if applicable.
- if (by_handle_file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- file_info->FileAttributes =
- file_info->FileAttributes | FILE_ATTRIBUTE_DIRECTORY;
- }
- return STATUS_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement