Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADIR returns a negative number for filesize
Message
De
05/09/2004 08:26:42
 
 
À
04/09/2004 17:45:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00939494
Message ID:
00939546
Vues:
13
This message has been marked as the solution to the initial question of the thread.
>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
*----------------------------------------------------------------------------
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform