How to do it ? -Ram Disk

BlitzMax Forums/BlitzMax Programming/How to do it ? -Ram Disk

blicek(Posted 2015) [#1]
Hello

I would like to do a ramdisk as it was in the days of the Amiga os using blitzmax, and integrate it with the system. Is it at all possible?

For help in advance thank you

Blicek


TomToad(Posted 2015) [#2]
Do you mean reading and writing to RAM using ReadInt, WriteInt, ReadString, WriteString, etc... like you would a hard drive? You can create a stream using CreateRamStream() then read and write to it like any other stream.
SuperStrict

Local RamDisk:TBank = CreateBank(65536) 'create a 64k ramdisk
Local Stream:TStream = CreateRamStream(RamDisk,65536,True,True) 'open a stream to the bank


'We'll write a bunch of stuff into the bank
Stream.WriteLine("Hello World!!!")
Stream.WriteInt(42)
STream.WriteLine("Goodbye Everybody!!!!")

CloseStream Stream 'close the ram stream

'Now we will open the stream again and read a bunch of stuff
Stream = CreateRamStream(RamDisk,65536,True,False) 'Open memory as read only
Print Stream.ReadLine()
Print Stream.ReadInt()
Print Stream.ReadLine()

CloseStream Stream

Note that when writing, you need to make sure that the write pointer doesn't go past the end of the bank or you can crash the program.


videz(Posted 2015) [#3]
I think what blicek meant is having a Virtual File System where you mount a virtual drive in memory and access to files like a physical drive.


TomToad(Posted 2015) [#4]
I guess I want being clear. I know what a ram disk is. Back in early days of computing, a ram disk was used mainly to preload a bunch of files into ram so when the program needed them, they could be accessed quickly. Not really needed anymore as hard drives are much faster than they use to be, and for the few things where the drive is still too slow, there are other methods for preloading the files for use. However, there are still those rare moments where it is beneficial to read and write ram like you would a hard drive, in those cases, there is CreateRamStream().

If you want an actual mountable file system, BlitzMax didn't have any native support, There probably a dll somewhere you could use.

Edit: there is incbin, read only, probably closest to a ram disc that BlitzMax will natively support.


Brucey(Posted 2015) [#5]
Ramdisks :

http://en.wikipedia.org/wiki/List_of_RAM_drive_software

:o)


blicek(Posted 2015) [#6]
Ok!

Thank you all for the quick and concrete answer and all the comments I am urgently.

Blicek

A few words:

I love above all Blitz,s


BlitzSupport(Posted 2015) [#7]
I use ImDisk, but the interface isn't very clear. Another decent RAM disk is OSFMount.