Disk Pointer?

BlitzMax Forums/BlitzMax Programming/Disk Pointer?

This may not make any sense at all, please bear with me.

Is there a way to read x amount of data from a specific pointer (on a disk) if you know exactly where the data is on the hard drive without referring to a file?

For example:

Instead of:
Loadbank(<File>)

this type of idea:
Loadbank(<Disk Pointer address>,<length>)

It would basically be the same as opening a file, but instead, opening an undefined file (just a chunk of memory on the drive).

Possible?

I guess the only possible way is through the Windows API:

http://support.microsoft.com/kb/100027

Sorry, don't have an example to throw in ;)

Nice find, i'll look into it more. Thanks =)

Yes there is nothing in BlitzMax to work with disk data directly. You only have file access. To look at the disk `itself` and read the file system yourself or even go below the filesystem you're going to have to use the os's API for low level disk access.

Thanks for the reply

It's looking pretty complicated, at least a lot more complicated then I was hoping for especially for trying to set up a module for cross platform with this, but I should be able to figure something out.

One problem I can forsee: how would I take the data that I read and return it as a loadable object? Or is this only possible in BM with streams/banks/urls?

Streams 'almost' do the trick when loading a file containing multiple data files when you seek to the desired data position, then loading it:


Local Stream:TStream = openstream("c:\test.pak")
Stream.seek(1663) 'Second file (image) located here.

Local Image:Timage = loadimage(Stream)



Which loads the stream from that position. The only thing missing from that is setting the length.
The reason I don't just ReadBytes or MemCopy or CopyBank to a seperate bank/stream is because that shows a huge slowdown compared to opening the data file by itself rather then in a package.

In an unrealistic test of a 70mb file, it takes at least 50% longer to copy the bytes over to a seperate object then to load the file outside of a package in all the methods ive tried. This is why i'm trying to get this working, sorry I didn't state my reasons before.

Try CreateRamStream... you should be able to create a stream of a limited length within the bank at a given position. This way LoadImage, etc only see the amount of data you want them to.