Ram Disk and Pointer to content in the File

Hi,

When we are using RAM DISK - the files are stored on the RAM.
from what I understand (and saw many examples) in order to read data from file (the file which locate on the RAM) - I need to use the read function.

Is there a chance to get char* (or any pointer) to the content of the file without using the read function ?

If the file locate on the RAM, it seem that it is like I have a buffer on the RAM (like an array which was dynamic allocated) and in the case of a buffer on the ram -> we can use pointers to the data without reading all the data.

example:

class CDATA
{
int nValue1;
int nValue2;
double dValue3;
double dValue4;
char achBuf[10];
};

void main ()
{
// for the example: suppose we have file which contains CDATA structures.

fstream m_ramdiskFile;
m_pBuffer = new char[1000000];
m_ramdiskFile.open("./.ramdisk", ios::binary | ios::in | ios::out | ios::trunc);

// in stead of reading the whole record
CDATA cDATA;
m_ramdiskFile.read((char*)cDATA, sizeof(CDATA));

// can I get a pointer to the content of the file -> which already locate on the RAM (bacause
// it is file on the RAM DISK)
// can I do something like that:
CDATA* pData = m_ramdiskFile.beg(); ???
cout << pData->dValue4;

}
I have a buffer on the RAM
Mostly correct.
we can use pointers to the data
No, it is not your program memory. Each program has its own memory space and cannot access other programs memory (There is actually, but they are way more complex).
so although the file locate on the RAM (because we are using RAM DISK folder), we cant get pointers to specific data in the file without reading the content ?
(as opposed to working with buffers on the memory) ?
Topic archived. No new replies allowed.