-
Notifications
You must be signed in to change notification settings - Fork 0
USER OS Program: Files
Files is a simple file explorer that is commonly found on existing Operating Systems. This program has the following features:
- View and go through directories
- Copy and Paste Folders and Files
- Delete Files
Here is an overview of the USER Files architecture.

Here is documentation on how to use the Files program's Systems and Components to your advantage:
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.
The FileDeleteSystem is not part of the Files program but is rooted in the USER Kernel itself. Refer to Kernel documentation instead.
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