blindwig Posted July 18, 2005 Posted July 18, 2005 Does AutoIt have a funciton to get the allocated file size? I know that FileGetSize will return the actual size of the file, but say I have a 5k file on a filesystem using 4k blocks. Obviously the file has 8k allocated for it. Is there a built-in function to tell me this? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
jpm Posted July 19, 2005 Posted July 19, 2005 Does AutoIt have a funciton to get the allocated file size?I know that FileGetSize will return the actual size of the file, but say I have a 5k file on a filesystem using 4k blocks. Obviously the file has 8k allocated for it. Is there a built-in function to tell me this?<{POST_SNAPBACK}>no that I know about :">
blindwig Posted July 19, 2005 Author Posted July 19, 2005 Is that hard to do in C++? I mean, would it be easy for the devs to add a built-in function (or a flag to the original FileGetSize() function) or should I figure out a way to do it through a DLL call? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
/dev/null Posted July 19, 2005 Posted July 19, 2005 Is that hard to do in C++? I mean, would it be easy for the devs to add a built-in function (or a flag to the original FileGetSize() function) or should I figure out a way to do it through a DLL call?I doubt there is a user mode API call for this in Windows. However, I'm happy if you find one.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Valik Posted July 19, 2005 Posted July 19, 2005 I doubt there is a user mode API call for this in Windows. However, I'm happy if you find one.CheersKurt<{POST_SNAPBACK}>I took a look and I didn't spot a function that jumped out sand said, "Hey, look-it-me, I'm the one you want". I would first try Google and see if there is anything about it there. If not, then the best I can think of is to find out the block-size for the drive the file is located on and then find the next multiple of the drive size that is larger than the current file size. Do all that programmatically, of course. I'm afraid I don't know of any API function off the top of my head that gives the partition block size, though.
blindwig Posted July 19, 2005 Author Posted July 19, 2005 I assume that it's built into windows somewhere, because if you view a file's properties in Windows Explorer there is a text that says "Size on Disk". on my system I'm noticing that it's always a multiple of 4K, which makes sense since my HD is formatted NTFS with 4K blocks. And I could have sworn that DIR used to have an undocumented switch to return allocated size instead of actual size, but I can't find any info on it. Hmm... OK, so does anyone know how to determine the block-size of a file system from a given file name? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
/dev/null Posted July 19, 2005 Posted July 19, 2005 current file size. Do all that programmatically, of course. I'm afraid I don't know of any API function off the top of my head that gives the partition block size, though.<{POST_SNAPBACK}>Not an API call, but WMI Class Win32_Volume can do it (Parameter: Blocksize). CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
GaryFrost Posted July 20, 2005 Posted July 20, 2005 Not an API call, but WMI Class Win32_Volume can do it (Parameter: Blocksize). CheersKurt<{POST_SNAPBACK}>Windows XP and earlier: This class is not available SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
/dev/null Posted July 20, 2005 Posted July 20, 2005 Windows XP and earlier: This class is not available<{POST_SNAPBACK}>Ups.. you're right, requires Windows Server 2003. Sorry, then I don't know a way how to do it.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Lazycat Posted July 20, 2005 Posted July 20, 2005 What is I have found, try this code (need beta of course): $pGDFS = DllStructCreate("dword;dword;dword;dword") $ret = DllCall("kernel32.dll","int","GetDiskFreeSpace",_ "str", "C:\",_ "ptr",DllStructGetPtr($pGDFS,1),_ "ptr",DllStructGetPtr($pGDFS,2),_ "ptr",DllStructGetPtr($pGDFS,3),_ "ptr",DllStructGetPtr($pGDFS,4)) $res = DllStructGetData($pGDFS, 1) * DllStructGetData($pGDFS, 2) DllStructDelete($pGDFS) MsgBox (0, "Cluster Size", $res) Tested only under XP, but this should works on earlier versions. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
blindwig Posted July 20, 2005 Author Posted July 20, 2005 Sweet - I tried it here on XP pro and it works - even for network drives! Thanks! My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
w0uter Posted July 20, 2005 Posted July 20, 2005 something like this ? Func _FileGetRealSize($s_path) If Not FileExists($s_path) Then SetError(1) Return 0 EndIf Local $s_drive = StringLeft($s_path, 3) If StringLeft($s_path, 1) = '.' Then $s_drive = StringLeft(@ScriptDir, 3) If StringLeft($s_path, 2) = '\\' Then $s_drive = StringLeft($s_path, StringInStr($s_path, '\', 0, 3) ConsoleWrite($s_drive & @LF) $v_struct = DllStructCreate("dword;dword;dword;dword") $ai_ret = DllCall("kernel32.dll","int","GetDiskFreeSpace",_ "str", $s_drive,_ "ptr",DllStructGetPtr($v_struct,1),_ "ptr",DllStructGetPtr($v_struct,2),_ "ptr",DllStructGetPtr($v_struct,3),_ "ptr",DllStructGetPtr($v_struct,4)) $i_res = DllStructGetData($v_struct, 1) * DllStructGetData($v_struct, 2) DllStructDelete($v_struct) $i_size = FileGetSize($s_path) $i_size = Ceiling($i_size/$i_res)*$i_res Return $i_size EndFunc My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
Administrators Jon Posted July 20, 2005 Administrators Posted July 20, 2005 Sweet - I tried it here on XP pro and it works - even for network drives!Thanks!Out of morbid curiousity is that a real gonk or an clip-art gonk?Gonks are are biggest unheard anti-desktop rollout agent of the 21st century Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
blindwig Posted July 21, 2005 Author Posted July 21, 2005 Out of morbid curiousity is that a real gonk or an clip-art gonk?uhhh... Gonk? Do you mean my Avatar? It's a picture of a stress ball I have on my desk at work. My girlfriend gave it to me last Christmas and it's already pretty worn - you can see the tounge is starting to peel off and the eyes are cracking. I took it on my cell phone and blue-toothed it to my laptop (my main computer at work) and scaled it and uploaded it here.Gonks are are biggest unheard anti-desktop rollout agent of the 21st century uhhh... you really lost me there. Please rephrase? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
blindwig Posted July 21, 2005 Author Posted July 21, 2005 something like this ?Yeah, looks good.There was a missing ) on line 11, and you need to include math.au3 and use _Ceil(), but other than that it works.Oh, and you need to change the StringInStr line to find the 4th occurance of '\' instead of the 3rd, because '\\127.0.0.1\' is not a drive, but '\\127.0.0.1\c-drive\' is.And I didn't realize this, but _Ceil() returns 1 when given a 0, so this even works on 0k files (which should have 1 cluster allocated to them)Cool. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
Valik Posted July 21, 2005 Posted July 21, 2005 And I didn't realize this, but _Ceil() returns 1 when given a 0, so this even works on 0k files (which should have 1 cluster allocated to them)Cool.On (at least NTFS), a 0-byte file is only stored in the MFT. There is no actual hard disk space used and the file will be 0 bytes until the first character is added, then it will obtain disk space to be stored.
w0uter Posted July 21, 2005 Posted July 21, 2005 @blindwig why use _ceil ? ceiling is better. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
CyberSlug Posted July 21, 2005 Posted July 21, 2005 So how many 0-byte files can you fit on a hard drive before it fills up? Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
herewasplato Posted July 21, 2005 Posted July 21, 2005 (edited) uhhh... Gonk? Do you mean my Avatar?...<{POST_SNAPBACK}>Not to speak for Jon, but I googled "gonk" when I saw his post last night.Toward the bottom of this page are some pictures of what someone else calls a gonk: http://www.twingo.net/twungi.htmlPerhaps the little character added to what appears to be an album or CD cover is also a gonk: http://www.geocities.com/philippesmash/gonkspic.jpgIt must mean something on the other side of the pond.....edit typo Edited July 22, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Valik Posted July 21, 2005 Posted July 21, 2005 So how many 0-byte files can you fit on a hard drive before it fills up? <{POST_SNAPBACK}>Well, technically speaking, they do take up something because at least the name/location is stored in the Master File Table. So assuming you wished to take the time, I suppose it's theoretically possible that you could create enough 0 byte files to fill the MFT causing it to expand and expand until it used up the entire hard drive. However, I would suspect that it is not possible for the MFT to do that, there is surely a cap on its growth size. Also, I would argue that the 0 byte files are not what is filling the hard drive up but rather the information being used to record their existence. So I would say that you could fit as many files as you had: BytesFreeSpace / SizeOfFileEntryInMFT = NumberOfZeroByteFiles.I'm intrigued by this...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now