Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.File Class Reference

File path. More...

Inheritance diagram for Dragengine.File:

Public Member Functions

bool equals (Object object)
 Files are equal.
String getComponentAt (int index)
 Component at index.
int getComponentCount ()
 Count of components.
String getName ()
 Name of path which is the last path component or the prefix if empty.
String getPath ()
 String representation of path.
int hashCode ()
 Hash code of File.
bool isAbsolute ()
 Path is absolute.
bool isEmpty ()
 Path is empty.
bool isParentOf (File file)
 File is a direct or indirect parent of another file.
bool isParentOf (String path)
 File is a direct or indirect parent of another file.
bool isRelative ()
 Path is relative.
File new ()
 Create File with root path.
File new (File file)
 Create copy of file.
File new (File parent, File filename)
 Create File from filename appended to parent File.
File new (File parent, String filename)
 Create File from filename appended to parent File.
File new (String filename)
 Create File from filename.
File new (String parent, String filename)
 Create File from filename appended to parent File.
File operator+ (File file)
 Create File from filename appended to parent File.
File operator+ (String file)
 Create File from filename appended to parent File.
File operator- (File directory)
 Relative path or null.
File operator- (String directory)
 Relative path or null.
File relativePath (File file)
 Relative path or null.
File relativePath (String path)
 Relative path or null.
String toString ()
 String representation of this filename.

Static Public Member Functions

static File absolutePath (String path, String baseDirectory)
 Create absolute path of base directory and a potential relative path.
static bool isAbsolute (String path)
 Path is absolute.

Public Attributes

Array pComponents
String pPrefix

Detailed Description

File path.

This is not an open file but only an object for working with filenames. This object though can then be used with appropriate other objects to load files.

Member Function Documentation

◆ absolutePath()

File Dragengine.File.absolutePath ( String path,
String baseDirectory )
static

Create absolute path of base directory and a potential relative path.

Used for loading files relative to a base path where the file path can be absolute or relative. If path is absolute a File instance of path is returned. If path is relative a File instance of baseDirectory with path appended is returned.

This method is safe to be used with path containing '..' at the beginning.

References getComponentAt(), getComponentCount(), and pComponents.

Referenced by operator-().

◆ equals()

bool Dragengine.File.equals ( Object object)

Files are equal.

Parameters
objectObject to check.
Returns
True if both objects describe the same filename.

Referenced by operator-().

◆ getComponentAt()

String Dragengine.File.getComponentAt ( int index)

Component at index.

References pComponents, and pPrefix.

Referenced by absolutePath().

◆ getComponentCount()

int Dragengine.File.getComponentCount ( )

Count of components.

Referenced by absolutePath().

◆ getName()

String Dragengine.File.getName ( )

Name of path which is the last path component or the prefix if empty.

Referenced by hashCode().

◆ getPath()

String Dragengine.File.getPath ( )

String representation of path.

Referenced by isParentOf(), and operator-().

◆ hashCode()

int Dragengine.File.hashCode ( )

Hash code of File.

References getName(), pComponents, and pPrefix.

Referenced by operator-().

◆ isAbsolute() [1/2]

bool Dragengine.File.isAbsolute ( )

Path is absolute.

Path is absolute if prefix is '/'.

References pComponents, and pPrefix.

Referenced by operator-(), operator-(), and toString().

◆ isAbsolute() [2/2]

bool Dragengine.File.isAbsolute ( String path)
static

Path is absolute.

Returns
true if path begins with '/'.

References pComponents, and pPrefix.

◆ isEmpty()

bool Dragengine.File.isEmpty ( )

Path is empty.

References pComponents, and pPrefix.

Referenced by operator+().

◆ isParentOf() [1/2]

bool Dragengine.File.isParentOf ( File file)

File is a direct or indirect parent of another file.

Typically used to check if a file is inside a directory.

References getPath(), and pComponents.

Referenced by operator-().

◆ isParentOf() [2/2]

bool Dragengine.File.isParentOf ( String path)

File is a direct or indirect parent of another file.

Version
1.20

Typically used to check if a file is inside a directory.

References pComponents, and pPrefix.

◆ isRelative()

bool Dragengine.File.isRelative ( )

Path is relative.

Path is relative if prefix is empty.

References pComponents.

Referenced by operator+().

◆ new() [1/6]

File Dragengine.File.new ( )

Create File with root path.

References new(), pComponents, and pPrefix.

Referenced by new().

◆ new() [2/6]

File Dragengine.File.new ( File file)

Create copy of file.

References pComponents, and pPrefix.

◆ new() [3/6]

File Dragengine.File.new ( File parent,
File filename )

Create File from filename appended to parent File.

Parameters
parentPath to parse filename relative to.
filenameFilename to parse.
Exceptions
EInvalidParamfilename is absolute.

◆ new() [4/6]

File Dragengine.File.new ( File parent,
String filename )

Create File from filename appended to parent File.

Parameters
parentPath to parse filename relative to.
filenameFilename to parse.

References pComponents, and pPrefix.

◆ new() [5/6]

File Dragengine.File.new ( String filename)

Create File from filename.

Parameters
filenameFilename to parse.

◆ new() [6/6]

File Dragengine.File.new ( String parent,
String filename )

Create File from filename appended to parent File.

Parameters
parentPath to parse filename relative to.
filenameFilename to parse.

References pComponents, and pPrefix.

◆ operator+() [1/2]

File Dragengine.File.operator+ ( File file)

Create File from filename appended to parent File.

Parameters
parentPath to parse filename relative to.
filenameFilename to parse.

References isEmpty(), isRelative(), pComponents, and pPrefix.

◆ operator+() [2/2]

File Dragengine.File.operator+ ( String file)

Create File from filename appended to parent File.

Parameters
parentPath to parse filename relative to.
filenameFilename to parse.

◆ operator-() [1/2]

File Dragengine.File.operator- ( File directory)

Relative path or null.

Version
1.20

If file.isParentOf(this) is true returns relative path to file.

References isAbsolute().

◆ operator-() [2/2]

File Dragengine.File.operator- ( String directory)

Relative path or null.

Version
1.20

If file.isParentOf(this) is true returns relative path to file.

References absolutePath(), equals(), getPath(), hashCode(), isAbsolute(), isParentOf(), pComponents, pPrefix, relativePath(), and toString().

◆ relativePath() [1/2]

File Dragengine.File.relativePath ( File file)

Relative path or null.

Version
1.20

If isParentOf(file) is true returns relative path to this path.

References pComponents, and pPrefix.

Referenced by operator-().

◆ relativePath() [2/2]

File Dragengine.File.relativePath ( String path)

Relative path or null.

Version
1.20

If isParentOf(file) is true returns relative path to this path.

References pComponents.

◆ toString()

String Dragengine.File.toString ( )

String representation of this filename.

Same as getPath().

References isAbsolute(), and pPrefix.

Referenced by operator-().

Member Data Documentation

◆ pComponents

◆ pPrefix


The documentation for this class was generated from the following file: