Back to Pocketbase

Interface dirFS

static/jsvm/interfaces/os.dirFS.html

latest2.6 KB
Original Source

Interface dirFS

Hierarchy

  • String

    • dirFS
  • dirFS(dir): FS

DirFS returns a file system (an fs.FS) for the tree of files rooted at the directory dir.

Note that DirFS("/prefix") only guarantees that the Open calls it makes to the operating system will begin with "/prefix": DirFS("/prefix").Open("file") is the same as os.Open("/prefix/file"). So if /prefix/file is a symbolic link pointing outside the /prefix tree, then using DirFS does not stop the access any more than using os.Open does. Additionally, the root of the fs.FS returned for a relative path, DirFS("prefix"), will be affected by later calls to Chdir. DirFS is therefore not a general substitute for a chroot-style security mechanism when the directory tree contains arbitrary content.

Use [Root.FS] to obtain a fs.FS that prevents escapes from the tree via symbolic links.

The directory dir must not be "".

The result implements [io/fs.StatFS], [io/fs.ReadFileFS] and [io/fs.ReadDirFS].

Parameters

dir: string

Returns FS

Index

Methods

openreadDirreadFilestat

Methods

open

Parameters

name: string

Returns fs.File

readDir

ReadDir reads the named directory, returning all its directory entries sorted by filename. Through this method, dirFS implements [io/fs.ReadDirFS].

Parameters

name: string

Returns os.DirEntry[]

readFile

  • readFile(name): string | number[]

The ReadFile method calls the [ReadFile] function for the file with the given name in the directory. The function provides robust handling for small files and special file systems. Through this method, dirFS implements [io/fs.ReadFileFS].

Parameters

name: string

Returns string | number[]

stat

Parameters

name: string

Returns fs.FileInfo

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

On This Page

Generated using TypeDoc