Constructor
new File(path)
- Description:
Creates an object that represents a folder or a file in the virtual file-system. The file may or may not already exist.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
path |
String | Path of file/folder in the virtual file-system. |
Members
adapterAbsolutePath :String
- Description:
The absolute path of the file in the adapter file-system (usually Windows).
For example, theadapterAbsolutePath
of/Home
isC:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Users
(by default).
- Source:
The absolute path of the file in the adapter file-system (usually Windows).
For example, the adapterAbsolutePath
of /Home
is
C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Users
(by default).
Type:
- String
canList :Boolean
Does the current user have permission to list this folder?
Type:
- Boolean
canRead :Boolean
Does the current user have permission to read this file?
Type:
- Boolean
canWrite :Boolean
Does the current user have permission to write to this file?
Type:
- Boolean
extension :String
Extension of the file.
Type:
- String
fullPath :String
- Description:
The absolute path of the file in CompleteFTP's virtual file-system. For example, by default the
fullPath
of the home-folder of the userNewUser1
is/Home/NewUser1
.
- Source:
The absolute path of the file in CompleteFTP's virtual file-system.
For example, by default the fullPath
of the home-folder of the user NewUser1
is /Home/NewUser1
.
Type:
- String
isExecutable :Boolean
Is this file an executable?
Type:
- Boolean
isFile :Boolean
Is this a file?
Type:
- Boolean
isFolder :Boolean
Is this a folder?
Type:
- Boolean
isFolderEmpty :Boolean
- Description:
Is this an empty folder? Throws an exception if it's not a folder.
- Source:
Is this an empty folder? Throws an exception if it's not a folder.
Type:
- Boolean
isLengthKnown :Boolean
Is the length of this file known?
Type:
- Boolean
isVirtualFileSystemFolder :Boolean
Is this file a folder in the virtual file-system?
Type:
- Boolean
length :Number
Length of the file in bytes.
Type:
- Number
modifiedTime :Date
Date and time that this file/folder was last modified.
Type:
- Date
name :String
The name of the file.
Type:
- String
Methods
appendText(text) → {void}
Parameters:
Name | Type | Description |
---|---|---|
text |
String | Text to append to the file. |
Returns:
- Type
- void
copyTo(toPath)
Parameters:
Name | Type | Description |
---|---|---|
toPath |
String | Path to copy this file to. |
createFile()
- Description:
Create an empty file at the location defined by this File object.
- Source:
createFolder()
exists() → {Boolean}
Returns:
- Type
- Boolean
getFiles() → {Array.<File>}
- Description:
Returns an array of File objects representing the contents of this folder. Throws an exception if this File object is not a folder.
- Source:
Returns:
- Type
- Array.<File>
getParent() → {File}
- Description:
Return a File object representing the parent-folder of this File object.
- Source:
Returns:
- Type
- File
moveTo(toPath)
Parameters:
Name | Type | Description |
---|---|---|
toPath |
String | Path to move this file to. |
readBase64() → {String}
- Description:
Reads the contents of the file and returns it as a base64 encoded string.
This only works for files up to 100kB.
- Source:
Returns:
base64 encoded string containing contents of file.
- Type
- String
readLines(numLines) → {Array.<String>}
- Description:
Returns the given number of lines (or all lines if numLines=0) as an array of strings.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
numLines |
Returns:
- Type
- Array.<String>
readObject() → {Object}
- Description:
Parses the contents of the file as JSON and returns a Javascript object. This only works for files up to 100kB.
- Source:
Returns:
- Type
- Object
readText() → {String}
- Description:
Returns the contents of this file as a string. This only works for files up to 100kB.
- Source:
Returns:
- Type
- String
remove()
- Description:
Delete the file or folder at the path represented by this File object.
- Source:
removeFile()
- Description:
Delete the file at the path represented by this File object. Fails if this is a folder.
- Source:
removeFolder(recursiveopt)
- Description:
Delete the folder at the path represented by this File object. Fails if this is a file.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
recursive |
String |
<optional> |
false
|
Remove all files and subfolders of the folder as well. |
rename(newName) → {File}
Parameters:
Name | Type | Description |
---|---|---|
newName |
String | New name of file. |
Returns:
New File object for the renamed file.
- Type
- File
testGetFiles() → {Boolean}
- Description:
Test to see if a folder can be listed (without listing all the files).
- Source:
Returns:
true
if the listing operation was successful and false
otherwise.
- Type
- Boolean
testRead() → {Boolean}
- Description:
Tries to read from the file. This differs from using canRead, which only checks permissions without attempting the operation.
- Source:
Returns:
true
if the read operation was successful and false
otherwise.
- Type
- Boolean
toURL() → {String}
Returns:
- Type
- String
unzip(destinationFolder, overwrite)
Parameters:
Name | Type | Description |
---|---|---|
destinationFolder |
String | Virtual file-system path of folder where the file should be unzipped. |
overwrite |
Boolean | If true then any existing files are overwritten otherwise an exception is thrown if a file is in the way. |
writeBase64(base64String) → {void}
- Description:
Parses the given base64-encoded string and writes the result to the file.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
base64String |
String | base64 encoding of what is to be written to the file. |
Returns:
- Type
- void
writeObject(object) → {void}
Parameters:
Name | Type | Description |
---|---|---|
object |
String | Object to write to the file. |
Returns:
- Type
- void
writeText(text) → {void}
Parameters:
Name | Type | Description |
---|---|---|
text |
String | Text to write to the file. |
Returns:
- Type
- void