Trait

sclib.io.fs

FSEntry

Related Doc: package fs

Permalink

trait FSEntry[Self <: FSEntry[Self]] extends AnyRef

File System Entry

Self Type
Self
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FSEntry
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val path: Path

    Permalink

    underlying path

  2. abstract def withPath(p: Path): Self

    Permalink
    Attributes
    protected[sclib.io.fs]

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. lazy val absNormalizedPath: Path

    Permalink

    absolute, normalized path

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def chmod(mode: String): Try[Self]

    Permalink

    set entry permission mode

    set entry permission mode

    mode

    : list of unix like symbolic permissions notation

    Example:
    1. chmod("a=r,u+w") -> chmod(Seq(OWNER_READ, OWNER_WRITE, GROUP_READ, OTHERS_READ))
      chmod("a+x")     -> current permissions + Seq(OWNER_EXECUTE, GROUP_EXECUTE, OTHERS_EXECUTE)
  7. def chmod(n: Int): Try[Self]

    Permalink

    set entry permission mode

    set entry permission mode

    n

    : unix like file permission notation

    Example:
    1. chmod(700) -> chmod(Seq(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE))
      chmod(644) -> chmod(Seq(OWNER_READ, OWNER_WRITE, GROUP_READ, OTHERS_READ))
  8. def chmod(perms: PosixFilePermission*): Try[Self]

    Permalink

    set entry permission mode

    set entry permission mode

    perms

    : sequence of http://http://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFilePermission.html

    Example:
    1. scala> import java.nio.file.attribute.PosixFilePermission._
      scala> for {
           |   wd <- dir("sclib-example")
           |   wd <- wd.createTemp
           |   fh <- file(wd, "a-file").flatMap(_.create)
           |   _ <- fh.chmod(OWNER_READ)
           |   mod <- fh.lsmod
           |   _ <- wd.deleteR()
           | } yield mod
      res0: scala.util.Try[Seq[java.nio.file.attribute.PosixFilePermission]] = Success(List(OWNER_READ))
  9. def chmodR(mode: String): Try[Self]

    Permalink

    set entry permission mode recursive

    set entry permission mode recursive

    fail on any error

    See also

    FSEntry.chmod(mode:String)*

  10. def chmodR(n: Int): Try[Self]

    Permalink

    set entry permission mode recursive

    set entry permission mode recursive

    fail on any error

    See also

    FSEntry.chmod(n:Int)*

  11. def chmodR(perms: PosixFilePermission*): Try[Self]

    Permalink

    set entry permission mode recursive

    set entry permission mode recursive

    fail on any error

    See also

    FSEntry.chmod(perms:java\.nio\.file\.attribute\.PosixFilePermission*)*

  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def copy(target: Self, options: CopyOption*): Try[Self]

    Permalink

    copy the entry (file -> file, dir -> dir)

    copy the entry (file -> file, dir -> dir)

    options

    http://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html

    Example:
    1. scala> for {
           |   wd <- dir("sclib-example")
           |   wd <- wd.createTemp
           |   src <- file(wd, "a-file")
           |   _ <- src.write("content")
           |   dst <- file(wd, "b-file")
           |   _ <- src.copy(dst)
           |   c <- dst.slurp
           |   _ <- wd.deleteR
           | } yield c
      res0: scala.util.Try[String] = Success(content)
  14. def copyTo(target: FSDir, options: CopyOption*): Try[Self]

    Permalink

    copy the entry to the given dir

    copy the entry to the given dir

    if the target dir doesn't exists, it's being created

    use FSEntry.copyToR(target* for a recursive copy operation

  15. def copyToR(target: FSDir, options: CopyOption*): Try[Self]

    Permalink

    recursively copy the entry to the given dir

    recursively copy the entry to the given dir

    if the target dir doesn't exists, it's being created

  16. def create(mode: String): Try[Self]

    Permalink

    create the filesystem entry with the given permissions

    create the filesystem entry with the given permissions

    the path hierarchy must exist - use FSEntry.mkDirs(attrs: FileAttribute*) to create the hierarchy at first.

    mode

    unix like symbolic mode

    Example:
    1. create("a=r,u+w") -> create the entry with the PosixFilePermissions: OWNER_READ, OWNER_WRITE, GROUP_READ and OTHERS_READ
      scala> import scala.collection.SortedSet
      scala> for {
           |   wd <- dir("/tmp/sclib")
           |   wd <- wd.createTemp
           |   fh <- file(wd, "example")
           |   _ <- fh.create("a=r,u+wx")
           |   perm <- fh.lsmod
           |   _ <- wd.deleteR
           | } yield perm.to[SortedSet]
      res0: scala.util.Try[scala.collection.SortedSet[java.nio.file.attribute.PosixFilePermission]] = Success(TreeSet(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, OTHERS_READ))
  17. def create(n: Int): Try[Self]

    Permalink

    create the filesystem entry with the given permissions

    create the filesystem entry with the given permissions

    the path hierarchy must exist - use FSEntry.mkDirs(attrs: FileAttribute*) to create the hierarchy at first.

    n

    unix like numeric mode

    Example:
    1. scala> import scala.collection.SortedSet
      scala> for {
           |   wd <- dir("/tmp/sclib")
           |   wd <- wd.createTemp
           |   fh <- file(wd, "example")
           |   _ <- fh.create(740)
           |   perm <- fh.lsmod
           |   _ <- wd.deleteR
           | } yield perm.to[SortedSet]
      res0: scala.util.Try[SortedSet[java.nio.file.attribute.PosixFilePermission]] = Success(TreeSet(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ))
  18. def create(perms: PosixFilePermission*): Try[Self]

    Permalink

    create the filesystem entry with the given permissions

    create the filesystem entry with the given permissions

    the path hierarchy must exist - use FSEntry.mkDirs(attrs:java\.nio\.file\.attribute\.FileAttribute[_]*)* to create the hierarchy at first.

  19. def create: Try[Self]

    Permalink

    create the filesystem entry with default permissions

    create the filesystem entry with default permissions

    the path hierarchy must exist - use FSEntry.mkDirs(attrs:java\.nio\.file\.attribute\.FileAttribute[_]*)* to create the hierarchy at first.

  20. def createTemp: Try[Self]

    Permalink

    create a new temporary filesystem entry.

    create a new temporary filesystem entry. the actual name is used for the prefix.

    if no absolute path is given, the entry is created in the temp directory (determined by: System.getProperty("java.io.tmpdir")).

    Example:
    1. scala> for {
           |   fh <- dir("a-temp-dir")
           |   // override the original fh
           |   fh <- fh.createTemp
           |   _ <- fh.delete
           |   // fh.name is something like 'a-temp-dir7526811586167481701'
           | } yield fh.name.matches("a-temp-dir\\d+")
      res0: scala.util.Try[Boolean] = Success(true)
      scala> for {
           |   fh <- file("a-temp-file")
           |   // override the original fh
           |   fh <- fh.createTemp
           |   _ <- fh.delete
           |   // fh.name is something like 'a-temp-file9014711075515420555'
           | } yield fh.name.matches("a-temp-file\\d+")
      res0: scala.util.Try[Boolean] = Success(true)
      scala> for {
           |   fh <- file("a-temp-file.txt")
           |   // override the original fh
           |   fh <- fh.createTemp
           |   _ <- fh.delete
           |   // fh.name is something like 'a-temp-file2068553337840465580.txt'
           | } yield fh.name.matches("a-temp-file\\d+\\.txt")
      res1: scala.util.Try[Boolean] = Success(true)
  21. def delete(): Try[Unit]

    Permalink

    delete the file

    delete the file

    returns a Failure if the file doesn't exist.

    See also

    FSEntry.deleteIfExists

  22. def deleteIfExists(): Try[Boolean]

    Permalink

    delete the file if it exists

    delete the file if it exists

    returns

    true if the file was deleted, false if it doesn't exist.

  23. def depth(other: FSEntryImpl): Int

    Permalink

    relative depth to a given FSEntry

    relative depth to a given FSEntry

    Example:
    1. scala> for {
           |  a <- dir("sclib-example")
           |  b <- dir(a, "x/y/z/..")
           | } yield a.depth(b)
      res0: scala.util.Try[Int] = Success(2)
  24. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  26. def exists: Boolean

    Permalink

    check if the file exists

  27. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  29. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  30. def isDirectory: Boolean

    Permalink

    check if the file is a directory

  31. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  32. def isRegularFile: Boolean

    Permalink

    check if the file is a regular file

  33. def lsmod: Try[Seq[PosixFilePermission]]

    Permalink

    get entry permission mode

  34. def mkDirs: Try[Self]

    Permalink

  35. def mkDirs(attrs: FileAttribute[_]*): Try[Self]

    Permalink

    create the directories

    create the directories

    - when called on a FSDir, the directroy's path (inclusive parents) are created - when called on a FSFile the parent hierarchy are created

    attrs

    http://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFileAttributes.html

  36. def move(target: Self, options: CopyOption*): Try[Self]

    Permalink

    move the entry

  37. def moveTo(dir: FSDir, options: CopyOption*): Try[Self]

    Permalink

    move the entry to the given directory, and keep the name

    move the entry to the given directory, and keep the name

    options

    http://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html

  38. def mtime(millis: Long): Try[Unit]

    Permalink

    set the modification time

    set the modification time

    millis

    file modification time in milliseconds, since the epoch (1970-01-01T00:00:00Z)

  39. def mtime: Try[Long]

    Permalink

    file modification time in milliseconds, since the epoch (1970-01-01T00:00:00Z)

  40. lazy val name: String

    Permalink

    file / directory name

  41. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  42. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  43. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  44. def renameTo(newName: String, options: CopyOption*): Try[Self]

    Permalink

    rename the entry

    rename the entry

    options

    http://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html

    Example:
    1. scala> for {
           |   wd <- dir("sclib-example")
           |   wd <- wd.createTemp
           |   src <- file(wd, "a-file")
           |   _ <- src.create
           |   dst <- src.renameTo("b-file")
           |   res = (src.exists, dst.exists)
           |   _ <- wd.deleteR
           | } yield res
      res0: scala.util.Try[(Boolean, Boolean)] = Success((false,true))
  45. def size: Try[Long]

    Permalink

    file size in bytes

  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  47. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  48. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped