os

Types from the Go package os (a library PocketBase builds on), as JavaScript sees them: they turn up as values of PocketBase's types and of hook events.

os.readdirMode

Has everything Number has.

os.File

Has everything file has.

Member Type
readdir() (n: number): Array<FileInfo> Readdir reads the contents of the directory associated with file and returns a slice of up to n FileInfo values, as would be returned by Lstat, in directory order. Subsequent calls on the same file will yield further FileInfos.
readdirnames() (n: number): Array<string> Readdirnames reads the contents of the directory associated with file and returns a slice of up to n names of files in the directory, in directory order. Subsequent calls on the same file will yield further names.
readDir() (n: number): Array<DirEntry> ReadDir reads the contents of the directory associated with the file f and returns a slice of DirEntry values in directory order. Subsequent calls on the same file will yield later DirEntry records in the directory.
name() (): string Name returns the name of the file as presented to Open.
read() (b: string|Array<number>): number Read reads up to len(b) bytes from the File and stores them in b. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF.
readAt() (b: string|Array<number>, off: number): number ReadAt reads len(b) bytes from the File starting at byte offset off. It returns the number of bytes read and the error, if any. ReadAt always returns a non-nil error when n < len(b). At end of file, that error is io.EOF.
readFrom() (r: io.Reader): number ReadFrom implements io.ReaderFrom.
write() (b: string|Array<number>): number Write writes len(b) bytes from b to the File. It returns the number of bytes written and an error, if any. Write returns a non-nil error when n != len(b).
writeAt() (b: string|Array<number>, off: number): number WriteAt writes len(b) bytes to the File starting at byte offset off. It returns the number of bytes written and an error, if any. WriteAt returns a non-nil error when n != len(b).
writeTo() (w: io.Writer): number WriteTo implements io.WriterTo.
seek() (offset: number, whence: number): number Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any. The behavior of Seek on a file opened with O_APPEND is not specified.
writeString() (s: string): number WriteString is like Write, but writes the contents of string s rather than a slice of bytes.
chmod() (mode: FileMode): void Chmod changes the mode of the file to mode. If there is an error, it will be of type [*PathError].
setDeadline() (t: time.Time): void SetDeadline sets the read and write deadlines for a File. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
setReadDeadline() (t: time.Time): void SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out. Not all files support setting deadlines; see SetDeadline.
setWriteDeadline() (t: time.Time): void SetWriteDeadline sets the deadline for any future Write calls and any currently-blocked Write call. Even if Write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out. Not all files support setting deadlines; see SetDeadline.
syscallConn() (): syscall.RawConn SyscallConn returns a raw file. This implements the syscall.Conn interface.
fd() (): number Fd returns the system file descriptor or handle referencing the open file. If f is closed, the descriptor becomes invalid. If f is garbage collected, a finalizer may close the descriptor, making it invalid; see runtime.setFinalizer for more information on when a finalizer might be run.
close() (): void Close closes the File, rendering it unusable for I/O. On files that support File.setDeadline, any pending I/O operations will be canceled and return immediately with an ErrClosed error. Close will return an error if it has already been called.
chown() (uid: number, gid: number): void Chown changes the numeric uid and gid of the named file. If there is an error, it will be of type [*PathError].
truncate() (size: number): void Truncate changes the size of the file. It does not change the I/O offset. If there is an error, it will be of type [*PathError].
sync() (): void Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.
chdir() (): void Chdir changes the current working directory to the file, which must be a directory. If there is an error, it will be of type [*PathError].
stat() (): FileInfo Stat returns the FileInfo structure describing file. If there is an error, it will be of type [*PathError].

os.DirEntry

A DirEntry is an entry read from a directory (using the ReadDir function or a File.readDir method).

Has everything fs.DirEntry has.

os.dirInfo

Auxiliary information if the File describes a directory

os.timeout

Member Type
timeout() (): boolean

os.PathError

PathError records an error and the operation and file path that caused it.

Has everything fs.PathError has.

os.SyscallError

SyscallError records an error from a specific system call.

Member Type
syscall string
err Error
error() (): string
unwrap() (): void
timeout() (): boolean Timeout reports whether this error represents a timeout.

os.syscallErrorType

Has everything syscall.Errno has.

os.processStatus

processStatus describes the status of a Process.

Has everything Number has.

os.Process

Process stores the information about a process created by StartProcess.

Member Type
pid number Pid is the operating system process ID.
release() (): void Release releases any resources associated with the Process p, rendering it unusable in the future. Release only needs to be called if Process.wait is not.
kill() (): void Kill causes the Process to exit immediately. Kill does not wait until the Process has actually exited. This only kills the Process itself, not any other processes it may have started.
wait() (): (ProcessState) Wait waits for the Process to exit, and then returns a ProcessState describing its status and an error, if any. Wait releases any resources associated with the Process. On most operating systems, the Process must be a child of the current process or an error will be returned.
signal() (sig: Signal): void Signal sends a signal to the Process. Sending Interrupt on Windows is not implemented.
withHandle() (f: (handle: number) => void): void WithHandle calls a supplied function f with a valid process handle as an argument. The handle is guaranteed to refer to process p until f returns, even if p terminates. This function cannot be used after Process.release or Process.wait.

