RAM virtual files
[Virtual Files]


Functions

char * oslGetTempFileName ()
void oslSetTempFileData (void *data, int size, int *type)
int oslAddVirtualFileList (OSL_VIRTUALFILENAME *vfl, int numberOfEntries)
void oslRemoveVirtualFileList (OSL_VIRTUALFILENAME *vfl, int numberOfEntries)

Detailed Description

There are two virtual file sources available by default: memory and file.

Function Documentation

char* oslGetTempFileName (  )  [inline]

Gets the name of the temporary file. See oslSetTempFileData for a code sample.

void oslSetTempFileData ( void *  data,
int  size,
int *  type 
)

Sets the data associated to a temporary file.

//Binary data representing a JPG file
const int test_data[] = {...};
//The file is 1280 bytes (it's the length of the test_data array)
const int test_data_size = 1280;
//Set data for the temporary file
oslSetTempFileData(test_data, test_data_size, &VF_MEMORY);
//Load a JPG file using the temporary file (oslGetTempFileName to get its name)
image = oslLoadImageFileJPG(oslGetTempFileName(), OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5650);

int oslAddVirtualFileList ( OSL_VIRTUALFILENAME vfl,
int  numberOfEntries 
)

Adds a list of virtual files. You will then be able to open these files as if they were real.

Parameters:
vfl Pointer to an array of OSL_VIRTUALFILENAME entries
numberOfEntries Number of OSL_VIRTUALFILENAME entries in the array
//Binary data representing a JPG file
const int test_jpg[] = {...};
const char *text = "This is a text file";

//Each entry consists of a name, a pointer to the data, the size of the data, and
//a file type. See the OSL_VIRTUALFILENAME documentation for more information.
OSL_VIRTUALFILENAME ram_files[] =               {
        {"ram:/test.jpg", (void*)test_jpg, sizeof(test_jpg), &VF_MEMORY},
        {"ram:/something.txt", (void*)text, strlen(text), &VF_MEMORY},
};

//Add these files to the list
oslAddVirtualFileList(ram_files, oslNumberof(ram_files));

//We can now open them as if they were real files...
VirtualFileOpen("ram:/something.txt", 0, VF_AUTO, VF_O_READ);
oslLoadImageFileJPG("ram:/test.jpg", OSL_IN_VRAM, OSL_PF_5650);

[...]

void oslRemoveVirtualFileList ( OSL_VIRTUALFILENAME vfl,
int  numberOfEntries 
)

Removes file entries from the virtual file list.

OSL_VIRTUALFILENAME ram_files[] =               {
        [..]
};

//Add these files to the list
oslAddVirtualFileList(ram_files, oslNumberof(ram_files));
//Removing them is as simple as adding them
oslRemoveVirtualFileList(ram_files, oslNumberof(ram_files));


Generated on Wed Feb 24 10:25:35 2010 by  doxygen 1.5.9