Task Description
Set up an abstract class for filesystem which should define the methods and the APIs for a File System in TPF learning section's tutorials.
and get the reference to instances of files
In the context of TPF, a file system should have the following behaviour:
Should maintain keep track of the files and directories in it.
Should store references to files which can be used to retrieve and store content in the file (this can be implemented as a separate File class, but we will be using BrowserFS for implementing this and they would take care of this detail already)
Should maintain a list of cursors, keeping track of the position of each of the cursor in the filesystem
Should provide the option to change the working directory of a cursor
Should provide the option to list the contents of the working directory of the cursor (if given a path it should list the contents in the given path and ignore the working directory of the cursor)
Should have a method which accepts the content and metadata of a file and saves it to a specified path in the filesystem
Should have a method for getting the content of a file given its path
Should have a method which adds directories to the working directory of the cursor (if given a path, it should use the path instead of the working directory of the cursor)
Should have a method which removes directories and files working directory of the cursor (if given a path, it should use the path instead of the working directory of the cursor)
Acceptance criteria for task
[ ] Check that the implementations of the class have a private variable named cursors which should be an array
[ ] Check that the implementations of the class have a public method named setWD.
[ ] Check that the implementations of the class have a public method named inspectWD
[ ] Check that the implementations of the class have a public method named persistContent
[ ] Check that the implementations of the class have a public method method saveFile
[ ] Check that the implementations of the class have a public method named getFile
[ ] Check that the implementations of the class have a public method named createDirectory
[ ] Check that the implementations fo the class have a public method named removeDirectory
Additional context
Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.
class PFEditorAbstractClass {
constructor() {
if (this.constructor === PFEditorAbstractClass) {
throw new TypeError('Abstract class "PFEditorAbstractClass" cannot be instantiated directly.');
}
//abstract method for mounting an Editor into a DOM Elemement must be implemented
if(!typeof this.mountEditorToDOMElement === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
if (this.content === undefined) {
throw new TypeError('Classes implementing PFEditorAbstractClass must have the content as an attribute')
}
//abstract method for storing one or more variables in local storage must be implemented
if(!this.saveContent === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}]
//abstract method for retrieving one or more variables from local storage must be implemented
if(!typeof this. this.getContent === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
//abstract method for closing the Editor after necessary cleanup operations must be implemented
if(!typeof this.closeEditor === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
//abstract method for minimizing the Editor after necessary saving operations must be implemented
if(!typeof this.minimizeEditor === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
}
}
Task Description Set up an abstract class for filesystem which should define the methods and the APIs for a File System in TPF learning section's tutorials.
and get the reference to instances of files
In the context of TPF, a file system should have the following behaviour:
Acceptance criteria for task
cursors
which should be an arraysetWD
.inspectWD
persistContent
saveFile
getFile
createDirectory
removeDirectory
Additional context Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.