Version

Goal:Access to the file system
Difficulty:Beginner
Duration:5 minutes
Language:All

Python

# Access to the file system

import os
import harfang as hg

# mount the system file driver, StdFileDriver wraps the system native file API
hg.MountFileDriver(hg.StdFileDriver())

# test that we indeed have access to the file system
path = os.path.realpath(__file__)  # absolute path to this file on the file system
result = hg.GetFilesystem().Exists(path)  # can the engine file system see it?

print("Access OK: %s" % str(result))

Lua

hg = require("harfang")

-- Access to the file system

-- mount the system file driver, StdFileDriver wraps the system native file API
hg.MountFileDriver(hg.StdFileDriver())

-- test that we indeed have access to the file system
path = '../_data/owl.jpg' -- relative path to a file on the file system
result = hg.GetFilesystem():Exists(path) -- can the engine file system see it?

print("Access OK: "..tostring(result))