Dotty Documentation


abstract class AbstractFile
extends Iterable

This class and its children serve to unify handling of files and directories. These files and directories may or may not have some real counter part within the file system. For example, some file handles reference files within a zip archive or virtual ones that exist only in memory.

Every abstract file has a path (i.e. a full name) and a name (i.e. a short name) and may be backed by some real File. There are two different kinds of abstract files: regular files and directories. Regular files may be read and have a last modification time. Directories may list their content and look for subfiles with a specified name or path and of a specified kind.

The interface does not allow to access the content. The class symtab.classfile.AbstractFileReader accesses bytes, knowing that the character set of classfiles is UTF-8. For all other cases, the class SourceFile is used, which honors global.settings.encoding.value.

''Note: This library is considered experimental and should not be used unless you know what you are doing.''

[-] Constructors

AbstractFile ( )
AbstractFile ( file: AbstractFile )

[-] Members

[+] private val extension : String
[+] def absolute : AbstractFile

The absolute file, if this is a relative file.

[+] def bufferedOutput : BufferedOutputStream

Returns a buffered output stream for writing the file - defaults to out

[+] def canonicalPath : String

Returns the path of this abstract file in a canonical form.

[+] def container : AbstractFile

Returns the containing directory of this abstract file

[+] def create ( ) : Unit

Create a file on disk, if one does not exist already.

[+] def delete ( ) : Unit

Delete the underlying file or directory (recursively).

[+] def exists : Boolean

Does this abstract file denote an existing file?

[+] def file : JFile

Returns the underlying File if any and null otherwise.

[+] def fileNamed ( name: String ) : AbstractFile

Get the file in this directory with the given name, creating an empty file if it does not already existing.

[+] private def fileOrSubdirectoryNamed ( name: String , isDir: Boolean ) : AbstractFile
[+] def hasExtension ( other: String ) : Boolean

Checks extension case insensitively.

[+] def input : InputStream

returns an input stream so the file can be read

[+] def isClass : Boolean
[+] def isClassContainer : Boolean

Does this abstract file represent something which can contain classfiles?

[+] def isDirectory : Boolean

Is this abstract file a directory?

[+] def isJarOrZip : Boolean
[+] def isPackage : Boolean
[+] def isScalaOrJavaSource : Boolean
[+] def isVirtual : Boolean

Does this abstract file correspond to something on-disk?

[+] def iterator ( ) : Iterator [ AbstractFile ]

Returns all abstract subfiles of this abstract directory.

[+] def lastModified : Long

Returns the time that this abstract file was last modified.

[+] private def lookup ( getFile: (AbstractFile, String, Boolean) => AbstractFile , path0: String , directory: Boolean ) : AbstractFile
[+] def lookupName ( name: String , directory: Boolean ) : AbstractFile

Returns the abstract file in this abstract directory with the specified name. If there is no such file, returns null. The argument directory tells whether to look for a directory or a regular file.

[+] def lookupNameUnchecked ( name: String , directory: Boolean ) : AbstractFile

Returns an abstract file with the given name. It does not check that it exists.

[+] def lookupPathUnchecked ( path: String , directory: Boolean ) : AbstractFile

Return an abstract file that does not check that path denotes an existing file.

[+] def name : String

Returns the name of this abstract file.

[+] def output : OutputStream

Returns an output stream for writing the file

[+] def path : String

Returns the path of this abstract file.

[+] def sizeOption : Option [ Int ]

size of this file if it is a concrete file.

[+] def subdirectoryNamed ( name: String ) : AbstractFile

Get the subdirectory with a given name, creating it if it does not already exist.

[+] @throws def toByteArray : Array [ Byte ]

Returns contents of file (if applicable) in a byte array.

[+] @throws def toCharArray : Array [ Char ]

Returns contents of file (if applicable) in a Char array. warning: use Global.getSourceFile() to use the proper encoding when converting to the char array.

[+] override def toString ( ) : String

Returns the path of this abstract file.

[+] def toURL : URL
[+] def toURLs ( default: => Seq [ URL ] ) : Seq [ URL ]

Safe method returning a sequence containing one URL representing this file, when underlying file exists, and returning given default value in other case

[+] def underlyingSource : Option [ AbstractFile ]

An underlying source, if known. Mostly, a zip/jar file.

[+] protected def unsupported ( ) : Nothing
[+] protected def unsupported ( msg: String ) : Nothing