Page 1 of 1

DriveSpaceFree

Posted: 26 Sep 2022, 19:37
by iPhilip
The documentation for DriveSpaceFree states:
https://www.autohotkey.com/docs/commands/DriveSpaceFree.htm wrote:Path of drive to receive information from. Since...
Internally, that command uses the GetDiskFreeSpaceEx function and its documentation states:
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexw wrote:This parameter does not have to specify the root directory on a disk. The function accepts any directory on a disk.
Thus, I recommend the following change to the DriveSpaceFree documentation page:
https://www.autohotkey.com/docs/commands/DriveSpaceFree.htm wrote:Path of drive (or any directory on the drive) to receive information from. Since...
To help the reader, the following line could be added at the bottom of Example #1:

Re: DriveSpaceFree

Posted: 27 Sep 2022, 03:46
by Ragnar
That's why this page talks about path, not explicitly about drive letters, root directory or similar. Path implies paths to directories.

Re: DriveSpaceFree

Posted: 27 Sep 2022, 18:59
by iPhilip
Ragnar wrote:
27 Sep 2022, 03:46
That's why this page talks about path, not explicitly about drive letters, root directory or similar. Path implies paths to directories.
@Ragnar, Thank you for reading my post and commenting on it. Respectfully, I disagree with your point of view. I think adding language that makes things clearer is always a good thing.

When I read
I think of strings such as C:\, D:\, etc. not C:\Windows, C:\Users\User\Documents, etc. Furthermore, the example at the bottom of the documentation page
reinforces that thinking.

In my opinion, adding the extra 6 words would help to clarify that the path to any folder on the drive can be used as a parameter.

At the end, this is just a suggestion to improve the documentation. Feel free to ignore it.

Re: DriveSpaceFree

Posted: 27 Sep 2022, 19:34
by TAC109
As the start of the path must have the drive letter (e.g. C:\) why would anyone go to the trouble of finding a directory on the disk so that they could include the directory in the parameter, rather than just using the root directory as shown above?

I don’t understand the purpose of this suggested change.

Cheers

Re: DriveSpaceFree

Posted: 27 Sep 2022, 20:02
by iPhilip
TAC109 wrote:
27 Sep 2022, 19:34
As the start of the path must have the drive letter (e.g. C:\) why would anyone go to the trouble of finding a directory on the disk so that they could include the directory in the parameter, rather than just using the root directory as shown above?

I don’t understand the purpose of this suggested change.

Cheers
@TAC109, Thank you for asking. Here is the case that led me to this issue: say you have a directory path (user specified) and want to know the free space of the drive associated with that directory. Before I knew that a folder was allowed, I did the following:

Code: Select all

Folder := A_MyDocuments
SplitPath, Folder, , , , , OutDrive
DriveSpaceFree, FreeSpace, % OutDrive
With the new awareness, I can skip the SplitPath command:

Code: Select all

Folder := A_MyDocuments
DriveSpaceFree, FreeSpace, % Folder

Re: DriveSpaceFree

Posted: 27 Sep 2022, 22:24
by TAC109

Code: Select all

Folder := A_MyDocuments
DriveSpaceFree, FreeSpace, % SubStr(Folder,1,3)

Re: DriveSpaceFree

Posted: 28 Sep 2022, 03:04
by lexikos
For contrast, the DriveGetSpaceFree (v2) documentation clarifies this repeatedly.

It also explains why these functions accept a path rather than a drive letter.
In general, Path can be any path. Since NTFS supports mounted volumes and directory junctions, different paths with the same drive letter can produce different amounts of free space.
Source: DriveGetSpaceFree - Syntax & Usage | AutoHotkey v2
SubStr(A_MyDocuments,1,3) will not work if the Documents folder has been redirected to a UNC path, which is not uncommon in some business networks.

Re: DriveSpaceFree  Topic is solved

Posted: 28 Sep 2022, 07:13
by Ragnar
I've adjusted the Drive*.htm files to the v2 equivalents, which should fulfill @iPhilip's request. Changes added in PR #570.

Re: DriveSpaceFree

Posted: 28 Sep 2022, 11:29
by iPhilip
Ragnar wrote:
28 Sep 2022, 07:13
I've adjusted the Drive*.htm files to the v2 equivalents, which should fulfill @iPhilip's request. Changes added in PR #570.
Thank you.