Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADIR returns a negative number for filesize
Message
From
05/09/2004 11:51:47
 
 
To
05/09/2004 08:26:42
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00939494
Message ID:
00939576
Views:
14
Thanks!

>>Hi All,
>>
>>In the case of a file that's more than 2Gig, ADIR() returns a negative filesize. The size is 2.451.450.455 and adir() says it's -1843516841.
>>
>>Maybe there's an algorithm that I can use to convert that negative number? Or can I use some API call?
>
>hi Peter,
>
>You can use download#10010 and function adir_(). Replace the function CharToBin() with the one below for speed.
>
>Or you can use the function below : FileSize_Get(FileName, @FileSize)
>
>I just tested both on a 5 Gb file
>
>
>#ifnDef	TRUE
>	#define	TRUE	.T.
>	#define	FALSE	.F.
>#endif
>function Do_it()
>	
>	local FileSize
>	
>	?FileSize_Get('Z:\tmp\test_2.txt', @FileSize), FileSize
>
>
>
>endfunc
>*---------------------------------------------------------------------------
>
>#Define MAX_PATH 260
>function FileSize_Get(FileName, FileSize)
>	declare Integer FindFirstFile in Kernel32.dll string @, String @
>	declare Integer FindClose in Kernel32.dll Integer
>	
>	local Success
>	Success = TRUE
>	
>	local FindFileData, Handle, FileSizeHigh, FileSizeLow
>	
>	FindFileData = replicate(chr(0), 4+8+8+8+4+4+4+4+MAX_PATH+14)
>	Handle = FindFirstFile(@FileName, @FindFileData)
>	
>	do case
>	case m.Handle < 0
>		Success = FALSE
>	
>	otherwise
>		FileSizeHigh	= substr(m.FindFileData, 29, 4)
>		FileSizeLow	= substr(m.FindFileData, 33, 4)
>	
>		FileSize = CharToBin(m.FileSizeHigh) * 2^32 + CharToBin(m.FileSizeLow)
>	
>		=FindClose(m.Handle)
>	endcase
>	
>	return m.Success
>	
>endfunc
>*---------------------------------------------------------------------------
>function CharToBin(word)
>	local i, out
>	
>	out = 0
>	
>	for i = len(m.word) to 1 step -1
>		out = m.out * 256 + asc(substr(m.word, m.i, 1))
> 	endfor
> 	
> 	return m.Out
>endfunc
>*----------------------------------------------------------------------------
>
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Reply
Map
View

Click here to load this message in the networking platform