Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ read and write huge file (300 GB)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Gwinx
Advanced Cheater
Reputation: 0

Joined: 30 Jul 2010
Posts: 65

PostPosted: Sun Apr 01, 2012 10:06 pm    Post subject: C++ read and write huge file (300 GB) Reply with quote

How can I read and write a huge file? I need to do it in a fast and efficient way.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun Apr 01, 2012 10:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25832
Location: The netherlands

PostPosted: Mon Apr 02, 2012 5:19 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Gwinx
Advanced Cheater
Reputation: 0

Joined: 30 Jul 2010
Posts: 65

PostPosted: Mon Apr 02, 2012 6:13 pm    Post subject: Reply with quote

Okay thanks. I will also have to quickly parse through it.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25832
Location: The netherlands

PostPosted: Tue Apr 03, 2012 6:01 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites