Skip to content

USER OS Program: Files

Jan Fic edited this page Sep 28, 2020 · 10 revisions

Files is a simple file explorer that is commonly found on existing Operating Systems. This program has the following features:

  1. View and go through directories
  2. Copy and Paste Folders and Files
  3. Delete Files

Here is an overview of the USER Files architecture. USER Files Architecture

API

Here is documentation on how to use the Files program's Systems and Components to your advantage:

FileCopySystem and FilePasteSystem

The FileCopySystem uses the components FileCopyComponent and FileComponent to add files to a list of copied files. The FilePasteSystem uses the components FilePasteComponent and FileComponent to mark files or directories to paste the list of copied files to.

Simply use the components and systems to copy and paste files of your choosing. It is recommended to use the USER Kernel's FileLoadSystem to easily get FileComponents.

Example:

/** Frame 0 **/
Entity copyEntity = new Entity()
copyEntity.add(new FileLoadRequestComponent(fileName: "copiedFile.txt"));
copyEntity.add(new FileCopyComponent());

Entity pasteEntity = new Entity()
pasteEntity.add(new FileLoadRequestComponent(fileName: "targetDirectory"));
pasteEntity.add(new FilePasteComponent());

After this a frame of the program will pass and the update method of systems will run. Because the FileLoadSystem has not given these entities FileComponents the FilePasteSystem and FileCopySystem do not use these entities until after. Here is a demonstration frame by frame the -> represents computation by systems between frames.

Frame 0                            Frame 1                             Frame 2
--------------------------   ->    ---------------------------    ->   -----------------------------
copyEntity                         copyEntity                          copyEntity
  FileLoadRequestComponent           FileComponent                       FileComponent
  FileCopyComponent                  FileCopyComponent

pasteEntity                        pasteEntity                         pasteEntity
  FileLoadRequestComponent           FileComponent                       FileComponent
  FilePasteComponent                 FilePasteComponent

As you can see the FileCopyComponent and FilePasteComponent are both removed from the entities after the process is complete.

FileDeleteSystem

The FileDeleteSystem is not part of the Files program but is rooted in the USER Kernel itself. Refer to Kernel documentation instead.

FileRenameSystem

The FileRenameSystem uses libGDX's FileHandle methods. This System only uses two components and one system. However, the UI aspect of the program uses much more to accomplish the renaming. Here we will only discuss the simple version, as the UI method of renaming a file uses a whole host of systems and components from the OS to accomplish the task.

Componments: os: FileComponent FileLoadComponent ( Recommended ) files: FileRenameComponent

Systems: os: FileLoadSystem ( Recommended ) files: FileRenameSystem

The FileRenameComponent simply has a new name String variable rename. The FileRenameSystem uses the family:

all:
  os.components.FileComponent
  files.components.FileRenameComponent

The FileRenameSystem simply uses the FileHandle method of moveTo(FileHandle fileHandle) to move the file to the renamed destination Example:

Entity renameEntity = new Entity()
renameEntity.add(new FileLoadRequest(fileName: "testFile.txt"))
renameEntity.add(new FileRenameComponent(rename: "renamed.txt"))

Similarly to the Copy and Paste example above we use the USER Kernel's system of loading files to retrieve FileComponents.

Frame 0                            Frame 1                             Frame 2
--------------------------   ->    ---------------------------    ->   -----------------------------
renameEntity                       renameEntity                        renameEntity
  FileLoadRequestComponent           FileComponent                       FileComponent
  FileREnameComponent                FileRenameComponent

This is how the directory looks per frame:

Frame 0                            Frame 1                             Frame 2
--------------------------   ->    ---------------------------    ->   -----------------------------
testFile.txt                       testFile.txt                        renamed.txt

This also works on directories as well

Navigation

USER Programs

  • Entity-Component-Systems
  • USER Program Structure

USER OS

  • Built-In Programs
  • API
    • Asset Management
    • Rendering
      • Textures, TextureRegions, NinePatch, Fonts
      • Positioning and Sizing
      • Colors
    • Mouse and Keyboard

Clone this wiki locally