# class `Files.FileRef`

A FileRef is a platform-independent representation of a file system object. It consists of two parts, a directory specification and the name of an object within that directory.

A FileRef may name an existing object or one that does not yet exist. The directory specification always refers to an existing directory, however (although this is not necessarily enforced).

When using a pathname in the construction of a FileRef, an absolute pathname should be used. The effect of specifying a relative pathname is undefined.

FileRef objects are immutable.

## Constructors

FileRef(dir = DirRef or path, name = string)
  Constructs a FileRef from a directory specification and a name within that directory. The directory may be specified either by a full pathname or a DirRef.
FileRef(path = string)
  Constructs a FileRef from a full pathname.

## Properties

`name`
  Read only. Name of the object within its parent directory.

`dir`
  Read only. A DirRef representing the directory in which the object resides, or will reside in the case of an object which does not yet exist.

## Methods

`open(mode, file_type = None)`
  Opens the referenced object as a file using the given mode (which is the same as the mode parameter to the built-in `open` function). If opening for writing and the file does not yet exist, it is created.
  If file_type is given, it should be a FileType instance specifying the file type metadata to be attached to the file. This parameter is only used if the call results in the creation of a new file. On platforms which do not have file type metadata, it is ignored.
mkdir()
  Creates a directory with the name and parent directory specified by the FileRef. Returns a DirRef representing the created directory.

---