int FileOpenAsset(char *filename);
Open a file asset that will be shipped with your product.
Return Value
Returns an int handle to the resource file opened.
Parameters
filename Name of the file to be opened.
NOTE: The file system used by iOS is case sensitive, so be sure to match the case of the file name in your code to that of the file on your computer.
Remarks
FileOpenAsset() will open an existing file in the folder where your application assets reside (the folder Assets which resides in the same directory as your executable). These may be game data or table files that are read only and are shipped along with your game. Typically, these files are in the Debug folder (on Windows, using Visual C++) where your application resides. In specifying the path to the file to be opened, omit the Assets portion of the path. DragonFireSDK will only load files from locations relative to the Assets folder.
Availability
Available in DragonFireSDK 1.0 and later.
Example
The example below tests for an existing file on the first run of the app and if the file does not exist, it opens the shipped file from Assets and saves a writable copy to the Documents folder.
#include "DragonFireSDK.h"
int MyFile; int MyNewFile; char MyFileBuffer[200];
void AppMain()
{ MyFile=FileOpen("MyFile.txt");
if (!MyFile) { MyFile=FileOpenAsset("MyFile.txt"); FileRead(MyFile, MyFileBuffer, 200); MyNewFile=FileCreate("MyFile.txt"); FileWrite(MyNewFile, MyFileBuffer, 200); FileClose(MyNewFile); } else { FileRead(MyFile, MyFileBuffer, 200); }
if (MyFile) FileClose(MyFile); }
void OnTimer() {
}
void AppExit() {
} |