Files

File I/O, filesystem queries, directory listing, compression, hashing, base64, random.

Files reference

File I/O, filesystem queries, directory listing, compression, hashing, base64, random. Files.* namespace binds raylib's rcore.c file API; Random.* binds SetRandom*.

Raw data I/O

Files.load_data(path: String) -> [UInt8]

Category: I/O · raylib: LoadFileData

Load file contents as a byte array.

val bytes = Files.load_data("assets/data.bin")

raylib cheatsheet · Iron source · Test usage

Files.save_data(path: String, data: [UInt8]) -> Bool / export_data_as_code(data, path) -> Bool

Category: I/O · raylib: SaveFileData / ExportDataAsCode

Write bytes to file; embed as C source.

Files.save_data("save.bin", bytes)

raylib cheatsheet · Iron source · Test usage

Text I/O

Files.load_text(path: String) -> String / save_text(path, text) -> Bool

Category: Text I/O · raylib: LoadFileText / SaveFileText

Text file round-trip.

val config = Files.load_text("config.json")
Files.save_text("out.txt", "hello")

raylib cheatsheet · Iron source · Test usage

Filesystem queries

Files.exists(path) -> Bool / directory_exists(path) -> Bool / is_file(path) -> Bool

Category: Filesystem · raylib: FileExists / DirectoryExists / IsPathFile

Path-type predicates.

if Files.exists("tests/assets/bounce.wav") { }

raylib cheatsheet · Iron source · Test usage

Files.is_extension(path, ext: String) -> Bool / extension(path) -> String / basename(path) / stem(path)

Category: Filesystem · raylib: IsFileExtension / GetFileExtension / GetFileName / GetFileNameWithoutExt

Extension match + parsing.

val ext = Files.extension("sprite.png")  -- ".png"

raylib cheatsheet · Iron source · Test usage

Files.directory(path) -> String / parent_directory(path) -> String / working_directory() / application_directory()

Category: Filesystem · raylib: GetDirectoryPath / GetPrevDirectoryPath / GetWorkingDirectory / GetApplicationDirectory

Path parts + process directories.

val cwd = Files.working_directory()

raylib cheatsheet · Iron source · Test usage

Files.change_directory(path) -> Bool / make_directory(path) -> Int32 / is_valid_name(path) -> Bool / mod_time(path) -> Int64 / length(path) -> Int32

Category: Filesystem · raylib: ChangeDirectory / MakeDirectory / IsFileNameValid / GetFileModTime / GetFileLength

Mutations + metadata.

Files.make_directory("saves")

raylib cheatsheet · Iron source · Test usage

Directory listing

Files.list(path: String) -> FilePathList / list_ex(path, filter, scan_subdirs: Bool) / unload_list(list)

Category: Listing · raylib: LoadDirectoryFiles / LoadDirectoryFilesEx / UnloadDirectoryFiles

Scan directory (flat or recursive, with optional extension filter). Pair with unload_list.

val list = Files.list("tests/assets")
Files.unload_list(list)

raylib cheatsheet · Iron source · Test usage

Data utilities

Files.compress(data: [UInt8]) -> [UInt8] / decompress(data: [UInt8]) -> [UInt8]

Category: Compression · raylib: CompressData / DecompressData

DEFLATE compress / decompress.

val packed = Files.compress(bytes)
val unpacked = Files.decompress(packed)

raylib cheatsheet · Iron source · Test usage

Files.encode_base64(data: [UInt8]) -> String / decode_base64(b64: String) -> [UInt8]

Category: Base64 · raylib: EncodeDataBase64 / DecodeDataBase64

Base64 round-trip.

val b64 = Files.encode_base64(bytes)

raylib cheatsheet · Iron source · Test usage

Files.compute_crc32(data: [UInt8]) -> UInt32

Category: Hashing · raylib: ComputeCRC32

CRC32 checksum (ISO 3309 polynomial). Canonical vector: "123456789"0xcbf43926.

val crc = Files.compute_crc32(bytes)

raylib cheatsheet · Iron source · Test usage

Files.compute_md5(data: [UInt8]) -> [UInt8]

Category: Hashing · raylib: ComputeMD5

16-byte MD5 digest (RFC 1321). Canonical vector: "abc"900150983cd24fb0d6963f7d28e17f72.

val digest = Files.compute_md5(bytes)

raylib cheatsheet · Iron source · Test usage

Files.compute_sha1(data: [UInt8]) -> [UInt8]

Category: Hashing · raylib: ComputeSHA1

20-byte SHA-1 digest (FIPS 180-1). Canonical vector: "abc"a9993e364706816aba3e25717850c26c9cd0d89d.

val digest = Files.compute_sha1(bytes)

raylib cheatsheet · Iron source · Test usage

Random

Random.get_value(min, max: Int32) -> Int32

Category: Random · raylib: GetRandomValue

Inclusive random integer in [min, max].

val d6 = Random.get_value(Int32(1), Int32(6))

raylib cheatsheet · Iron source · Test usage

Random.load_sequence(count: UInt32, min: Int32, max: Int32) -> [Int32] / unload_sequence(seq)

Category: Random · raylib: LoadRandomSequence / UnloadRandomSequence

Generate a non-repeating shuffled sequence (Fisher-Yates). unload_sequence does nothing in Iron because the sequence is garbage-collected.

val deal = Random.load_sequence(UInt32(52), Int32(0), Int32(51))

raylib cheatsheet · Iron source · Test usage

See also