//=========================
// File and Archive
//=========================
// Open from device
// test.txt must in assets folder.
irr::io::IReadFile* fp = arsa_CreateAndOpenFile( "test.txt" );
// Open from cloud
// Keep file (assets2.zip) on device memory.
// Make sure file sizes are fiting with avaliable device memory.
irr::io::IReadFile* fp = arsa_OpenFileFromServer("http://www.sarosworld.com/assets2.zip");
// Open from cloud and keep file to permission folder on device.
// false = write download file to device.
irr::io::IReadFile* fp = arsa_OpenFileFromServer("http://www.sarosworld.com/assets2.zip",false);
// Write
irr::io::IWriteFile* fp = arsa_CreateAndWriteFile("test.txt");
// !!!Close, call when done!!!
fp->drop();
//=========================
// Direct Input / Output
//=========================
// Reads from a file.
char buffer[256];
fp->read( buffer, 256 );
// Reads a byte line from a file stream.
irr::core::stringc str = arsa_fgets(fp);
// Writes to a file.
irr::core::stringc str = "hello";
fp->write(str.c_str(), msg.size());
//=========================
// File positioning
//=========================
// Current position in the file in bytes.
long size = fp->getSize();
// Size of the file in bytes.
long pos = fp->getPos();
// Moves the file position indicator to a specific location in a file
// 10 = Destination position in the file.
// true = If set to true, the position in the file is changed relative to current position. Otherwise the position is changed from beginning of file.
// return true if successful, otherwise false.
fp->seek( 10, true );
// Get name of file.
irr::core::stringc name = fp->getFileName();
//=========================
// 1. File Example
// read all line in text file
//=========================
irr::io::IReadFile* fp = g_fs->createAndOpenFile("test.txt");
if (fp)
{
while (!arsa_eof()) // check eof
{
irr::core::stringc str = arsa_fgets(fp);
}
fp->drop();
}
//=========================
// 2. File Example
// write data to permission folder
//=========================
irr::io::IWriteFile* fp = arsa_CreateAndWriteFile("test.txt");
if (fp)
{
// write string
irr::core::stringc str = "hello";
fp->write(str.c_str(), msg.size());
// write int
int i = 10;
fp->write(&i, sizeof(int));
// write float
float f = 45.72f;
fp->write(&f, sizeof(float));
fp->drop();
}
//=========================
// Archive
// Support zip, gzip, tar, pak, npk and wad
//=========================
// Example add zip file.
// After calling this, the ARSA Framework will also search and open files directly from this archive.
// 1. open original file for add archive
irr::io::IReadFile* fp = g_fs->createAndOpenFile("assets2.zip");
// 2. call add archive function
// fp = file pointer
// false = Ignore case, If set to true, files in the archive can be accessed without writing all letters in the right case.
// false = Ignore path, If set to true, files in the added archive can be accessed without its complete path.
// irr::io::EFAT_ZIP = archiveType
// irr::io::EFAT_ZIP = A PKZIP archive.
// irr::io::EFAT_GZIP = A gzip archive.
// irr::io::EFAT_PAK = An ID Software PAK archive.
// irr::io::EFAT_NPK = A Nebula Device archive.
// irr::io::EFAT_TAR = A Tape ARchive.
// irr::io::EFAT_WAD = A wad Archive, Quake2, Halflife.
g_fs->addFileArchive(fp, false, false, irr::io::EFAT_ZIP);
// 3. drop original file
fp->drop();
// If zip have a password. call this before drop
// "12345678" = zip password
g_fs->addFileArchive(fp, false, false, irr::io::EFAT_ZIP, "12345678");
- Log in to post comments