Class: Entity

DKTools.IO.Entity

Abstract class of entity (file or directory)

new DKTools.IO.Entity () abstract

Examples
var file = new DKTools.IO.File('index.html');
var directory = new DKTools.IO.Directory('img/system/');

Members

_extension String privatereadonly

_initialExtension String privatereadonly

_name String privatereadonly

_path String privatereadonly

extension

Gets extension of the entity
Since:
  • 3.0.0

initialExtension

Gets initial extension of the entity
Since:
  • 5.0.0

name

Gets name of the entity

path

Gets path of the entity
Since:
  • 3.0.0

Methods

__processError (error, onError) private

Name Type Description
error * Error
onError function optional Callback function upon completion of an operation with error
Since:
  • 6.1.0

equals (entity)Boolean

Returns true is the entity is same
Name Type Description
entity DKTools.IO.Entity Entity
Since:
  • 11.2.1
Returns:
Type Description
Boolean Entity is same

exists ()Boolean

Returns true if the entity exists
Version:
  • 3.0.0
Returns:
Type Description
Boolean Entity exists

getAbsolutePath ()String

Returns the absolute path
Since:
  • 3.0.0
Returns:
Type Description
String Absolute path

getExtension ()String

Returns the extension of the entity
Since:
  • 3.0.0
Returns:
Type Description
String Extension of the entity

getFullName ()String

Returns the full name
Version:
  • 10.0.8
Since:
  • 3.0.0
Returns:
Type Description
String Full name

getFullPath ()String

Returns the full path
Version:
  • 3.0.0
Returns:
Type Description
String Full Path

getName ()String

Returns the name of the entity without an extension
Since:
  • 3.0.0
Returns:
Type Description
String Name of the entity without an extension

getPath ()String

Returns the path
Since:
  • 3.0.0
Returns:
Type Description
String Path

getStats (object)Object

Returns a stats Returns an object with 2 properties: status - Result of an operation data - Loaded data if the status is not equal to DKTools.IO.OK then data will be null Possible statuses: DKTools.IO.OK DKTools.IO.EXPECT_CALLBACK DKTools.IO.ERROR_NOT_LOCAL_MODE DKTools.IO.ERROR_PATH_DOES_NOT_EXIST DKTools.IO.ERROR_CALLBACK_IS_NOT_AVAILABLE DKTools.IO.ERROR_OPTIONS_ARE_NOT_AVAILABLE
Name Type Description
object Object Options of an operation
Name Type Description
sync Boolean optional Use synchronous version of stat
onSuccess function optional Callback function upon completion of an operation (only for object.sync == false)
onError function optional Callback function upon completion of an operation with error (only for object.sync == false)
Version:
  • 8.0.0
Since:
  • 2.0.0
Returns:
Type Description
Object Loaded stats

getStatsAsync ()Promise.<Object> async

Returns a stats Asynchronous version of DKTools.IO.Entity.prototype.getStats Promise resolves an object with 2 properties: status - Result of an operation data - Loaded data if the status is not equal to DKTools.IO.OK then data will be null Possible statuses: DKTools.IO.OK DKTools.IO.ERROR_NOT_LOCAL_MODE DKTools.IO.ERROR_PATH_DOES_NOT_EXIST
Version:
  • 6.1.0
Since:
  • 4.0.0
Returns:
Type Description
Promise.<Object> Loaded stats

hasExtension ()Boolean

Returns true if the entity has an extension
Since:
  • 5.0.0
Returns:
Type Description
Boolean Entity has an extension

initialize (fullPath)

Initializes the entity
Name Type Description
fullPath String Path to entity
Version:
  • 11.2.3
Since:
  • 3.0.0

isDirectory ()Boolean

Returns true if the entity is a directory
Version:
  • 5.0.0
Since:
  • 2.0.0
Returns:
Type Description
Boolean Entity is a directory

isFile ()Boolean

Returns true if the entity is a file
Version:
  • 6.2.1
Since:
  • 2.0.0
Returns:
Type Description
Boolean Entity is a file

rename (newName, object)Number

Renames the entity (file or directory) Returns a code of the result of an operation Possible results: DKTools.IO.OK DKTools.IO.EXPECT_CALLBACK DKTools.IO.ERROR_NOT_LOCAL_MODE DKTools.IO.ERROR_PATH_DOES_NOT_EXIST DKTools.IO.ERROR_OVERWRITING_IS_NOT_AVAILABLE
Name Type Default Description
newName String New name of entity (file or directory) without the extension
object Object {} optional Options of an operation
Name Type Description
sync Boolean optional Use synchronous version of rename
overwrite Boolean optional Overwrite existing entity
onSuccess function optional Callback function upon completion of an operation (only for object.sync == false)
onError function optional Callback function upon completion of an operation with error (only for object.sync == false)
Version:
  • 7.0.0
Returns:
Type Description
Number Code of the result of an operation

renameAsync (newName, object)Promise.<Number> async

Renames the entity (file or directory) Asynchronous version of DKTools.IO.Entity.prototype.rename Promise resolves a code of the result of an operation Possible results: DKTools.IO.OK DKTools.IO.ERROR_NOT_LOCAL_MODE DKTools.IO.ERROR_PATH_DOES_NOT_EXIST DKTools.IO.ERROR_OVERWRITING_IS_NOT_AVAILABLE
Name Type Default Description
newName String New name of entity without the extension
object Object {} optional Options of an operation
Name Type Description
overwrite Boolean optional Overwrite existing entity
Version:
  • 7.0.0
Since:
  • 4.0.0
Returns:
Type Description
Promise.<Number> Code of the result of an operation