fs2.io.file

package fs2.io.file

Provides support for working with files.

Attributes

Members list

Type members

Classlikes

sealed trait BasicFileAttributes

Attributes of a file that are provided by most operating systems and file systems.

Attributes of a file that are provided by most operating systems and file systems.

To get an instance of BasicFileAttributes, use Files[F].getBasicFileAttributes(path).

The fileKey operation returns a unique identifier for the file, if the operating system and file system supports providing such an identifier.

Attributes

Companion
object
Source
FileAttributes.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Source
FileAttributes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final class CopyFlag extends AnyVal

Attributes

Companion
object
Source
CopyFlag.scala
Supertypes
class AnyVal
trait Matchable
class Any
object CopyFlag

Attributes

Companion
class
Source
CopyFlag.scala
Supertypes
class Object
trait Matchable
class Any
Self type
CopyFlag.type
case class CopyFlags(value: List[CopyFlag])

Attributes

Companion
object
Source
CopyFlags.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object CopyFlags

Attributes

Companion
class
Source
CopyFlags.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
CopyFlags.type
trait FileHandle[F[_]]

Provides the ability to read/write/lock/inspect a file in the effect F.

Provides the ability to read/write/lock/inspect a file in the effect F.

Attributes

Companion
object
Source
FileHandle.scala
Supertypes
class Object
trait Matchable
class Any
object FileHandle

Attributes

Companion
trait
Source
FileHandle.scala
Supertypes
class Object
trait Matchable
class Any
Self type
FileHandle.type
trait FileKey

An opaque, unique identifier for a file.

An opaque, unique identifier for a file.

Paths which have the same FileKey (via univerals equals), as reported by Files[F].getBasicFileAttributes(path).fileKey, are guaranteed to reference the same file on the file system.

Note: not all operating systems and file systems support file keys, hence BasicFileAttributes#fileKey returns an Option[FileKey].

Attributes

Companion
object
Source
FileKey.scala
Supertypes
class Object
trait Matchable
class Any
object FileKey

Attributes

Companion
trait
Source
FileKey.scala
Supertypes
class Object
trait Matchable
class Any
Self type
FileKey.type
sealed trait Files[F[_]]

Provides operations related to working with files in the effect F.

Provides operations related to working with files in the effect F.

An instance is available for any effect F which has an Async[F] instance.

The operations on this trait are implemented for both the JVM and Node.js. Some operations only work on POSIX file systems, though such methods generally have "Posix" in their names (e.g. getPosixPermissions). A small number of methods are only available on the JVM (e.g. variant of list which takes a glob pattern) and are indicated as such in their ScalaDoc.

Attributes

Companion
object
Source
Files.scala
Supertypes
class Object
trait Matchable
class Any
object Files

Attributes

Companion
trait
Source
Files.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Files.type
final class Flag extends AnyVal

Attributes

Companion
object
Source
Flag.scala
Supertypes
class AnyVal
trait Matchable
class Any
object Flag

Attributes

Companion
class
Source
Flag.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Flag.type
case class Flags(value: List[Flag])

Flags describing how a file should be opened by Files[F].open(path, flags).

Flags describing how a file should be opened by Files[F].open(path, flags).

Common flag combinations are available in the companion (e.g. Flags.Write) Custom combinations are supported via the apply method (e.g., Flags(Flag.Write, Flag.CreateNew)).

Attributes

Companion
object
Source
Flags.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Flags

Attributes

Companion
class
Source
Flags.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Flags.type
final class Path

Path to a file or directory on a file system.

Path to a file or directory on a file system.

The path API is inspired by the java.nio.file.Path API. On the JVM, a NIO path can be converted to an FS2 path via Path.fromNioPath(p) and likewise an FS2 path can be converted to a NIO path via p.toNioPath.

(When using this class on Node.js, the fromNioPath and toNioPath methods are not accessible.)

Generally, most methods have the same behavior as their NIO counterparts, though there are some slight differences -- e.g., resolve normalizes.

Attributes

Companion
object
Source
Path.scala
Supertypes
class Object
trait Matchable
class Any
object Path

Attributes

Companion
class
Source
Path.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Path.type
sealed trait Permissions

