Re: [WIN] drive space used != total file space used; whynot?
- Posted by vern at lvp.eastlink.ca Feb 09, 2002
- 489 views
----- Original Message ----- From: "Dan Moyer" <DANIELMOYER at prodigy.net> To: "EUforum" <EUforum at topica.com> Subject: Re: [WIN] drive space used != total file space used; whynot? lesson that you cannot believe everything you see, another is, reality is a matter of perspective....both apply to how Windows properties "sees" disk comsumption. Windows XP, for instance, shows a 151 byte file located on drive c:\ in two ways when I view it in properties. 1). it says the file is 151bytes in size ( .151K) 2). it also states that this one file is taking up 4096 bytes (4K) of drive space. Is Windows insane and doesn't know what it is saying? No, both are true becuase the cluster size is 4K and the whole cluster is flagged as used. Should for some reason Defrag (or some other wonderful optimization utility) not have been run for awhile these unused portions of clusters add up and Windows Properties can wreak havoc on the senses. My suggestion would be to ignore windows properties and go with a non-comparitive approach. > > Euman, > > Thanks, but that's not what I need. I'm not looking for FREE space on a > drive, I'm trying to display the space USED by all directories on a drive. > I'm getting that ok (verified afterward by using "properties" on each > directory & comparing), but when I SUM UP all the space used by all > directories (& also all files on the drive which are not in directories), > and compare that to what I see when I use "properties" on the DRIVE itself, > the "properties" says there's more space used up on the drive than the > summing of the directories says. > > So I'm wondering what I'm missing. > > Anybody got any idea what might be going on? > > Dan > > ----- Original Message ----- > From: <euman at bellsouth.net> > To: "EUforum" <EUforum at topica.com> > Sent: Saturday, February 09, 2002 10:17 AM > Subject: Re: [WIN] drive space used != total file space used; whynot? > > > > ----- Original Message ----- > > From: "Dan Moyer" <DANIELMOYER at prodigy.net> > > > > > > > On Win98 2nd ed, if I right-click on all top-level directories/folders > on a > > > drive, select "properties", and record the number of bytes USED for each > > > directory(not just the sum of the size of the files in them), and then > sum > > > all directories, and then do the same "properties" query for the DRIVE > > > itself, the sums for all directories does NOT equal the "used space" in > > > bytes for the drive. Can anyone tell me why? > > > > > > I was making a utility to show all directories in descending order of > space > > > used on the drive for each, and it finally works, except the sum of the > > > (correctly reported) sizes of all the directories doesn't equal the > > > "properties" reported size of the drive itself. > > > > > > Dan Moyer > > > > > > Hey Dan, > > > > On Windows 95 OSR2 and later you can use this to check the drive > > space. > > > > global function GetDiskFreeSpace(sequence drive) > > atom lpDirectoryName,lpFreeBytesAvailable,lpTotalNumberOfBytes, > > lpTotalNumberOfFreeBytes,bool > > sequence info > > > > lpDirectoryName=allocate_string(drive) > > lpFreeBytesAvailable=allocate(8) > > lpTotalNumberOfBytes =allocate(8) > > lpTotalNumberOfFreeBytes=allocate(8) > > > > bool=c_func(xGetDiskFreeSpaceEx, > > {lpDirectoryName, > > lpFreeBytesAvailable, > > lpTotalNumberOfBytes , > > lpTotalNumberOfFreeBytes}) > > > > info={ > > > peek4u(lpFreeBytesAvailable+4)*power(2,32)+peek4u(lpFreeBytesAvailable), > > peek4u(lpTotalNumberOfBytes > +4)*power(2,32)+peek4u(lpTotalNumberOfBytes ), > > > peek4u(lpTotalNumberOfFreeBytes+4)*power(2,32)+peek4u(lpTotalNumberOfFreeByt > es) > > } > > > > free(lpDirectoryName) > > free(lpFreeBytesAvailable) > > free(lpTotalNumberOfBytes ) > > free(lpTotalNumberOfFreeBytes) > > > > return info > > end function > > > > or on Window 95 OSR-2 and below you can use this which doesnt correctly > return > > volume sizes that are greater than 2GB > > > > function GetDiskFreeSpace(sequence drive) > > atom lpPathName,lpSectorsPerCluster,lpBytesPerSector, > > lpNumberOfFreeClusters,lpTotalNumberOfClusters,bool > > sequence info > > > > lpPathName=allocate_string2(drive) > > lpSectorsPerCluster=allocate(4) > > lpBytesPerSector=allocate(4) > > lpNumberOfFreeClusters=allocate(4) > > lpTotalNumberOfClusters=allocate(4) > > > > bool=c_func(hGetDiskFreeSpace, > > {lpPathName, > > lpSectorsPerCluster, > > lpBytesPerSector, > > lpNumberOfFreeClusters, > > lpTotalNumberOfClusters}) > > > > info={ > > bool, > > peek4u(lpSectorsPerCluster), > > peek4u(lpBytesPerSector), > > peek4u(lpNumberOfFreeClusters), > > peek4u(lpTotalNumberOfClusters) > > } > > > > --warning: > > --this function shows bytes up to 2gig drive limit, > > --but thats good enough for most aps needing to know > > --if there is free space available. > > > > free(lpPathName) > > free(lpSectorsPerCluster) > > free(lpBytesPerSector) > > free(lpNumberOfFreeClusters) > > free(lpTotalNumberOfClusters) > > return info > > end function > > > > I would use the first one because I dont think many people are still > > using Win95 OSR-2 or lower. > > > > Hope this help's. > > > > Euman > > euman at bellsouth.net > > > > > > >