Skip to content

Latest commit

 

History

History
69 lines (57 loc) · 2.06 KB

file-system.md

File metadata and controls

69 lines (57 loc) · 2.06 KB

File System

  • Name in Remix: fileManager
  • kind: fs
Type Name Description
event currentFileChanged Triggered when a file changes.
method getFolder Get a Folder map (see below) from a path.
method getCurrentFile Get the name of the current file selected.
method getFile Get the content of a file.
method setFile Set the content of a file.
method switchFile Switch the current File to the new one

Examples

Events

currentFileChanged: Triggered when a file changes.

client.solidity.on('currentFileChanged', (fileName: string) => {
  // Do something
})
// OR
client.on('fileManager', 'currentFileChanged', (fileName: string) => {
  // Do something
})

Methods

getFolder: Get a list of names from a path.

const folder = await client.fileManager.getFolder('/browser')
// OR
const folder = await client.call('fileManager', 'getFolder', '/browser')

getCurrentFile: Get the name of the current file selected.

const fileName = await client.fileManager.getCurrentFile()
// OR
const fileName = await client.call('fileManager', 'getCurrentFile')

getFile: Get the content of a file.

const ballot = await client.fileManager.getFile('browser/ballot.sol')
// OR
const fileName = await client.call('fileManager', 'getFile', 'browser/ballot.sol')

setFile: Set the content of a file.

await client.fileManager.setFile('browser/ballot.sol', 'pragma ....')
// OR
await client.call('fileManager', 'setFile', 'browser/ballot.sol', 'pragma ....')

switchFile: Switch the current File to the new one.

await client.fileManager.switchFile('browser/ballot.sol')
// OR
await client.call('fileManager', 'switchFile', 'browser/ballot.sol')

Types

Folder: A map with the file name as the key and the metadata of this file as value.

Type Definitions can be found here