Search code examples
scalafilefilesystemsterminologyalgebraic-data-types

In computer terminology, what is a "non-directory" called?


This question might sound really naive but I understand that in a hierarchical filesystem, directories can contain other files. But, I am having trouble coming up with a good name for things that are not directories (i.e. vanilla "files") - I can't just call them files since class Directory extends Files. I want to do type-safe operations (e.g. the compile will fail if I try to list a file or read a directory):

sealed trait File {
  def path: Path
}
case class Directory(path: Path, children: Iterable[File]) extends File
case class VanillaFile?(path: Path, contents: Iterable[Byte]) extends File

What should be a better name for VanillaFile?

EDIT: As pointed out, there is one more thing in certain file systems:

case class SymbolicLink(target: File) extends File

Solution

  • As suggested by Andy Turner, "regular file" is a standard term: