Skip to content
Saveliy Tronza edited this page Apr 25, 2024 · 5 revisions

Storage Folder

All files which can be accessed or created with addon are stored in pathToAddon/storage folder.

Principles

  • Data is stored as key-value pairs. Key is always a string, value is always a string too. Key should be unique, otherwise you will override value associated with another key - like profileNamespace in Arma.
  • open and close function names might be slightly misleading. Actual file read doesn't happen until you call the read function, and write does not happen until you call write function. set, get and similar functions perform their actions purely in RAM - just like profileNamespace in Arma.
  • File format is binary: <file header><key0><\0><value0><\0><\n><key1><\0><value1><\0><\n><value1>.... However since everything is stored as strings, if you need to edit data, you can do so - just don't touch the binary file header and characters between keys and values. There is no checksum or similar which must be recalculated.

Usage Examples

Writing data to a file

private _fileName = "test.txt";
  
[_fileName] call filext_fnc_open;
 
[_fileName, "Name", "Cpt Miller"] call filext_fnc_set; 
[_fileName, "Weapon", "MX Marksman Rifle"] call filext_fnc_set; 
 
[_fileName] call filext_fnc_write; // Actual write to file
[_fileName] call filext_fnc_close;

Reading data from a file

private _fileName = "test.txt";
  
[_fileName] call filext_fnc_open;
[_fileName] call filext_fnc_read; // Actual read from the file
 
private _name = [_fileName, "Name"] call filext_fnc_get; 
private _weapon = [_fileName, "Weapon"] call filext_fnc_get; 
 
[_fileName] call filext_fnc_close;

[_name, _weapon]

SQF functions

Please use the SQF API to communicate with extension. You can use raw callExtension call too, the only function which really needs special handling is filext_fnc_get.

filext_fnc_open - prepares file for manipulation

filext_fnc_close - deletes all data associated with file from RAM

filext_fnc_write - writes data from RAM into the actual file

filext_fnc_read - reads data from file to RAM

filext_fnc_set - sets value associated with key

filext_fnc_get - returns value associated with key

filext_fnc_eraseKey - erases value associated with key

filext_fnc_getFiles - returns array of files in storage folder

filext_fnc_deleteFile - deletes file from fily system

filext_fnc_fileExists - returns true if file with name exists in storage folder

Common Mistakes

  • Battleye could block loading of the .dll file, try to disable Battleye through Arma Launcher.
  • If the extension can't write to a file, ensure that file name is good for the operating system. Some characters or file names are not supported. Easy way to check is by creating an empty file with that name through Explorer. You can read more here: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file
Clone this wiki locally