PDA

View Full Version : load files in memory



farcodev_
23-09-2009, 01:07 AM
Hi, is anyone know a component (free) which allow to load files in memory and use them after.

I need to load .3ds object in memory for multiple uses and avoid a lot of i/o on hd ???

Thank you !

WILL
23-09-2009, 01:58 AM
Why can't you just write something small using TStream? :)

Andreaz
23-09-2009, 05:07 AM
More exactly TMemoryStream:




FS:= TFileStream.Create(FileName, fmOpenRead);

Stream:= TMemoryStream.Create;
Stream.Size:= FS.Size;
Stream.CopyFrom(FS, FS.Size);
FS.Free;

// loaded into memory
Stream.Position:=0;
Stream.Read(value, sizeof(Integer));
...
Stream.Free;

noeska
23-09-2009, 04:27 PM
You can use glmodel: http://www.noeska.com/dogl/glModel.aspx
it can even load .3ds from memorystreams :-) Even when loading a .3ds from file a stream is used and when modifying the mesh it is only changed in memory.
Only the saving of a .3ds file is a work in progres. But you can save to milkshape ascii and obj even when the file is loaded as an .3ds .

farcodev_
24-09-2009, 04:43 PM
First, thank you for all your answers ;)

About TStreams it's because i never used them :scared: But it seems cool since if i remember i can load 3ds file from a stream (i use GLScene with a custom 3ds loader from Dave Gravel), so i'll test that ! ;)

for glmodel i don't know how to use it with GLScene :no: ???

Anyway thank you it will save loading time ! (beside to reduce the objects polygons too :-[)

farcodev_
24-09-2009, 11:46 PM
yeehaa the custom loader support tstream too, let's the party started ! 8)

Thank you again ;)

farcodev_
06-11-2009, 01:04 AM
(useless post sorry :scared: i had a problem but i found the solution)

edit: wow i saved 14 mb of memory by put the xml file containing user's interface texts in memory ! :o w/o speak of less disk access and a gain in speed :o