| 1430 | } |
| 1431 | |
| 1432 | static NTSTATUS DOKAN_CALLBACK CryptSetEndOfFile( |
| 1433 | LPCWSTR FileName, LONGLONG ByteOffset, PDOKAN_FILE_INFO DokanFileInfo) { |
| 1434 | FileNameEnc filePath(DokanFileInfo, FileName); |
| 1435 | HANDLE handle; |
| 1436 | |
| 1437 | DbgPrint(L"SetEndOfFile %s, %I64d\n", FileName, ByteOffset); |
| 1438 | |
| 1439 | handle = (HANDLE)DokanFileInfo->Context; |
| 1440 | if (!handle || handle == INVALID_HANDLE_VALUE) { |
| 1441 | DbgPrint(L"\tinvalid handle\n\n"); |
| 1442 | return STATUS_INVALID_HANDLE; |
| 1443 | } |
| 1444 | |
| 1445 | CryptFile *file = CryptFile::NewInstance(GetContext()); |
| 1446 | |
| 1447 | if (file->Associate(GetContext(), handle, FileName, true)) { |
| 1448 | if (!file->SetEndOfFile(ByteOffset)) { |
| 1449 | DWORD error = GetLastError(); |
| 1450 | DbgPrint(L"\tSetEndOfFile error code = %d\n\n", error); |
| 1451 | delete file; |
| 1452 | return ToNtStatus(error); |
| 1453 | } |
| 1454 | } else { |
| 1455 | delete file; |
| 1456 | DbgPrint(L"\tSetEndOfFile unable to associate handle %I64x\n", handle); |
| 1457 | return STATUS_ACCESS_DENIED; |
| 1458 | } |
| 1459 | |
| 1460 | delete file; |
| 1461 | |
| 1462 | return STATUS_SUCCESS; |
| 1463 | } |
| 1464 | |
| 1465 | static NTSTATUS DOKAN_CALLBACK CryptSetAllocationSize( |
| 1466 | LPCWSTR FileName, LONGLONG AllocSize, PDOKAN_FILE_INFO DokanFileInfo) { |
nothing calls this directly
no test coverage detected