Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with max path size on Windows #5

Open
Mart-Bogdan opened this issue Oct 27, 2021 · 3 comments · May be fixed by #9
Open

Deal with max path size on Windows #5

Mart-Bogdan opened this issue Oct 27, 2021 · 3 comments · May be fixed by #9

Comments

@Mart-Bogdan
Copy link
Contributor

Mart-Bogdan commented Oct 27, 2021

On windows maximum length for a path is MAX_PATH, which is defined as 260 characters.

There are some ways to define path in a specific way, so it would allow 32,767 characters is approximate.

It could work with our API call on Windows 10, Version 1607, and Later if Registry key is configured, or APP manifest provided.

I assume it's better to stick with "\\?\" prefix and support a wider range of Windows versions.

links:

Creating this issue as I've found TODO in code.

@Mart-Bogdan
Copy link
Contributor Author

I think the hard part would be to test and check all corner cases.

Perhaps I'll be able to take this issue but can't guarantee.

Mart-Bogdan added a commit to Mart-Bogdan/dirstat-rs that referenced this issue Apr 23, 2022
* Manually implemented windows File Namespace name generation

* added some unit tests

closes scullionw#5
Mart-Bogdan added a commit to Mart-Bogdan/dirstat-rs that referenced this issue Apr 23, 2022
* Manually implemented windows File Namespace name generation

* added some unit tests

closes scullionw#5
@Mart-Bogdan
Copy link
Contributor Author

I'm going to finish PR soon. I've got time to dig into Rust.

My initial take was to fix filename generation, and I've done it. But now I see that it can be achieved using GetFileInformationByHandleEx , as it accepts HANDLE and gives various info form file (we already are using similar funtion for getting information on regular size). Using handles must be marginally faster.

Also I've found other issues with apparent size on Windows platform: it shows size inconsistent with windows explorer for small files. Windows explorer shows 0, which means it's stored inside parent directory, but current solution shows size. And also we don't calculate size of alternate file streams, but that calculation can be costly on performance.

I think that inconsitencies can be addressed later.

P.S. source material: https://devblogs.microsoft.com/oldnewthing/20160427-00/?p=93365

@Mart-Bogdan
Copy link
Contributor Author

Fun fact. Comporssed size reports incorrectly:
image

File: test-data\b4000_rand_c
 FILE_STANDARD_INFO { AllocationSize: 8192, EndOfFile: 4000, NumberOfLinks: 1, DeletePending: 0, Directory: 0 }
 FILE_COMPRESSION_INFO { CompressedFileSize: 4000, CompressionFormat: 2, CompressionUnitShift: 16, ChunkShift: 12, ClusterShift: 12, Reserved: [0, 0, 0] }
 GetCompressedFileSizeW: 4000

AllocationSize struct is most reliable (when calling GetFileInformationByHandleEx)

but it gives minuscule discrepancy on small files

File: test-data\b23_rand_c
FILE_STANDARD_INFO { AllocationSize: 24, EndOfFile: 23, NumberOfLinks: 1, DeletePending: 0, Directory: 0 }
FILE_COMPRESSION_INFO { CompressedFileSize: 23, CompressionFormat: 2, CompressionUnitShift: 16, ChunkShift: 12, ClusterShift: 12, Reserved: [0, 0, 0] }
comp_size: 23

24 bytes instead of 23. But I think it's not a big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant