Re: show drive space used?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Aug 29, 2003
- 428 views
Al, I think maybe Elliott is right, the report from your function is already accurate with respect to file/properties report ? And I don't see a dos screen, because I turned your program into an include & just use the functions! :) Dan Moyer ----- Original Message ----- From: "Al Getz" <Xaxo at aol.com> To: <EUforum at topica.com> Subject: RE: show drive space used? > > > Al Getz wrote: > > > > > > Dan Moyer wrote: > > > > > > > > > Al, > > > > > > Apparently it's easier than you suggested below, & *you* made it so :) > > > > > > You contributed a program, Get Drives, which returns all drives on a > > > system, > > > (or alternatively just all *fixed* drives, I think), with info about > > > each > > > drive, including total size & free space, which subtracted yields space > > > used. > > > > > > So instead of summing all the dir space used & trying to figure how many > > > clusters might be being used to store the dir & drive info, I just made > > > your > > > program into an include & used that. In fact, I'd already used it, to > > > find > > > what drives would be present & then display them in a user select list > > > box. > > > Now I'll also use it for total drive space used. Did you forget about > > > your > > > program? > > > > > > Only problem I've seen is that both your routine's return *and* just > > > right-click and select "properties" on a drive to see windows report on > > > drive space each sometime return different values, but then if done a > > > few > > > more times, they both will then agree. Weird. > > > > > > Dan Moyer > > > > > > > > > ----- Original Message ----- > > > From: "Al Getz" <Xaxo at aol.com> > > > To: <EUforum at topica.com> > > > Sent: Monday, August 25, 2003 6:24 PM > > > Subject: RE: show drive space used? > > > > > > > > > > Dan Moyer wrote: > > > > > > > > > > > > > > > Pete, > > > > > > > > > > Not sure what you mean about "was it free space". The summation of > > > > > drive > > > > > space used for each directory was *nearly* correct. I used dir_walk (or > > > > > walk_dir, whichever it is), (checked each dir report by hand for > > > > > correct, > > > > > which they were), and then summed all dirs for drive total for space > > > > > used, > > > > > but found that the sum wasn't correct. Turns out I probably asked about > > > > > this a while ago, because I had started to try to account for the "." & > > > > > ".." > > > > > that show up in each dir, such that a cluster (or more?) is used to hold > > > > > the > > > > > actual directory *data*. Once I "assumed" the addition of one cluster > > > > > per > > > > > directory, the program *sometimes* comes out correct, depending on maybe > > > > > how > > > > > many actual files there are on a drive (in other words, some directories > > > > > may > > > > > need *more* than one cluster to hold the dir data; the drives with dirs > > > > > that > > > > > don't apparently need more than one cluster to hold its data, came out > > > > > right > > > > > for total drive space used when I added one cluster per directory, plus > > > > > I > > > > > think one cluster for the drive to hold the directory info, too). > > > > > > > > > > So apparently what I need to know now is how to figure how many clusters > > > > > are > > > > > used for each directory; "1" would be a minimum, but I'm not sure how to > > > > > figure when it's more. And maybe how to know if more than one cluster > > > > > is > > > > > being used to hold the drive's info about its directories. > > > > > > > > > > Dan Moyer > > > > > ----- Original Message ----- > > > > > From: "Pete Lomax" <petelomax at blueyonder.co.uk> > > > > > To: "EUforum" <EUforum at topica.com> > > > > > Sent: Sunday, August 24, 2003 4:06 AM > > > > > Subject: Re: show drive space used? > > > > > > > > > > > > > > > > On Sun, 24 Aug 2003 03:09:38 -0700, Dan Moyer > > > > > > <DANIELMOYER at prodigy.net> wrote: > > > > > > > > > > > > >but something (I don't remember what exactly) went wrong if I gave it > > > a > > > > > > >drive to walk through. > > > > > > Was it free space? > > > > > > > > > > > > Pete > > > > > > > > > > > > > > > > > > TOPICA - Start your own email discussion group. FREE! > > > > > > > > > > > > > > > Hi Dan, > > > > > > > > If you are using FAT32 you can simply create a file of 1 byte and check > > > > the properties in explorer (bytes used). This will tell you the size > > > > a directory name takes up. > > > > In NTFS, if you are using a 2GB or larger disk the units are > > > > 4096 bytes so one directory listing probably takes 4096 bytes. > > > > > > > > In any case, the ratio of the directory listing space to files > > > > space is usually low, so you can probably assume 0 and get > > > > reasonable results unless you happen to have a lot of > > > > directories with only a few files in them. > > > > > > > > This means if you do a 'dir()' in Euphoria on a directory > > > > you should be able to add up the bytes from each file and > > > > get results you can compare with other directories. > > > > > > > > If you wish, you can round the file bytes count up to the > > > > nearest allocation unit before adding so you get actual > > > > bytes used. This is the actual disk space used. > > > > The formula > > > > > > > > if b>0 then > > > > B=(floor(b/a)+1)*a > > > > else > > > > B=0 > > > > end if > > > > > > > > where > > > > b is bytes returned from 'dir()' for each file, and > > > > a is bytes per allocation unit on that disk > > > > B is actual bytes taken up on the disk > > > > > > > > should get you there if you sum up all B from all the files in > > > > a directory. The directory name takes up one allocation unit, > > > > so add that to the sum for that directory count. > > > > Ignore "." and ".." . > > > > > > > > There is also a dos int call to find out the allocation unit size, > > > > but im not sure if it works in NTFS and i've never used it. > > > > > > > > This should provide more accurate results, but if it doesnt > > > > please let me know. > > > > > > > > Take care for now, > > > > Al > > > > > > > > > > > > TOPICA - Start your own email discussion group. FREE! > > > > > > > > Hi there Dan, > > > > I remember something about that, but didnt it just show > > the drive space as a whole? I thought you wanted to > > look at individual directories and do a report that > > shows which directories use the most bytes to help > > decide what to move to another drive, or something like > > that. > > > > I'll have to take a new look at the program, if i can find > > it now... > > > > Take care for now, > > Al > > Hello again Dan, > > As you probably already know, there are two standards for > defining a megabyte. > > 1. 1 megabyte=1,000,000 bytes > 2. 1 megabyte=1,048,576 bytes (1024*1024) > > Hard disk manufacturers use #1 while memory uses #2. > This means if you want to store a block of memory say > 4096 bytes (4kb) long on disk, it's going to take more > then 4kb to store it on disk! In fact, it takes 4.096kb > on disk. Since i wanted to show bytes used using the > memory standard, i used the conversion factor 1/1024 > instead of 1/1000. > It makes sense to use the disk standard, but it also makes > sense to use the memory standard because this tells you > how much space you have for storing memory. Using the > memory standard tells you that after you create a file > such as a bitmap that uses 32k bytes you will be using > 32k bytes of disk space when it's saved to a file. > Using the disk standard, after you create a file using > 32k bytes in mem you will be using up 32.768k bytes on disk, > which brings in a conversion factor. It all depends > on how you want to look at it. > > What i SHOULD have done was define a constant that allowed > the user to select which they wanted to use in their program, > memory or disk standard. > > > If you want to see the bytes count match up with the > file/properties listing, it really should be quite easy... > > In function: > GetDriveInfo() <snip> > >