-
Notifications
You must be signed in to change notification settings - Fork 141
File system operations
Rajesh R edited this page Jun 16, 2024
·
1 revision
Utilities to ls
, cp
, rm
, mv
, ln
, md5
, touch
, cat
etc:
file.touch()
file.delete() // unlike the Java API, also works on directories as expected (deletes children recursively)
file.clear() // If directory, deletes all children; if file clears contents
file.renameTo(newName: String)
file.moveTo(destination)
file.moveToDirectory(destination)
file.copyTo(destination) // unlike the default API, also works on directories (copies recursively)
file.copyToDirectory(destination)
file.linkTo(destination) // ln destination file
file.symbolicLinkTo(destination) // ln -s destination file
file.setOwner(user: String) // chown user file
file.setGroup(group: String) // chgrp group file
Seq(file1, file2) `>:` file3 // same as cat file1 file2 > file3 (must import import better.files.Dsl.SymbolicOperations)
Seq(file1, file2) >>: file3 // same as cat file1 file2 >> file3 (must import import better.files.Dsl.SymbolicOperations)
file.isReadLocked(); file.isWriteLocked(); file.isLocked()
File.numberOfOpenFileDescriptors() // number of open file descriptors