Package

os

Permalink

package os

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. os
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait BasePath extends AnyRef

    Permalink

    A path which is either an absolute Path, a relative RelPath, or a ResourcePath with shared APIs and implementations.

    A path which is either an absolute Path, a relative RelPath, or a ResourcePath with shared APIs and implementations.

    Most of the filesystem-independent path-manipulation logic that lets you splice paths together or navigate in and out of paths lives in this interface

  2. trait BasePathImpl extends BasePath

    Permalink
  3. class Bytes extends AnyRef

    Permalink

    Trivial wrapper around Array[Byte] with sane equality and useful toString

  4. case class CommandResult(exitCode: Int, chunks: Seq[Either[Bytes, Bytes]]) extends Product with Serializable

    Permalink

    Contains the accumulated output for the invocation of a subprocess command.

    Contains the accumulated output for the invocation of a subprocess command.

    Apart from the exit code, the primary data-structure is a sequence of byte chunks, tagged with Left for stdout and Right for stderr. This is interleaved roughly in the order it was emitted by the subprocess, and reflects what a user would have see if the subprocess was run manually.

    Derived from that, is the aggregate out and err StreamValues, wrapping stdout/stderr respectively, and providing convenient access to the aggregate output of each stream, as bytes or strings or lines.

  5. trait FilePath extends BasePath

    Permalink

    Represents a value that is either an absolute Path or a relative RelPath, and can be constructed from a java.nio.file.Path or java.io.File

  6. sealed trait FileType extends AnyRef

    Permalink

    Simple enum with the possible filesystem objects a path can resolve to

  7. case class FullStatInfo(name: String, size: Long, mtime: FileTime, ctime: FileTime, atime: FileTime, group: GroupPrincipal, owner: UserPrincipal, permissions: PermSet, fileType: FileType) extends Product with Serializable

    Permalink

    A richer, more informative version of the stat object.

    A richer, more informative version of the stat object.

    Created using stat.full! filePath

  8. type Generator[+T] = geny.Generator[T]

    Permalink
  9. class GlobInterpolator extends AnyRef

    Permalink

    Lets you pattern match strings with interpolated glob-variables

  10. class Path extends FilePath with ReadablePath with BasePathImpl

    Permalink

    An absolute path on the filesystem.

    An absolute path on the filesystem. Note that the path is normalized and cannot contain any empty "", "." or ".." segments

  11. sealed trait PathConvertible[T] extends AnyRef

    Permalink
  12. class PermSet extends AnyRef

    Permalink

    A set of permissions; can be converted easily to the rw-rwx-r-x form via toString, or to the 0x777 form via toInt and the other way via PermSet.fromString/PermSet.fromInt

  13. trait ReadablePath extends AnyRef

    Permalink
  14. sealed trait Redirect extends AnyRef

    Permalink

    The different ways you can redirect input/output streams from a suprocess

  15. case class RedirectToPath(p: Path, append: Boolean = false) extends Redirect with Product with Serializable

    Permalink

    Redirect the input/output directly to a file on disk

  16. class RelPath extends FilePath with BasePathImpl with SegmentedPath

    Permalink

    A relative path on the filesystem.

    A relative path on the filesystem. Note that the path is normalized and cannot contain any empty or ".". Parent ".." segments can only occur at the left-end of the path, and are collapsed into a single number ups.

  17. case class ResourceNotFoundException(path: ResourcePath) extends Exception with Product with Serializable

    Permalink

    Thrown when you try to read from a resource that doesn't exist.

  18. class ResourcePath extends BasePathImpl with ReadablePath with SegmentedPath

    Permalink

    Represents path to a resource on the java classpath.

    Represents path to a resource on the java classpath.

    Classloaders are tricky: http://stackoverflow.com/questions/12292926

  19. sealed trait ResourceRoot extends AnyRef

    Permalink

    Represents a possible root where classpath resources can be loaded from; either a ResourceRoot.ClassLoader or a ResourceRoot.Class.

    Represents a possible root where classpath resources can be loaded from; either a ResourceRoot.ClassLoader or a ResourceRoot.Class. Resources loaded from classloaders are always loaded via their absolute path, while resources loaded via classes are always loaded relatively.

  20. trait SeekableSource extends Source

    Permalink

    A source which is guaranteeds to provide a SeekableByteChannel

  21. trait SegmentedPath extends BasePath

    Permalink
  22. case class Shellable(s: Seq[String]) extends Product with Serializable

    Permalink

    An implicit wrapper defining the things that can be "interpolated" directly into a subprocess call.

  23. trait Source extends AnyRef

    Permalink

    A source of bytes; must provide either an InputStream or a SeekableByteChannel to read from.

    A source of bytes; must provide either an InputStream or a SeekableByteChannel to read from. Can be constructed implicitly from strings, byte arrays, inputstreams, channels or file paths

  24. case class StatInfo(name: String, size: Long, mtime: FileTime, owner: UserPrincipal, permissions: PermSet, fileType: FileType) extends Product with Serializable

    Permalink

    The result from doing an system stat on a particular path.

    The result from doing an system stat on a particular path.

    Created via stat! filePath.

    If you want more information, use stat.full

  25. case class StreamValue(chunks: Seq[Bytes]) extends Product with Serializable

    Permalink

    Encapsulates one of the output streams from a subprocess and provides convenience methods for accessing it in a variety of forms

  26. case class SubprocessException(result: CommandResult) extends Exception with Product with Serializable

    Permalink

    Thrown when a shellout command results in a non-zero exit code.

    Thrown when a shellout command results in a non-zero exit code.

    Doesn't contain any additional information apart from the CommandResult that is normally returned, but ensures that failures in subprocesses happen loudly and won't get ignored unless intentionally caught

  27. trait WritableLowPri extends AnyRef

    Permalink
  28. case class proc(command: Shellable*) extends Product with Serializable

    Permalink

    Convenience APIs around java.lang.Process and java.lang.ProcessBuilder:

    Convenience APIs around java.lang.Process and java.lang.ProcessBuilder:

    - os.proc.call provides a convenient wrapper for "function-like" processes that you invoke with some input, whose entire output you need, but otherwise do not have any intricate back-and-forth communication

    - os.proc.stream provides a lower level API: rather than providing the output all at once, you pass in callbacks it invokes whenever there is a chunk of output received from the spawned process.

    - os.proc(...) provides the lowest level API: an simple Scala API around java.lang.ProcessBuilder, that spawns a normal java.lang.Process for you to deal with. You can then interact with it normally through the standard stdin/stdout/stderr streams, using whatever protocol you want

