13.07.2015 Views

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tutorial on the System Classes2.4 Creating a filesystem interfaceYou can use the FileSystem interface to create streams for reading and writing files in the nativeor a virtual file system. Use the System::createFileSystem() function to retrieve a FileSystemobject. As with other System objects, you can use Managed to eliminate the requirement tomanually release the created object.The following steps describe how to create a FileSystem interface:1. Open the main.cpp file from the 03 - Using the FileSystem <strong>Interface</strong> project.Example 2-11 shows how to create a system and filesystem interface:Example 2-11 Create a System object#include #include int main(){try{MDE::Managed system = MDE::create_system_backend();Managed filesystem = system->createFileSystem(".");...The parameter passed to createFileSystem() specifies the root directory.2. Example 2-12 shows how to use the filesystem to attempt to read a file. For this example,the target file does not exist, and the exception is trapped.Example 2-12 Create an InputStream object...printf("Trying to load a non-existent file:\n");try{Managed nonexisting = filesystem->createInputStream("data/non-existing-file.txt");}catch(IOException& ioe){printf("An expected exception was thrown:\n%s\n", ioe.getMessage().getCharString() );}...3. Example 2-13 shows how to create two streams and read the contents of a file:Example 2-13 Reading from a file...Managed output = filesystem->createOutputStream("data/write.txt");Managed input = filesystem->createInputStream("data/read.txt");int length = input->getLength();// Allocate the size of the file, plus one extra byte for a null-terminatorchar* inputBuffer = new char[length+1];ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 2-9ID070710Non-Confidential - Draft - Beta

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!