p

os

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

    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
  3. trait Checker extends AnyRef

    Defines hooks for path based operations.

    Defines hooks for path based operations.

    This, in conjunction with checker, can be used to implement custom checks like

    • restricting an operation to some path(s)
    • logging an operation
    Annotations
    @experimental()
  4. case class CommandResult(command: Seq[String], exitCode: Int, chunks: Seq[Either[Bytes, Bytes]]) extends Product with Serializable

    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. sealed trait FilePath extends BasePath

    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

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

  7. trait GeneratedTupleConversions[R] extends AnyRef
  8. type Generator[+T] = geny.Generator[T]
  9. class GlobInterpolator extends AnyRef

    Lets you pattern match strings with interpolated glob-variables

  10. class Path extends FilePath with ReadablePath with BasePathImpl

    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. case class PathAppendRedirect(p: Path) extends ProcessOutput with Product with Serializable
  12. trait PathChunk extends AnyRef
  13. trait PathChunkMacros extends StringPathChunkConversion
  14. sealed trait PathConvertible[T] extends AnyRef
  15. trait PathMacros extends StringPathChunkConversion
  16. case class PathRedirect(p: Path) extends ProcessInput with ProcessOutput with Product with Serializable
  17. case class PermSet(value: Int) extends Product with Serializable

    A set of permissions; can be converted easily to the rw-rwx-r-x form via toString, or to a set of PosixFilePermissions via toSet and the other way via PermSet.fromString/PermSet.fromSet

  18. case class PosixStatInfo(owner: UserPrincipal, permissions: PermSet) extends Product with Serializable
  19. case class ProcGroup extends Product with Serializable

    A group of processes that are piped together, corresponding to e.g.

    A group of processes that are piped together, corresponding to e.g. ls -l | grep .scala. You can create a ProcGroup by calling .pipeTo on a proc multiple times. Contains methods corresponding to the methods on proc, but defined for pipelines of processes.

  20. trait ProcessInput extends AnyRef

    Represents the configuration of a SubProcess's input stream.

    Represents the configuration of a SubProcess's input stream. Can either be os.Inherit, os.Pipe, os.Path or a os.Source

  21. sealed trait ProcessLike extends AutoCloseable

    Parent type for single processes and process pipelines.

  22. trait ProcessOutput extends AnyRef

    Represents the configuration of a SubProcess's output or error stream.

    Represents the configuration of a SubProcess's output or error stream. Can either be os.Inherit, os.Pipe, os.Path or a os.ProcessOutput

  23. class ProcessPipeline extends ProcessLike
    Annotations
    @deprecatedInheritance( ... , "0.10.4" )
  24. trait ReadablePath extends AnyRef
  25. class RelPath extends FilePath with BasePathImpl with SegmentedPath

    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.

  26. trait RelPathMacros extends StringPathChunkConversion
  27. case class ResourceNotFoundException(path: ResourcePath) extends Exception with Product with Serializable

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

  28. class ResourcePath extends BasePathImpl with ReadablePath with SegmentedPath

    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

  29. sealed trait ResourceRoot extends AnyRef

    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.

  30. trait SeekableSource extends Source

    A source which is guaranteeds to provide a SeekableByteChannel

  31. trait SegmentedPath extends BasePath
  32. case class Shellable(value: Seq[String]) extends Product with Serializable

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

  33. trait Source extends Writable

    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

  34. case class StatInfo(size: Long, mtime: FileTime, ctime: FileTime, atime: FileTime, fileType: FileType) extends Product with Serializable

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

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

    Note: ctime is not same as ctime (Change Time) in stat, it is creation time maybe fall back to mtime if system not supported it.

    Created via stat! filePath.

    If you want more information, use stat.full

  35. trait StringPathChunkConversion extends AnyRef
  36. class SubPath extends FilePath with BasePathImpl with SegmentedPath

    A relative path on the filesystem, without any .. or . segments

  37. trait SubPathMacros extends StringPathChunkConversion
  38. class SubProcess extends ProcessLike

    Represents a spawn subprocess that has started and may or may not have completed.

    Represents a spawn subprocess that has started and may or may not have completed.

    Annotations
    @deprecatedInheritance( ... , "0.10.4" )
  39. case class SubprocessException(result: CommandResult) extends Exception with Product with Serializable

    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

  40. trait WritableLowPri extends AnyRef
  41. class experimental extends Annotation with StaticAnnotation

    Annotation to mark experimental API, which is not guaranteed to stay.

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

    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. val Generator: geny.Generator.type
  2. implicit def GlobSyntax(s: StringContext): GlobInterpolator
  3. val checker: DynamicVariable[Checker]
  4. val dynamicPwd: DynamicVariable[Path]

    Used to override pwd within a certain scope with a fixed value

  5. val dynamicPwdFunction: DynamicVariable[() ⇒ Path]

    Used to override pwd within a certain scope with a generated value

  6. def home: Path

    The user's home directory

  7. def pwd: Path

    The current working directory for this process.

  8. val rel: RelPath
  9. def resource(implicit resRoot: ResourceRoot = ...): ResourcePath
  10. def root(root: String, fileSystem: FileSystem = FileSystems.getDefault()): Path
  11. val root: Path

    The root of the filesystem

  12. val sub: SubPath
  13. val up: RelPath
  14. object /

    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.

  15. object BasePath
  16. object Checker
    Annotations
    @experimental()
  17. object FilePath
  18. object FileType
  19. object GlobInterpolator
  20. object Inherit extends ProcessInput with ProcessOutput

    Inherit the input/output stream from the current process.

    Inherit the input/output stream from the current process.

    Can be overriden on a thread local basis for the various kinds of streams (stdin, stdout, stderr) via in, out, and err

  21. object InheritRaw extends ProcessInput with ProcessOutput

    Inherit the input/output stream from the current process.

    Inherit the input/output stream from the current process. Identical of os.Inherit, except it cannot be redirected globally

  22. object Internals
  23. object Macros
  24. object Path extends PathMacros
  25. object PathChunk extends PathChunkMacros
  26. object PathConvertible
  27. object PathError
  28. object PermSet extends Serializable
  29. object Pipe extends ProcessInput with ProcessOutput

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

  30. object PosixStatInfo extends Serializable
  31. object ProcessInput
  32. object ProcessOutput
  33. object RelPath extends RelPathMacros
  34. object ResourcePath
  35. object ResourceRoot
  36. object SeekableSource
  37. object Shellable extends GeneratedTupleConversions[Shellable] with Serializable
  38. object Source extends WritableLowPri
  39. object StatInfo extends Serializable
  40. object SubPath extends SubPathMacros
  41. object SubProcess
  42. object call
  43. object copy

    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.

  44. object exists extends (Path) ⇒ Boolean

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

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

    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)

  46. object group extends (Path) ⇒ GroupPrincipal

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

  47. object hardlink

    Creates a hardlink between two paths

  48. object isDir extends (Path) ⇒ Boolean

    Checks whether the given path is a directory

    Checks whether the given path is a directory

    Returns false if the path does not exist

  49. object isFile extends (Path) ⇒ Boolean

    Checks whether the given path is a regular file

    Checks whether the given path is a regular file

    Returns false if the path does not exist

  50. object isLink extends (Path) ⇒ Boolean

    Checks whether the given path is a symbolic link

    Checks whether the given path is a symbolic link

    Returns false if the path does not exist

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

    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

    For convenience os.list sorts the entries in the folder before returning them. You can disable sorted by passing in the flag sort = false.

  52. object makeDir extends (Path) ⇒ Unit

    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

  53. object move

    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.

  54. object mtime extends (Path) ⇒ Long

    Gets the mtime of the given file or directory

  55. object owner extends (Path) ⇒ UserPrincipal

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

  56. object perms extends (Path) ⇒ PermSet

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

  57. object read extends (ReadablePath) ⇒ String

    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.

  58. object readLink extends (Path) ⇒ FilePath

    Reads the destination that the given symbolic link is pointed to

  59. object remove extends (Path) ⇒ Boolean

    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

  60. object size extends (Path) ⇒ Long

    Gets the size of the given file or folder

    Gets the size of the given file or folder

    Throws an exception if the file or folder does not exist

    When called on folders, returns the size of the folder metadata (i.e. the list of children names), and not the size of the folder's recursive contents. Use os.walk if you want to sum up the total size of a directory tree.

  61. object spawn
  62. object stat extends (Path) ⇒ StatInfo

    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.

    Throws an exception if the file or folder does not exist

  63. object symlink

    Creates a symbolic link between two paths

  64. object temp

    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.

  65. object truncate

    Truncate the given file to the given size.

    Truncate the given file to the given size. If the file is smaller than the given size, does nothing.

  66. object unzip
  67. object walk

    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.

  68. object write

    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.

  69. object zip

Inherited from AnyRef

Inherited from Any

Ungrouped