Describes the permissions of a file / directory.

Describes the permissions of a file / directory.

Note: currently, there is only one subtype -- PosixPermissions. More types may be added in the future (e.g. Windows ACLs).

Attributes

Source
Permissions.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
object
Source
FileAttributes.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
FileAttributes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait PosixPermission

Attributes

Companion
object
Source
Permissions.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object GroupExecute.type
object GroupRead.type
object GroupWrite.type
object OthersExecute.type
object OthersRead.type
object OthersWrite.type
object OwnerExecute.type
object OwnerRead.type
object OwnerWrite.type
Show all

Attributes

Companion
trait
Source
Permissions.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final class PosixPermissions extends Permissions

Describes POSIX file permissions, where the user, group, and others are each assigned read, write, and/or execute permissions.

Describes POSIX file permissions, where the user, group, and others are each assigned read, write, and/or execute permissions.

The toString method provides a 9 character string where the first three characters indicate user permissions, the next three group permissions, and the final three others permissions. For example, rwxr-xr-- indicates the owner has read, write and execute, the group as read and execute, and others have read.

The value field encodes the permissions in the lowest 9 bits of an integer. bits 8-6 indicate read, write, and execute for the owner, 5-3 for the group, and 2-0 for others. rwxr-xr-- has the integer value 111101100 = 492.

The toOctalString method returns the a 3 digit string, where the first character indicates read, write and execute for the owner, the second digit for the group, and the third digit for others. rwxr-xr-- has the octal string 754.

Constructors from strings, octal strings, and integers, as well as explicitly enumerating permissions, are provided in the companion.

Attributes

Companion
object
Source
Permissions.scala
Supertypes
trait Permissions
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
Permissions.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final case class ReadCursor[F[_]](file: FileHandle[F], offset: Long)

Associates a FileHandle with an offset in to the file.

Associates a FileHandle with an offset in to the file.

This encapsulates the pattern of incrementally reading bytes in from a file, a chunk at a time. Convenience methods are provided for working with pulls.

Attributes

Companion
object
Source
ReadCursor.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ReadCursor

Attributes

Companion
class
Source
ReadCursor.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ReadCursor.type
sealed abstract class Watcher[F[_]]

Allows watching the file system for changes to directories and files by using the platform's WatchService.

Allows watching the file system for changes to directories and files by using the platform's WatchService.

Attributes

Companion
object
Source
Watcher.scala
Supertypes
class Object
trait Matchable
class Any
object Watcher

Attributes

Companion
class
Source
Watcher.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Watcher.type
final case class WriteCursor[F[_]](file: FileHandle[F], offset: Long)

Associates a FileHandle with an offset in to the file.

Associates a FileHandle with an offset in to the file.

This encapsulates the pattern of incrementally writing bytes in to a file, a chunk at a time. Convenience methods are provided for working with pulls.

Attributes

Companion
object
Source
WriteCursor.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object WriteCursor

Attributes

Companion
class
Source
WriteCursor.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Types

type AccessDeniedException = AccessDeniedException

Attributes

Source
file.scala
type DirectoryNotEmptyException = DirectoryNotEmptyException

Attributes

Source
file.scala
type FileAlreadyExistsException = FileAlreadyExistsException

Attributes

Source
file.scala
type FileSystemException = FileSystemException

Attributes

Source
file.scala
type FileSystemLoopException = FileSystemLoopException

Attributes

Source
file.scala
type NoSuchFileException = NoSuchFileException

Attributes

Source
file.scala
type NotDirectoryException = NotDirectoryException

Attributes

Source
file.scala

Value members

Deprecated methods

def copy[F[_] : Async](source: Path, target: Path, flags: Seq[CopyOption]): F[Path]

Copies a file from the source to the target path,

Copies a file from the source to the target path,

By default, the copy fails if the target file already exists or is a symbolic link.

Attributes

Deprecated
true
Source
file.scala
def createDirectories[F[_] : Async](path: Path, flags: Seq[FileAttribute[_]]): F[Path]

Creates a new directory at the given path and creates all nonexistent parent directories beforehand.

