API Docs for:
Show:

File Class

Module: API

Represents a file or folder in the virtual file-system. This file/folder may not yet exist. It is returned from system.getFile function of the 'system' global variable.

Methods

copyTo

(
  • toPath
)

Copy this file to the given destination.

Parameters:

  • toPath String

    Path to copy this file to.

createFile

()

Create an empty file at the location defined by this File object.

createFolder

()

Create a folder at the path represented by this File object.

exists

() Boolean

Does this file or folder exist?

Returns:

Boolean:

getFiles

() File[]

Returns an array of File objects representing the contents of this folder. Throws an exception if this File object is not a folder.

Returns:

getParent

() File

Return a File object representing the parent-folder of this File object.

Returns:

File:

moveTo

(
  • toPath
)

Move this file to the given path.

Parameters:

  • toPath String

    Path to move this file to.

readBase64

() String

Reads the contents of the file an returns it as a base64 encoded string.
This only works for files up to 100kB.

Returns:

String: base64 encoded string containing contents of file.

readLines

(
  • numLines
)
String

Returns the given number of lines (or all lines if numLines=0) as an array of strings.

Parameters:

  • numLines Object

Returns:

String:

readObject

() Object

Parses the contents of the file as JSON and returns a Javascript object. This only works for files up to 100kB.

Returns:

Object:

readText

() String

Returns the contents of this file as a string. This only works for files up to 100kB.

Returns:

String:

remove

()

Delete the file or folder at the path represented by this File object.

removeFile

()

Delete the file at the path represented by this File object. Fails if this is a folder.

removeFolder

(
  • [recursive=false]
)

Delete the folder at the path represented by this File object. Fails if this is a file.

Parameters:

  • [recursive=false] String optional

    Remove this folder.

rename

(
  • newName
)
String

Rename the current file to the given name.

Parameters:

  • newName String

    New name of file.

Returns:

String: New File object for the renamed file.

toURL

() String

Get the URL that this file is accessible at.

Returns:

String:

writeBase64

(
  • base64String
)
Void

Parses the given base64-encoded string and writes the result to the file.

Parameters:

  • base64String String

    base64 encoding of what is to be written to the file.

Returns:

Void:

writeObject

(
  • object
)
Void

Write the given object to the file in JSON format.

Parameters:

  • object String

    Object to write to the file.

Returns:

Void:

writeText

(
  • text
)
Void

Write the given text to this file.

Parameters:

  • text String

    Text to write to the file.

Returns:

Void:

Properties

canList

Boolean

Does the current user have permission to list this folder?

canRead

Boolean

Does the current user have permission to read this file?

canWrite

Boolean

Does the current user have permission to write to this file?

extension

String

Extension of the file.

fullPath

String

The absolute path of the file.

isExecutable

Boolean

Is this file an executable?

isFile

Boolean

Is this a file?

isFolder

Boolean

Is this a folder?

isLengthKnown

Boolean

Is the length of this file known?

isVirtualFileSystemFolder

Boolean

Is this file a folder in the virtual file-system?

length

Number

Length of the file in bytes.

modifiedTime

Date

Date and time that this file/folder was last modified.

name

String

The name of the file.