File system

Application storage

Several means are available for an application to store data:

StorageAdvantagesDisadvantages
file in tmp:Files are read/writeContents are not retained when application exits.

Unmanaged. Does not automatically delete data unless the application actively manages the directory. This increases app's memory usage, which could result in an app failures.
file in cachefs:Files are read/write; an arbitrary amount of data can be written.

cachefs use is per developer ID. Files in cachefs are stored in RAM; therefore, a reboot will evict them from cachefs.

Does not count towards app’s total memory usage
Data is evicted when more space is required for another app
file in pkg:Accesses any files included in app packageFiles are read-only
file on USB deviceAccesses files on removable USB mediaFiles are read-only; not all Roku models support USB
RegistryData is read/write; data is retained when the application exits and when the system rebootsData size is limited. Each app has access to only 32kb of registry space.

Cachefs

Developers can use the cachefs: file system to allow applications to
cache data to volatile or persistent storage instead of tmp:. End-users
can add an external SD card to their device which will preserve the data
even after a system reboot and improve performance. Users without
extended storage also benefit from the use of a shared in-memory cache
that is automatically managed by the system to optimize for the most
recently used assets.

Note that the OS can evict the data at any time, such as when another
app decides to write so much data that space is required. Thus, a
app should always check for the existence of the file they wrote to
before relying on the data cache.

Depending on your application's requirements, you can choose one of
these options. Interfaces to the registry are documented
at roRegistry.
Interfaces to files are described below.

Pathnames

A Roku Streaming Player Pathname identifies a file. Pathnames are used
in ifFileSystem methods,
as well as in other components which use files. A Pathname is a string
with the following format:

device:/dir1/dir2/…/filename

The device field (sometimes called PHY) identifies the location of the
file and can be one of:

  • tmp - Temporary file storage device for the application
  • pkg - The root of the application directory that provides read-only
    access to files provided in the pkg
  • common – A common read-only filesystem that all plugins have access
    to. Currently, it only contains a CA certificate bundle that
    contains CA certs trusted by Firefox
    (common:/certs/ca-bundle.crt). You
    are encouraged to use this file in your apps, especially if you are
    aggregating many different feeds. Please see the twitterOAuth sample
    application for a usage example.
  • ext1, ext2, …,ext9 – Storage devices recognized on the USB bus.
    Please see the USB player sample application for a usage example.

There is no concept of a current working directory or relative paths.
All path names must use the absolute Roku Streaming Player Pathname
format above.

The filename components in a pathname may not contain any of these
characters:

  <  >  :  "  /  |  ?  *

nor any whitespace or non-printable character.

Example

Example of path names used from BrightScript

theme.OverhangSliceSD = "pkg:/images/Overhang_Slice_SD43.png"
http.Http.GetToFile("tmp:/categorylist")
DeleteFile("tmp:/categorylist")
obj.SetCertificatesFile("common:/certs/ca-bundle.crt")

Did this page help you?