|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
highly optimized file reading and writing?
I want to know if this is possible:
To write an array of data directly to the disk and then later read it back into memory without ever having to parse the data. In more detail, the write to the disk would be an exact byte per byte copy, (done whichever way is the fastest and most optimized possible), directly from memory to disk, without worrying about data structures and variables. The read from the disk will be exactly the same, ignoring all data structures, variables, and any parsing what-so-ever. The read will directly overwrite the exact space in memory that is already declared. If this could be done, then I think this is the fastest way to store an array of data to disk that needs to be constantly reloaded into memory to be udpated and then quickly stored again. Is this possible?
__________________
Matthew Doucette / Xona.com |
|
#2
|
|||
|
|||
|
(BTW, I know that it would be faster to simply keep the data in memory and update the data in memory and then periodically write the whole thing to disk, especially seeing that this is a webpage application, but this is not an option as I have not learned how to do this yet.)
|
|
#3
|
||||
|
||||
|
Yes, it is possible to do a write to disk and reread the data into a buffer. However, it sounds like you probably want to use shared memory instead, especially if you want to share some common data between multiple instances. This way, you can avoid disk I/O
Hopefully this link may prove to be useful. |
|
#4
|
|||
|
|||
|
Thanks for the link, Scorpions4ever, but I think I am going to try to save everything to disk before I learn how to code a server that handles requests and all of that.
Quote:
|
|
#5
|
||||
|
||||
|
Quote:
Yes, you can. If you think about it, when you're reading any character string (whether from file or from console), you're putting it into an already defined and declared character array. The only thing you need to watch out for is to ensure that your buffer is large enough to contain the data that you're reading back into it. |
|
#6
|
|||
|
|||
|
Excellent. This is obviously the fastest way to write data to a disc and later read it back. No parsing what-so-ever.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > highly optimized file reading and writing? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|