Jump to content

DriveGetSize and DriveSpaceTotal not match


Darien
 Share

Recommended Posts

Hello,

 

Why do the results of the "DriveGetSize" and "DriveSpaceTotal" commands do not match, as seen in the example below?

 

MsgBox ( 0 , "" , Round ( DriveSpaceTotal ( "C:" ) / 1024 ) & Chr(13) & Round ( DirGetSize ( "C:" ) / 1024 / 1024 / 1024 ) )

2017-10-21_170107.jpg

Edited by Darien
Link to comment
Share on other sites

Because the two functions don't return the same value since they don't count the same thing (total space != dir size).

And reread what you write: "DriveGetSize" and "DriveSpaceTotal" while you invoke DirGetSize and DriveSpaceTotal.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

DriveSpaceFree() is presumably better suited to return available free space on a drive than any other function intended to count the space used by a directory (DirGetSize) or the total size of a drive (DriveSpaceTotal).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Still my favorite, via @rover

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I assume "DriveSpaceTotal" works similarly to "DriveSpaceFree", so I asked him. But if the result of "DriveSpaceFree" does not match the "DirGetSize" result of the directory I want to copy to that device, I will not know if the directory will fit or not.

Edited by Darien
Link to comment
Share on other sites

A directory doesn't have its own free space. The unused or free or available space on a drive is returned by DriveSpaceFree.

20 minutes ago, Darien said:

I assume "DriveSpaceTotal" works similarly to "DriveSpaceFree"

Total ≥ Free ! A 16Gb USB key has around 16Gb total space once formatted but has anything between that and 0 free space, depending on the size already used by files and directories.

DirGetSize sums up the size of all files and directories found under a given path.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

It's also worth mentioning that the amount of space needed to store files is usually a bit more than the reported file size, due to storage granularity. Any advanced file system (e.g. FAT, NTFS) will divide a formatted storage medium into fixed-size chunks (e.g., 4 Kb or 64 Kb, usually provided as a formatting option) and allocate one or more of these chunks to a particular file as needed. You can witness this difference yourself if your right-click on a file in the file manager and select "Properties;" you'll see separate entries for "Size" and "Size on Disk." In some file systems, the content of tiny files maybe stored with the directory entry description itself, so file size on disk is reported as zero. Larger files will be  rounded up in size on disk to the next-larger integer number of chunks. So it's not as straightforward as simply adding all file sizes in a directory, and see if that will fit. Instead, to be safe, when establishing whether a bunch of files will fit, round each one's size up to the next-larger integer number of storage chunks, and sum those (do NOT add all file sizes, and round up that total once; that's not the same thing).

Edited by RTFC
correction, clarification
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...