Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: FileSystemService

[20:7] extends: EngineService

Wraps FXGL's FileSystemService (com.almasb.fxgl.io.FileSystemService), an EngineService that exposes file I/O wrapped in IOTask objects. Every read/write/list method returns an IOTask; call run() to execute synchronously or runAsync() to schedule on a background thread. All file names are paths relative to the application root (on desktop, the current working directory; on mobile, the private storage root). Reached at runtime via fxgl.getFileSystemService; obtain a wrapper via adopt.

Methods

  • FileSystemService (Ajo = null)

    Creates a FileSystemService wrapper. Empty by default; the (Ajo) form wraps an existing instance from fxgl.getFileSystemService.

    • @p Ajo is an optional AussomJavaObject around a FileSystemService.
  • adopt (object Ajo)

    Wraps an existing FileSystemService AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a FileSystemService.
    • @r A new wrapper.
  • exists (string PathName)

    Returns true when a file or directory at the given path exists.

    • @p PathName is the path relative to root.
    • @r A bool.
  • createDirectoryTask (string DirName)

    Returns an IOTask that creates the named directory (and any missing parents) when run.

    • @p DirName is the directory path relative to root.
    • @r An AussomJavaObject around an IOTask.
  • writeDataTask (object DataObj, string FileName)

    Returns an IOTask that binary-serializes Data to the named file when run. Data must be a Java Serializable.

    • @p DataObj is an AussomJavaObject around a Serializable.
    • @p FileName is the destination file path relative to root.
    • @r An AussomJavaObject around an IOTask.
  • writeTextLinesTask (object LinesObj, string FileName)

    Returns an IOTask that writes a list of text lines (joined with newlines) to the named file when run.

    • @p LinesObj is an AussomJavaObject around a List.
    • @p FileName is the destination file path relative to root.
    • @r An AussomJavaObject around an IOTask.
  • readDataTask (string FileName)

    Returns an IOTask that binary-deserializes the named file into an object when run.

    • @p FileName is the source file path relative to root.
    • @r An AussomJavaObject around an IOTask.
  • loadFileNamesTask (string DirName, bool Recursive)

    Returns an IOTask<List> that lists file names under the given directory. When recursive, descends into subdirectories.

    • @p DirName is the directory path relative to root.
    • @p Recursive when true descends into subdirectories.
    • @r An AussomJavaObject around an IOTask<List>.
  • loadFileNamesExtTask (string DirName, bool Recursive, object ExtensionsObj)

    Returns an IOTask<List> that lists file names under the given directory, restricted to files whose name ends with one of the supplied extensions.

    • @p DirName is the directory path relative to root.
    • @p Recursive when true descends into subdirectories.
    • @p ExtensionsObj is an AussomJavaObject around a List.
    • @r An AussomJavaObject around an IOTask<List>.
  • loadDirectoryNamesTask (string DirName, bool Recursive)

    Returns an IOTask<List> that lists directory names under the given directory.

    • @p DirName is the directory path relative to root.
    • @p Recursive when true descends into subdirectories.
    • @r An AussomJavaObject around an IOTask<List>.
  • loadLastModifiedFileTask (string DirName, bool Recursive)

    Returns an IOTask that loads the most recently modified file under the given directory by name, then deserializes it.

    • @p DirName is the directory path relative to root.
    • @p Recursive when true descends into subdirectories.
    • @r An AussomJavaObject around an IOTask.
  • deleteFileTask (string FileName)

    Returns an IOTask that deletes the named file when run.

    • @p FileName is the file path relative to root.
    • @r An AussomJavaObject around an IOTask.
  • deleteDirectoryTask (string DirName)

    Returns an IOTask that deletes the named directory (recursively) when run.

    • @p DirName is the directory path relative to root.
    • @r An AussomJavaObject around an IOTask.