| View previous topic :: View next topic |
| Author |
Message |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Sun Apr 01, 2012 10:06 pm Post subject: C++ read and write huge file (300 GB) |
|
|
| How can I read and write a huge file? I need to do it in a fast and efficient way.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun Apr 01, 2012 10:28 pm Post subject: |
|
|
You're at the mercy of the HDD basically. Standard file i/o should work fine but it's going to be slow because disk r/w is slow, comparatively
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25832 Location: The netherlands
|
Posted: Mon Apr 02, 2012 5:19 am Post subject: |
|
|
Look into filemapping
Windows won't actually load the file into memory until you read a page of memory from the mapped memory that corresponds to the mapped file.
If you ARE going to read every single byte of the file in order (like a movie), you can tell windows it's going to get sequential reads so it'll optimize it (buffer ahead)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Apr 02, 2012 6:13 pm Post subject: |
|
|
| Okay thanks. I will also have to quickly parse through it.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25832 Location: The netherlands
|
Posted: Tue Apr 03, 2012 6:01 am Post subject: |
|
|
Just noticed the size. If you're in 64-bit(and compile as 64-bit), use filemapping, it's perfect for quick parsing (loads the parts you need and has direct access to all of the file at once)
If you're in 32-bit you'll have to use small views of the map, which kinda breaks the usefulness. In that case I recommend writing a class that emulates this. (on accessing a byte of the virtual file cache in the data from the file and return a pointer to that)
(perhaps a class that does this already exists in the standard library, I don't know)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|