DriveSpaceFree Topic is solved

Share your ideas as to how the documentation can be improved.
iPhilip
Posts: 801
Joined: 02 Oct 2013, 12:21

DriveSpaceFree

Post by iPhilip » 26 Sep 2022, 19:37

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:
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

User avatar
Ragnar
Posts: 611
Joined: 30 Sep 2013, 15:25

Re: DriveSpaceFree

Post by Ragnar » 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.

iPhilip
Posts: 801
Joined: 02 Oct 2013, 12:21

Re: DriveSpaceFree

Post by iPhilip » 27 Sep 2022, 18:59

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.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

TAC109
Posts: 1098
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: DriveSpaceFree

Post by TAC109 » 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
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

iPhilip
Posts: 801
Joined: 02 Oct 2013, 12:21

Re: DriveSpaceFree

Post by iPhilip » 27 Sep 2022, 20:02

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
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

TAC109
Posts: 1098
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: DriveSpaceFree

Post by TAC109 » 27 Sep 2022, 22:24

Code: Select all

Folder := A_MyDocuments
DriveSpaceFree, FreeSpace, % SubStr(Folder,1,3)
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Re: DriveSpaceFree

Post by lexikos » 28 Sep 2022, 03:04

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.

User avatar
Ragnar
Posts: 611
Joined: 30 Sep 2013, 15:25

Re: DriveSpaceFree  Topic is solved

Post by Ragnar » 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.

iPhilip
Posts: 801
Joined: 02 Oct 2013, 12:21

Re: DriveSpaceFree

Post by iPhilip » 28 Sep 2022, 11:29

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.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Post Reply

Return to “Suggestions on Documentation Improvements”