Creates a new directory at the given path and creates all nonexistent parent directories beforehand.

Attributes

Deprecated
true
Source
file.scala
def createDirectory[F[_] : Async](path: Path, flags: Seq[FileAttribute[_]]): F[Path]

Creates a new directory at the given path

Creates a new directory at the given path

Attributes

Deprecated
true
Source
file.scala
def delete[F[_] : Async](path: Path): F[Unit]

Deletes a file.

Deletes a file.

If the file is a directory then the directory must be empty for this action to succeed. This action will fail if the path doesn't exist.

Attributes

Deprecated
true
Source
file.scala
def deleteDirectoryRecursively[F[_] : Async](path: Path, options: Set[FileVisitOption]): F[Unit]

Recursively delete a directory

Recursively delete a directory

Attributes

Deprecated
true
Source
file.scala
def deleteIfExists[F[_] : Async](path: Path): F[Boolean]

Like delete, but will not fail when the path doesn't exist.

Like delete, but will not fail when the path doesn't exist.

Attributes

Deprecated
true
Source
file.scala
def directoryStream[F[_] : Async](path: Path): Stream[F, Path]

Creates a stream of Paths inside a directory.

Creates a stream of Paths inside a directory.

Attributes

Deprecated
true
Source
file.scala
def directoryStream[F[_] : Async](path: Path, filter: Path => Boolean): Stream[F, Path]

Creates a stream of Paths inside a directory, filtering the results by the given predicate.

Creates a stream of Paths inside a directory, filtering the results by the given predicate.

Attributes

Deprecated
true
Source
file.scala
def directoryStream[F[_] : Async](path: Path, glob: String): Stream[F, Path]

Creates a stream of Paths inside a directory which match the given glob.

Creates a stream of Paths inside a directory which match the given glob.

Attributes

Deprecated
true
Source
file.scala
def exists[F[_] : Async](path: Path, flags: Seq[LinkOption]): F[Boolean]

Checks if a file exists

Checks if a file exists

Note that the result of this method is immediately outdated. If this method indicates the file exists then there is no guarantee that a subsequence access will succeed. Care should be taken when using this method in security sensitive applications.

Attributes

Deprecated
true
Source
file.scala
def move[F[_] : Async](source: Path, target: Path, flags: Seq[CopyOption]): F[Path]

Moves (or renames) a file from the source to the target path.

Moves (or renames) a file from the source to the target path.

By default, the move fails if the target file already exists or is a symbolic link.

Attributes

Deprecated
true
Source
file.scala
def permissions[F[_] : Async](path: Path, flags: Seq[LinkOption]): F[Set[PosixFilePermission]]

Get file permissions as set of PosixFilePermission.

Get file permissions as set of PosixFilePermission.

This will only work for POSIX supporting file systems

Attributes

Deprecated
true
Source
file.scala
def readAll[F[_] : Async](path: Path, chunkSize: Int): Stream[F, Byte]

Attributes

Deprecated
true
Source
file.scala
def readRange[F[_] : Async](path: Path, chunkSize: Int, start: Long, end: Long): Stream[F, Byte]

Reads a range of data synchronously from the file at the specified java.nio.file.Path.

Reads a range of data synchronously from the file at the specified java.nio.file.Path. start is inclusive, end is exclusive, so when start is 0 and end is 2, two bytes are read.

Attributes

Deprecated
true
Source
file.scala
def setPermissions[F[_] : Async](path: Path, permissions: Set[PosixFilePermission]): F[Path]

Set file permissions from set of PosixFilePermission.

Set file permissions from set of PosixFilePermission.

This will only work for POSIX supporting file systems

Attributes

Deprecated
true
Source
file.scala
def size[F[_] : Async](path: Path): F[Long]

Returns the size of a file (in bytes).

Returns the size of a file (in bytes).

Attributes

Deprecated
true
Source
file.scala
def tail[F[_] : Async](path: Path, chunkSize: Int, offset: Long, pollDelay: FiniteDuration): Stream[F, Byte]

Returns an infinite stream of data from the file at the specified path.

Returns an infinite stream of data from the file at the specified path. Starts reading from the specified offset and upon reaching the end of the file, polls every pollDuration for additional updates to the file.

Read operations are limited to emitting chunks of the specified chunk size but smaller chunks may occur.

If an error occurs while reading from the file, the overall stream fails.

Attributes

Deprecated
true
Source
file.scala
def tempDirectoryResource[F[_] : Async](dir: Path, prefix: String, attributes: Seq[FileAttribute[_]]): Resource[F, Path]

Creates a resource containing the path of a temporary directory.

Creates a resource containing the path of a temporary directory.

The temporary directory is removed during the resource release.

Attributes

Deprecated
true
Source
file.scala
def tempDirectoryStream[F[_] : Async](dir: Path, prefix: String, attributes: Seq[FileAttribute[_]]): Stream[F, Path]

Creates a stream containing the path of a temporary directory.

Creates a stream containing the path of a temporary directory.

The temporary directory is removed when the stream completes.

Attributes

Deprecated
true
Source
file.scala
def tempFileResource[F[_] : Async](dir: Path, prefix: String, suffix: String, attributes: Seq[FileAttribute[_]]): Resource[F, Path]

Creates a resource containing the path of a temporary file.

Creates a resource containing the path of a temporary file.

The temporary file is removed during the resource release.

Attributes

Deprecated
true
Source
file.scala
def tempFileStream[F[_] : Async](dir: Path, prefix: String, suffix: String, attributes: Seq[FileAttribute[_]]): Stream[F, Path]

Creates a stream containing the path of a temporary file.

Creates a stream containing the path of a temporary file.

The temporary file is removed when the stream completes.

Attributes

Deprecated
true
Source
file.scala
def walk[F[_] : Async](start: Path): Stream[F, Path]

Creates a stream of Paths contained in a given file tree.

Creates a stream of Paths contained in a given file tree. Depth is unlimited.

Attributes

Deprecated
true
Source
file.scala
def walk[F[_] : Async](start: Path, options: Seq[FileVisitOption]): Stream[F, Path]

Creates a stream of Paths contained in a given file tree, respecting the supplied options.

Creates a stream of Paths contained in a given file tree, respecting the supplied options. Depth is unlimited.

Attributes

Deprecated
true
Source
file.scala
def walk[F[_] : Async](start: Path, maxDepth: Int, options: Seq[FileVisitOption]): Stream[F, Path]

Creates a stream of Paths contained in a given file tree down to a given depth.

Creates a stream of Paths contained in a given file tree down to a given depth.

Attributes

Deprecated
true
Source
file.scala
def watch[F[_]](path: Path, types: Seq[EventType], modifiers: Seq[Modifier], pollTimeout: FiniteDuration)(implicit F: Async[F]): Stream[F, Event]

Watches a single path.

Watches a single path.

Alias for creating a watcher and watching the supplied path, releasing the watcher when the resulting stream is finalized.

Attributes

Deprecated
true
Source
file.scala
def watcher[F[_]](implicit F: Async[F]): Resource[F, Watcher[F]]

Creates a Watcher for the default file system.

Creates a Watcher for the default file system.

The watcher is returned as a resource. To use the watcher, lift the resource to a stream, watch or register 1 or more paths, and then return watcher.events().

Attributes

Deprecated
true
Source
file.scala
def writeAll[F[_] : Async](path: Path, flags: Seq[StandardOpenOption]): (F, Byte) => Nothing

Writes all data to the file at the specified java.nio.file.Path.

Writes all data to the file at the specified java.nio.file.Path.

Adds the WRITE flag to any other OpenOption flags specified. By default, also adds the CREATE flag.

Attributes

Deprecated
true
Source
file.scala
def writeRotate[F[_]](computePath: F[Path], limit: Long, flags: Seq[StandardOpenOption])(implicit F: Async[F]): (F, Byte) => Nothing

Writes all data to a sequence of files, each limited in size to limit.

Writes all data to a sequence of files, each limited in size to limit.

The computePath operation is used to compute the path of the first file and every subsequent file. Typically, the next file should be determined by analyzing the current state of the filesystem -- e.g., by looking at all files in a directory and generating a unique name.

Attributes

Deprecated
true
Source
file.scala