Value Members

  1. object /

    Permalink

    Extractor to let you easily pattern match on os.Paths.

    Extractor to let you easily pattern match on os.Paths. Lets you do

    @ val base/segment/filename = pwd
    base: Path = Path(Vector("Users", "haoyi", "Dropbox (Personal)"))
    segment: String = "Workspace"
    filename: String = "Ammonite"

    To break apart a path and extract various pieces of it.

  2. object BasePath

    Permalink
  3. object FilePath

    Permalink
  4. object FileType

    Permalink
  5. val Generator: geny.Generator.type

    Permalink
  6. object GlobInterpolator

    Permalink
  7. implicit def GlobSyntax(s: StringContext): GlobInterpolator

    Permalink
  8. object Inherit extends Redirect

    Permalink

    Inherit the input/output stream from the current process

  9. object Internals

    Permalink
  10. object Path

    Permalink
  11. object PathConvertible

    Permalink
  12. object PathError

    Permalink
  13. object PermSet

    Permalink
  14. object Pipe extends Redirect

    Permalink

    Pipe the input/output stream to the current process to be used via java.lang.Process#{getInputStream,getOutputStream,getErrorStream}

  15. object Redirect

    Permalink
  16. object RelPath

    Permalink
  17. object ResourcePath

    Permalink
  18. object ResourceRoot

    Permalink
  19. object SeekableSource

    Permalink
  20. object Shellable extends Serializable

    Permalink
  21. object Source extends WritableLowPri

    Permalink
  22. object copy

    Permalink

    Copy a file or folder from one path to another.

    Copy a file or folder from one path to another. Recursively copies folders with all their contents. Errors out if the destination path already exists, or is within the source path.

  23. object exists extends (Path) ⇒ Boolean

    Permalink

    Checks if a file or folder exists at the given path.

  24. object followLink extends (Path) ⇒ Option[Path]

    Permalink

    Attempts to any symbolic links in the given path and return the canonical path.

    Attempts to any symbolic links in the given path and return the canonical path. Returns None if the path cannot be resolved (i.e. some symbolic link in the given path is broken)

  25. object group extends (Path) ⇒ GroupPrincipal

    Permalink

    Get the owning group of the file/folder at the given path

  26. object hardlink

    Permalink

    Creates a hardlink between two paths

  27. val home: Path

    Permalink

    The user's home directory

  28. object isDir extends (Path) ⇒ Boolean

    Permalink

    Checks whether the given path is a directory

  29. object isFile extends (Path) ⇒ Boolean

    Permalink

    Checks whether the given path is a regular file

  30. object isLink extends (Path) ⇒ Boolean

    Permalink

    Checks whether the given path is a symbolic link

  31. object list extends (Path) ⇒ IndexedSeq[Path]

    Permalink

    Returns all the files and folders directly within the given folder.

    Returns all the files and folders directly within the given folder. If the given path is not a folder, raises an error. Can be called with list.stream to return an iterator. To list files recursively, use walk

  32. object makeDir extends (Path) ⇒ Unit

    Permalink

    Create a single directory at the specified path.

    Create a single directory at the specified path. Optionally takes in a PermSet to specify the filesystem permissions of the created directory.

    Errors out if the directory already exists, or if the parent directory of the specified path does not exist. To automatically create enclosing directories and ignore the destination if it already exists, using os.makeDir.all

  33. object move

    Permalink

    Moves a file or folder from one path to another.

    Moves a file or folder from one path to another. Errors out if the destination path already exists, or is within the source path.

  34. object mtime extends (Path) ⇒ Long

    Permalink

    Gets the mtime of the given file

  35. object owner extends (Path) ⇒ UserPrincipal

    Permalink

    Get the owner of the file/folder at the given path

  36. object perms extends (Path) ⇒ PermSet

    Permalink

    Get the filesystem permissions of the file/folder at the given path

  37. val pwd: Path

    Permalink

    The current working directory for this process.

  38. object read extends (ReadablePath) ⇒ String

    Permalink

    Reads the contents of a os.Path or other os.Source as a java.lang.String.

    Reads the contents of a os.Path or other os.Source as a java.lang.String. Defaults to reading the entire file as UTF-8, but you can also select a different charSet to use, and provide an offset/count to read from if the source supports seeking.

  39. val rel: RelPath

    Permalink
  40. object remove extends (Path) ⇒ Unit

    Permalink

    Roughly equivalent to bash's rm -rf.

    Roughly equivalent to bash's rm -rf. Deletes any files or folders in the target path, or does nothing if there aren't any

  41. def resource(implicit resRoot: ResourceRoot = ...): ResourcePath

    Permalink
  42. val root: Path

    Permalink

    The root of the filesystem

  43. object size extends (Path) ⇒ Long

    Permalink

    Gets the size of the given file

  44. object stat extends (Path) ⇒ StatInfo

    Permalink

    Reads in the basic filesystem metadata for the given file.

    Reads in the basic filesystem metadata for the given file. By default follows symbolic links to read the metadata of whatever the link is pointing at; set followLinks = false to disable that and instead read the metadata of the symbolic link itself.

  45. object symlink

    Permalink

    Creates a symbolic link between two paths

  46. object temp

    Permalink

    Alias for java.nio.file.Files.createTempFile and java.io.File.deleteOnExit.

    Alias for java.nio.file.Files.createTempFile and java.io.File.deleteOnExit. Pass in deleteOnExit = false if you want the temp file to stick around.

  47. val up: RelPath

    Permalink
  48. object walk

    Permalink

    Recursively walks the given folder and returns the paths of every file or folder within.

    Recursively walks the given folder and returns the paths of every file or folder within.

    You can pass in a skip callback to skip files or folders you are not interested in. This can avoid walking entire parts of the folder hierarchy, saving time as compared to filtering them after the fact.

    By default, the paths are returned as a pre-order traversal: the enclosing folder is occurs first before any of it's contents. You can pass in preOrder = false to turn it into a post-order traversal, such that the enclosing folder occurs last after all it's contents.

    os.walk returns but does not follow symlinks; pass in followLinks = true to override that behavior. You can also specify a maximum depth you wish to walk via the maxDepth parameter.

  49. object write

    Permalink

    Write some data to a file.

    Write some data to a file. This can be a String, an Array[Byte], or a Seq[String] which is treated as consecutive lines. By default, this fails if a file already exists at the target location. Use write.over or write.append if you want to over-write it or add to what's already there.

Inherited from AnyRef

Inherited from Any

Ungrouped