File Access link

These Python functions allow you to access asset files, which may be found in the game directory, RPA archives, or as Android assets.

renpy.file(fn, encoding=None) link

An alias for renpy.open_file(), for compatibility with older versions of Ren'Py.

renpy.list_files(common=False) link

Lists the files in the game directory and archive files. Returns a list of files, with / as the directory separator.

If true, files in the common directory are included in the listing.
renpy.loadable(filename) link

Returns True if the given filename is loadable, meaning that it can be loaded from the disk or from inside an archive. Returns False if this is not the case.

renpy.open_file(fn, encoding=None) link

Returns a read-only file-like object that accesses the file named fn. The file is accessed using Ren'Py's standard search method, and may reside in an RPA archive. or as an Android asset.

The object supports a wide subset of the fields and methods found on Python's standard file object, opened in binary mode. (Basically, all of the methods that are sensible for a read-only file.)

If given, the file is open in text mode with the given encoding. If None, the default, the encoding is taken from config.open_file_encoding. If False, the file is opened in binary mode.

Rarely Used link

These functions are used more rarely.

renpy.exists(filename) link

Returns true if the given filename can be found in the searchpath. This only works if a physical file exists on disk. It won't find the file if it's inside of an archive.

You almost certainly want to use renpy.loadable() in preference to this function.

renpy.fsdecode(s) link

Converts s from filesystem encoding to unicode.

renpy.fsencode(s, force=False) link

Converts s from unicode to the filesystem encoding.

renpy.image_size(im) link

Given an image manipulator, loads it and returns a (width, height) tuple giving its size.

This reads the image in from disk and decompresses it, without using the image cache. This can be slow.