StreamLine Posted February 21, 2009 Posted February 21, 2009 as the title says, i am creating a new section and storing data in it, i would like to know the best way to store a large amount of data and read it back, perfer delphi, but any lang would be good.
Nacho_dj Posted February 21, 2009 Posted February 21, 2009 In my opinion, the best way of storing a huge amount of data is doing it on disk. The performance of your target gets slower when you use memory space to store it, especially when you are manging huge amount of data, as you stated.Then, if you want to read data of the new section for being managed by your tool, the fastest way (for a good performance) is to choose not loading very large blocks in memory. I usually load blocks of 0x10000.And talking about language, this is my way, there could be of course a lot of better ways...type bufType : array of Byte;procedure DumpingData (var buf : bufType; FileName : AnsiString; offset : Integer);var dump : TFileStream;begin try dump := TFileStream.Create (FileName,fmCreate); dump.Seek (offset,soFromBeginning); dump.Write (buf[0],Length(buf)); finally dump.Free; end;end;So, FileName should contain the entire path to your file, and buf should contain your wanted data to be stored. There could be done lots of previous checks, to be sure the file is accessible, the buffer is not empty, and so on...To retrieve the data from disk, just change fmCreate by fmOpenRead and dump.Write by dump.Read...Is this answering your question?CheersNacho_dj
StreamLine Posted February 22, 2009 Author Posted February 22, 2009 (edited) for instance if i wanted to save a group of settings, strings,integers etc inside a new pe section, what would the best way to write it be?typeTSettings =recordsetting1:string;setting2:integer;end;varset : TSettings;beginset.setting1 := 'hello world';set.setting2 := 20;end;say i wanted to write the simple data above into my new section. since i dont know the size of my record or my string snce the string is varialbe.? i was thinking about storing a dll or plugins in size a new section, just playing with ides atm. cheers. Edited February 22, 2009 by StreamLine
null46 Posted February 23, 2009 Posted February 23, 2009 You can define the length of string allocated, that way you know the size of the record.e.gTSettings =record setting1: string[60]; setting2: integer;end;
Departure Posted February 23, 2009 Posted February 23, 2009 whats the point in that unless its a "packed" record?
StreamLine Posted February 23, 2009 Author Posted February 23, 2009 defining the length of the string wont help since im not sure what it will be, if i define it at 255, it wastes space or doesnt hold enough space, i cant tell how big the string will be,
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now