os.processHandle

processHandle holds an operating system handle to a process. This is only used on systems that support that concept, currently Linux and Windows. This maintains a reference count to the handle, and closes the handle when the reference drops to zero.

os.ProcAttr

ProcAttr holds the attributes that will be applied to a new process started by StartProcess.

Member Type
dir string If Dir is non-empty, the child changes into the directory before creating the process.
env Array<string> If Env is non-nil, it gives the environment variables for the new process in the form returned by Environ. If it is nil, the result of Environ will be used.
files Array<(File | undefined)> Files specifies the open files inherited by the new process. The first three entries correspond to standard input, standard output, and standard error. An implementation may support additional entries, depending on the underlying operating system. A nil entry corresponds to that file being closed when the process starts. On Unix systems, StartProcess will change these File values to blocking mode, which means that SetDeadline will stop working and calling Close will not interrupt a Read or Write.
sys? syscall.SysProcAttr Operating system-specific process creation attributes. Note that setting this field means that your program may not execute properly or even compile on some operating systems.

os.Signal

A Signal represents an operating system signal. The usual underlying implementation is operating system-dependent: on Unix it is syscall.Signal.

Member Type
string() (): string
signal() (): void // to distinguish from other Stringers

os.ProcessState

ProcessState stores information about a process, as reported by Wait.

Member Type
userTime() (): time.Duration UserTime returns the user CPU time of the exited process and its children.
systemTime() (): time.Duration SystemTime returns the system CPU time of the exited process and its children.
exited() (): boolean Exited reports whether the program has exited. On Unix systems this reports true if the program exited due to calling exit, but false if the program terminated due to a signal.
success() (): boolean Success reports whether the program exited successfully, such as with exit status 0 on Unix.
sys() (): any Sys returns system-dependent exit information about the process. Convert it to the appropriate underlying type, such as syscall.waitStatus on Unix, to access its contents.
sysUsage() (): any SysUsage returns system-dependent resource usage information about the exited process. Convert it to the appropriate underlying type, such as [*syscall.Rusage] on Unix, to access its contents. (On Unix, *syscall.Rusage matches struct rusage as defined in the getrusage(2) manual page.)
pid() (): number Pid returns the process id of the exited process.
string() (): string
exitCode() (): number ExitCode returns the exit code of the exited process, or -1 if the process hasn't exited or was terminated by a signal.

os.LinkError

LinkError records an error during a link or symlink or rename system call and the paths that caused it.

Member Type
op string
old string
new string
err Error
error() (): string
unwrap() (): void

os.noReadFrom

noReadFrom can be embedded alongside another type to hide the ReadFrom method of that other type.

Member Type
readFrom() (_arg0: io.Reader): number ReadFrom hides another ReadFrom method. It should never be called.

os.fileWithoutReadFrom

Has everything noReadFrom, File has.

os.noWriteTo

noWriteTo can be embedded alongside another type to hide the WriteTo method of that other type.

Member Type
writeTo() (_arg0: io.Writer): number WriteTo hides another WriteTo method. It should never be called.

os.fileWithoutWriteTo

Has everything noWriteTo, File has.

os.file

file is the real representation of *File. The extra level of indirection ensures that no clients of os can overwrite this data, which could cause the finalizer to close the wrong file descriptor.

os.newFileKind

newFileKind describes the kind of file to newFile.

Has everything Number has.

os.unixDirent

Member Type
name() (): string
isDir() (): boolean
type() (): FileMode
info() (): FileInfo
string() (): string

os.rawConn

rawConn implements syscall.RawConn.

Member Type
control() (f: (_arg0: number) => void): void
read() (f: (_arg0: number) => boolean): void
write() (f: (_arg0: number) => boolean): void

os.Root

Root may be used to only access files within a single directory tree.

Methods on Root can only access files and directories beneath a root directory. If any component of a file name passed to a method of Root references a location outside the root, the method returns an error. File names may reference the directory itself (.).

Methods on Root will follow symbolic links, but symbolic links may not reference a location outside the root. Symbolic links must not be absolute.

Methods on Root do not prohibit traversal of filesystem boundaries, Linux bind mounts, /proc special files, or access to Unix device files.

Methods on Root are safe to be used from multiple goroutines simultaneously.

On most platforms, creating a Root opens a file descriptor or handle referencing the directory. If the directory is moved, methods on Root reference the original directory in its new location.

