WriteFileAsHex()
ts
WriteFileAsHex(filePath: string, data: string, offset: number, whence: number): respBase;Writes the provided base-16 (hexadecimal) encoded data to the filePath file in the VFS, starting at the specified offset computed from whence. The file is treated as binary data.
Parameters
| Parameter | Type | Explanation |
|---|---|---|
filePath | string | The fully qualified, root-based, POSIX path to the file in the VFS |
data | string | The string of hex-encoded bytes to write to the file |
offset | number | The positional offset, computed from whence, where the write operation will begin |
whence | number | One of: FromStart, FromEnd |
NOTE
offset and whence together determine where writing begins. 0,FromStart overwrites the file from the beginning; 0,FromEnd appends new data to the file.
Example
ts
var vfs = GetCurrentVFS();
if (vfs != null) {
var resp = vfs.WriteFileAsHex("/data/archive.dat", "FFD8", 0, FromEnd);
if (resp.Ok()) {
Log("Data written"); // Bytes 255 (FF) and 216 (D8) appended to file
} else {
Log("Error: " + resp.ErrorMsg());
}
} else {
Log("VFS was null");
}