Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
file_length() incorrect values #472483
04/30/18 16:21
04/30/18 16:21
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
file_length() seems to give incorrect results when it's used for larger files (a couple of megabytes or higher).

Here's a code example of how I used it:
Code:
var fhandle = file_open_read("test.mp3");
var Size = file_length(fhandle);
printf("size: %d", (int)Size);
file_close(fhandle);


What's interesting is that manually retrieving it using the engine's functions seems to give the same faulty results.
Code:
file_seek(fhandle, 0, 2); // seek to end
int Size = (int)file_seek(fhandle, 0, 4); // read position
file_seek(fhandle, 0, 1); // seek back to beginning



POTATO-MAN saves the day! - Random
Re: file_length() incorrect values [Re: Kartoffel] #472484
04/30/18 16:57
04/30/18 16:57
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Those functions probably return real vars, right (instead of let's say int)? Then you've got your (file) limitations with the var range of around a million (bytes).
You will probably need to use Windows functions instead.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: file_length() incorrect values [Re: Superku] #472485
04/30/18 17:06
04/30/18 17:06
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Sounds like this is the case, thanks. Though, I'm confused that they decided to use var for those functions, as it doesn't make sense to get anything else than integers from them.


POTATO-MAN saves the day! - Random
Re: file_length() incorrect values [Re: Kartoffel] #472690
05/14/18 17:31
05/14/18 17:31
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Yes it is due to var limitations.
My guess is the functions already existed in WDL/C-Script, where there were only var and string.

I fixed this in a dirty way for end of file detection and otherwise avoided usage of file_seek and file_length as much as possible.

#define feof(f) (file_seek(f,1,4) == file_length(f))

if both functions deliver the identical (wrong) value, we've most likely reached end of file grin

Re: file_length() incorrect values [Re: FBL] #472692
05/14/18 18:39
05/14/18 18:39
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I just ended up using the file-functions from stdio laugh


POTATO-MAN saves the day! - Random
Re: file_length() incorrect values [Re: Kartoffel] #472712
05/15/18 14:54
05/15/18 14:54
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Possibly the better idea.


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1