Class: File

File(rel_path, contentopt, encodingopt, typeopt, mime_typeopt, git_working_treeopt, git_dirtyopt, git_unmergedopt)

A File

Constructor

new File(rel_path, contentopt, encodingopt, typeopt, mime_typeopt, git_working_treeopt, git_dirtyopt, git_unmergedopt)

constructor
Parameters:
Name Type Attributes Default Description
rel_path string path relative to root directory
content string | Buffer <optional>
content of file
encoding string <optional>
utf8 text encoding of a text file (implicitely null for raw buffer, undefined if same as global file system text encoding)
type string <optional>
type
mime_type string <optional>
MIME type
git_working_tree string <optional>
URL of git repository
git_dirty boolean <optional>
Git dirty flag
git_unmerged boolean <optional>
Git unmerged flag
Source:

Methods

(static) from(obj) → {File}

Build a File instance from an object, convenient for transportation with a transport protocol, that looks like a file but with an additional property 'format'. If a property 'format' exists in the object then property 'content' is considered as a base64 encoded string that is converted to a buffer in the File instance.
Parameters:
Name Type Description
obj Object an object
Source:
Returns:
an instance of File
Type
File

(static) from_database(obj) → {File}

Build a File instance from an object from the database.
Parameters:
Name Type Description
obj Object an object from database
Source:
Returns:
an instance of File
Type
File

compare_content(other) → {number}

Compare content with another file
Parameters:
Name Type Description
other File other file to compare content with
Source:
Returns:
sort order (0 means equal)
Type
number

database_export() → {Object}

Export the file as an object convenient for storing in the database. It has property 'format' which value is 'binary' when the property 'content' of the object is a base64 encoded string, otherwise its value is 'text'.
Source:
Returns:
an object
Type
Object

export() → {Object}

Export the file as an object convenient for transportation with a transport protocol. It has property 'format' which value is 'binary' when the property 'content' of the object is a base64 encoded string, otherwise its value is 'text'.
Source:
Returns:
an object
Type
Object

get_abs_path(root_directory_path) → {string}

Get the absolute path of the file (on the host file system)
Parameters:
Name Type Description
root_directory_path string the root directory path on the host file system
Source:
Returns:
the absolute path of the file
Type
string