Root's behavior differs on some platforms:

  - When GOOS=windows, file names may not reference Windows reserved device names
    such as NUL and COM1.
  - On Unix, [Root.Chmod], [Root.Chown], and [Root.Chtimes] are vulnerable to a race condition.
    If the target of the operation is changed from a regular file to a symlink
    while the operation is in progress, the operation may be performed on the link
    rather than the link target.
  - When GOOS=js, Root is vulnerable to TOCTOU (time-of-check-time-of-use)
    attacks in symlink validation, and cannot ensure that operations will not
    escape the root.
  - When GOOS=plan9 or GOOS=js, Root does not track directories across renames.
    On these platforms, a Root references a directory name, not a file descriptor.
  - WASI preview 1 (GOOS=wasip1) does not support [Root.Chmod].
Member Type
name() (): string Name returns the name of the directory presented to OpenRoot.
close() (): void Close closes the Root. After Close is called, methods on Root return errors.
open() (name: string): (File) Open opens the named file in the root for reading. See Open for more details.
create() (name: string): (File) Create creates or truncates the named file in the root. See Create for more details.
openFile() (name: string, flag: number, perm: FileMode): (File) OpenFile opens the named file in the root. See OpenFile for more details.
openRoot() (name: string): (Root) OpenRoot opens the named directory in the root. If there is an error, it will be of type [*PathError].
chmod() (name: string, mode: FileMode): void Chmod changes the mode of the named file in the root to mode. See Chmod for more details.
mkdir() (name: string, perm: FileMode): void Mkdir creates a new directory in the root with the specified name and permission bits (before umask). See Mkdir for more details.
mkdirAll() (name: string, perm: FileMode): void MkdirAll creates a new directory in the root, along with any necessary parents. See MkdirAll for more details.
chown() (name: string, uid: number, gid: number): void Chown changes the numeric uid and gid of the named file in the root. See Chown for more details.
lchown() (name: string, uid: number, gid: number): void Lchown changes the numeric uid and gid of the named file in the root. See Lchown for more details.
chtimes() (name: string, atime: time.Time, mtime: time.Time): void Chtimes changes the access and modification times of the named file in the root. See Chtimes for more details.
remove() (name: string): void Remove removes the named file or (empty) directory in the root. See Remove for more details.
removeAll() (name: string): void RemoveAll removes the named file or directory and any children that it contains. See RemoveAll for more details.
stat() (name: string): FileInfo Stat returns a FileInfo describing the named file in the root. See Stat for more details.
lstat() (name: string): FileInfo Lstat returns a FileInfo describing the named file in the root. If the file is a symbolic link, the returned FileInfo describes the symbolic link. See Lstat for more details.
readlink() (name: string): string Readlink returns the destination of the named symbolic link in the root. See Readlink for more details.
rename() (oldname: string, newname: string): void Rename renames (moves) oldname to newname. Both paths are relative to the root. See Rename for more details.
link() (oldname: string, newname: string): void Link creates newname as a hard link to the oldname file. Both paths are relative to the root. See Link for more details.
symlink() (oldname: string, newname: string): void Symlink creates newname as a symbolic link to oldname. See Symlink for more details.
readFile() (name: string): string|Array<number> ReadFile reads the named file in the root and returns its contents. See ReadFile for more details.
writeFile() (name: string, data: string|Array<number>, perm: FileMode): void WriteFile writes data to the named file in the root, creating it if necessary. See WriteFile for more details.
fs() (): fs.FS FS returns a file system (an fs.FS) for the tree of files in the root.

os.rootFS

Has everything Root has.

Member Type
open() (name: string): fs.File
readDir() (name: string): Array<DirEntry>
readFile() (name: string): string|Array<number>
readLink() (name: string): string
stat() (name: string): FileInfo
lstat() (name: string): FileInfo

os.root

root implementation for platforms with a function to open a file relative to a directory.

Member Type
close() (): void
name() (): string

errSymlink reports that a file being operated on is actually a symlink, and the target of that symlink.

Has everything String has.

Member Type
error() (): string

os.sysfdType

sysfdType is the native type of a file handle (int on Unix, syscall.Handle on Windows), permitting helper functions to be written portably.

Has everything Number has.

os.FileInfo

A FileInfo describes a file and is returned by Stat and Lstat.

Has everything fs.FileInfo has.

os.FileMode

A FileMode represents a file's mode and permission bits. The bits have the same definition on all systems, so that information about files can be moved from one system to another portably. Not all bits apply to all systems. The only required bit is ModeDir for directories.

Has everything fs.FileMode has.

os.fileStat

A fileStat is the implementation of FileInfo returned by Stat and Lstat.

Member Type
name() (): string
isDir() (): boolean
size() (): number
mode() (): FileMode
modTime() (): time.Time
sys() (): any