summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/io/VirtualFile.scala
blob: 02ce3b0f81d84d48763cf9dea501bbe476eca4ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002-2006, LAMP/EPFL         **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$


package scala.tools.nsc.io;


import java.io.{File,IOException};

/** This class implements an empty abstract regular file. */
class VirtualFile(val name: String, _path: String) extends AbstractFile {

  assert(name != null && path != null, name + " - " + path);

  //########################################################################
  // Public Constructors

  /**
   * Initializes this instance with the specified name and an
   * identical path.
   */
  def this(name: String) = this(name, name);

  //########################################################################
  // Public Methods

  def path = _path;

  /** Returns null. */
  final def file: File = null;

  /** Is this abstract file a directory? */
  def isDirectory: Boolean = false;

  /** Returns the time that this abstract file was last modified. */
  def lastModified: Long = Long.MIN_VALUE;

  /** Reads the content of this abstract file into a byte array. */
  def read: Array[Byte] = {
    assert(!isDirectory, "cannot read directory '" + this + "'");
    new Array[Byte](0);
  }

  /** Returns all abstract subfiles of this abstract directory. */
  def elements: Iterator[AbstractFile] = {
    assert(isDirectory, "not a directory '" + this + "'");
    Iterator.empty;
  }

  /**
   * 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
   * or a regular file.
   */
  def lookupName(name: String, directory: Boolean): AbstractFile = {
    assert(isDirectory, "not a directory '" + this + "'");
    null;
  }

  //########################################################################
}