Jump to content

Recommended Posts

Guest frank_que
Posted

Is't possible to modify the function filegetsize to get the size of files greater than 2gb?

Thanx

Frank

Guest frank_que
Posted

I've tried both windows 2k and windows xp

Frank

Posted

Hi,

you're right, strange result for a 2,89G file: -1190395904 under XP with NTFS.

I think it's a bug but i have a solution:

$before = DriveSpaceFree ( "C:\" )

;This takes time
$FC = FileCopy ( "myvideo.vob", "myvideo.tmp" )

;This is faster;-)
$FC = FileDelete ( "myvideo.vob" )

$after = DriveSpaceFree ( "C:\" )
If $FC = 1 then
MsgBox(4096,"Filesize is:",$after - $before)
FileDelete ( "myvideo.tmp" )
EndIf
Posted

I wonder if this is a windows problem, when I search for files at least 20,971,520kb in size, I'm returned a ton of files, all of them under that size. Same for a search of at least 2,097,152kb...

So, that's winXP...

"I'm not even supposed to be here today!" -Dante (Hicks)

Guest frank_que
Posted

I've looked into autoit sources: It uses the getfilesize() function.

From msdn library documentation: ( http://msdn.microsoft.com/library/default....getfilesize.asp )

"The GetFileSize function retrieves the size of the specified file.

The file size that can be reported by this function is limited to a DWORD value.

To retrieve a file size that is larger than a DWORD value, use the GetFileSizeEx function."

I'm not a c++ programmer, can someone help me to implement it?

Tnx

Frank

Posted

I don't think GetFileSizeEx() is available on earlier versions of Windows or on NT or something. If I remember, there is a valid reason why it isn't used.

Posted

Yeah, I think the small problem is not "GetFileSize", but the conversation to a result:

vResult = (int)GetFileSize(fileIn, NULL);

You see it's converted to integer and a file greater than 2 GB had a problem.

cause the limit of "int" is:2.147.483.647

The highest what this function can is DWORD (4.294.967.295).

So if someone has files bigger than this he has the problem again, but for the size up to 4 GB why we not use this instead (c++):

...
char *dwMaxSize = "0";
...
_ultoa(GetFileSize(fileIn, NULL),dwMaxSize,10);
vResult = dwMaxSize;
...

Only an idea...

Holger

  • Administrators
Posted

Yeah, I think the small problem is not "GetFileSize", but the conversation to a result:

vResult = (int)GetFileSize(fileIn, NULL);

You see it's converted to integer and a file greater than 2 GB had a problem.

cause the limit of "int" is:2.147.483.647

The highest what this function can is DWORD (4.294.967.295).

So if someone has files bigger than this he has the problem again, but for the size up to 4 GB why we not use this instead (c++):

...
char *dwMaxSize = "0";
...
_ultoa(GetFileSize(fileIn, NULL),dwMaxSize,10);
vResult = dwMaxSize;
...

Only an idea...

Holger

We can use a double instead to get to 4GB. Maybe doing getsizeEx when running under NT OSes.

Holger, you do know that code you posted has a buffer overrun yeah? It's just one of your submissions has a similar thing in that I changed :ph34r:


 

  • Administrators
Posted

Why? Do you have files bigger than 4GB?

Movie files and such. a DVD-R is 4.7 GB which could be in one or two files. (I DVD recorded CSI last night off TV and that was 1.47 GB :ph34r: )


 

Posted (edited)

Ofcourse. I don't record/copy movies or television shows on my PC,

that's why I hadn't thought about it.

Edited by SlimShady
Posted

@Jon: I hope I understand :ph34r:

I think you mean the line:

char *dwMaxSize = "0";

Your'e absolutely right.

I read a bit over buffer overruns and security problems a time ago...

So I read it again and now I understand it.

Better for is would be (I hope):

char dwMaxSize[10];

I will install later NT4.0 here on my test-pc as another partition an check what it says to a 10 GB file with "GetFileSizeEx"...

  • Administrators
Posted

@Jon: I hope I understand  :ph34r:

I think you mean the line:

char *dwMaxSize = "0";

Your'e absolutely right.

I read a bit over buffer overruns and security problems a time ago...

So I read it again and now I understand it.

Better for is would be (I hope):

char dwMaxSize[10];

I will install later NT4.0 here on my test-pc as another partition an check what it says to a 10 GB file with "GetFileSizeEx"...

Yeah, that's the one.

char *dwMaxSize = "0";

just allocates 2 bytes "0" and "\0".


 

Posted

Why? Do you have files bigger than 4GB?

I dont, but it is not a reason for keeping a buggy function in Autoit.

For example a .rar achivie can be at most 8,589,934,591 GB so the 4gB limit can be tight.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...