Pointers To Appendage Of File?

Started by
5 comments, last by Nik02 11 years, 2 months ago

Is there a way to point to a certain part of a very large file (>1 gigabyte)?

My intention is to store every game asset in a database. My way of doing that is just to write a file that may be a little bit bigger than a gigabyte, but still holding everything like a database. Is there a way to quickly point to a certain entry in the database, rather than doing a search every time I need to pull something?

EDIT: I do know that there is a WinAPI function for file pointers than can be changed to an offset of 5 bytes, but is there an easier way, preferably with the standard library?

C dominates the world of linear procedural computing, which won't advance. The future lies in MASSIVE parallelism.

Advertisement

fseek can be used to set the position of an open file stream, but it is only portable if your file is read and written in binary mode.

Is this what you mean?

EDIT:Yeah in C, fseek is the way to go.

Look into memory mapped files.

Windows file cursors are internally 64-bit, so it is easy to access more than 1 gb. On 32-bit systems, you cannot directly map more than 4gb into your process address space - of course - because the pointers are 32-bit. You can still seek, read and write normally, though. It is also possible to map different regions of the file, if it is larger than the available address space.

Niko Suni

Thank you. I will use fseek, and yes, it it is a binary file database. The one gigabyte size wasn't imposed as a limit, I just only have 1 gigabyte of content to pack.

C dominates the world of linear procedural computing, which won't advance. The future lies in MASSIVE parallelism.

That's a very reasonable size for a commercial, locally-installable game. Most recent games on the market are way larger due to content size. Of course, for web-based gaming and/or distribution, smaller is usually better.

Niko Suni

This topic is closed to new replies.

Advertisement