Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
os
os.open
os.fgets
os.fputs
os.mmap
os.getRootDir
os.listFiles
os.exists
os.remove
os.mkdir
os.rmdir
os.rename
os.stat
os.exit
File
ListFilesResult
FileStat
Structures
Built-in Variables and Constants
Conventions
Exchanges

Reads the whole file and returns its binary data as an ArrayBuffer.

mmap(filename)

Examples

Map the binary data of a file.

javascript
function ab2str(buf) { let arr = new Uint8Array(buf) return String.fromCharCode.apply(null, arr) } function main() { let buffer = os.mmap("strategyConfig/testData.txt") Log("File size in bytes:", buffer.byteLength) let arr = Array.from(new Uint8Array(buffer)) Log("arr:", arr) // Output: arr: [72,101,108,108,111,32,70,77,90,33] Log("ab2str(buffer):", ab2str(buffer)) // Output: ab2str(buffer): Hello FMZ! }

Returns

TypeDescription

ArrayBuffer

Returns the binary data of the file content.

Arguments

NameTypeRequiredDescription

filename

string

Yes

File path.

See Also

Remarks

Reads the entire file into memory at once and returns it as an ArrayBuffer (it is not an on-demand memory mapping; a large file takes the same amount of memory).