Skip to content

Commit

Permalink
some minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Sep 20, 2024
1 parent 94ffeb9 commit 0e9a62c
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 133 deletions.
2 changes: 1 addition & 1 deletion src/app/system-apps/audioplayer/audioplayer.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { BaseComponent } from 'src/app/system-base/base/base.component';
import { ComponentType } from 'src/app/system-files/component.types';
import {extname, basename} from 'path';
import {extname} from 'path';
import { ProcessIDService } from 'src/app/shared/system-service/process.id.service';
import { Process } from 'src/app/system-files/process';
import { RunningProcessService } from 'src/app/shared/system-service/running.process.service';
Expand Down
218 changes: 117 additions & 101 deletions src/app/system-apps/fileexplorer/fileexplorer.component.ts

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions src/app/system-apps/terminal/terminal.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { StateManagmentService } from "src/app/shared/system-service/state.manag
import {extname, basename, resolve, dirname} from 'path';
import { FileService } from "src/app/shared/system-service/file.service";
import { FileEntry } from 'src/app/system-files/file.entry';
import { Constants } from 'src/app/system-files/constants';


export interface OctalRepresentation {
Expand All @@ -22,12 +23,13 @@ export class TerminalCommands{
private _fileService:FileService;
private _directoryFilesEntries!:FileEntry[];
private _appDirctory = new AppDirectory();
private _consts:Constants = new Constants();

private permissionChart!:Map<number, OctalRepresentation>;
private closingNotAllowed:string[] = ["system", "desktop", "filemanager", "taskbar", "startbutton","clock","taskbarentry"];
private files:FileInfo[] = [];
private readonly defaultDirectoryPath = '/';
private currentDirectoryPath = '/';
private readonly defaultDirectoryPath = this._consts.ROOT;
private currentDirectoryPath = this._consts.ROOT;
private fallBackDirPath = '';

constructor() {
Expand Down Expand Up @@ -352,21 +354,21 @@ ${(file.getIsFile)? '-':'d'}${this.addspaces(strPermission,10)} ${this.addspaces
const filePathRegex = /^(\.\.\/)+([a-zA-Z0-9_-]+\/?)*$|^(\.\/|\/)([a-zA-Z0-9_-]+\/?)+$|^\.\.$|^\.\.\/$/;

if(filePathRegex.test(arg0)){
const cmdArg = arg0.split('/');
const cmdArg = arg0.split(this._consts.ROOT);

//console.log('CMDARG:', cmdArg);
const moveUps = (cmdArg.length > 1)? cmdArg.filter(x => x == "..") : ['..'] ;
const impliedPath = this.cdMoveUp(moveUps);
this.fallBackDirPath = impliedPath;
const explicitPath = (arg0 !== '..')? arg0.split("../").splice(-1)[0] : '';

directory = `${impliedPath}/${explicitPath}`.replace('//','/');
directory = `${impliedPath}/${explicitPath}`.replace(this._consts.DOUBLE_SLASH,this._consts.ROOT);

// console.log('IMPLIEDPATH:', impliedPath);
// console.log('EXPLICITPATH:', explicitPath);
// console.log('DIRECTORY:', directory);
}else{
directory = `${this.currentDirectoryPath}/${arg0}`.replace('//','/');
directory = `${this.currentDirectoryPath}/${arg0}`.replace(this._consts.DOUBLE_SLASH,this._consts.ROOT);
this.fallBackDirPath = this.getFallBackPath(directory);
}

Expand Down Expand Up @@ -410,12 +412,12 @@ ${(file.getIsFile)? '-':'d'}${this.addspaces(strPermission,10)} ${this.addspaces
let directory = '';
let dirPath = '';
let cnt = 0;
const tmpTraversedPath = this.currentDirectoryPath.split('/');
const tmpTraversedPath = this.currentDirectoryPath.split(this._consts.ROOT);
tmpTraversedPath.shift();
const traversedPath = tmpTraversedPath.filter(x => x !== '');

if(traversedPath.length == 0){
return '/';
return this._consts.ROOT;
} else if(traversedPath.length == 1){
directory = traversedPath[0];
return `/${directory}`;
Expand Down Expand Up @@ -461,7 +463,7 @@ ${(file.getIsFile)? '-':'d'}${this.addspaces(strPermission,10)} ${this.addspaces
*this.fallBackDirPath = this.currentDirectoryPath; /osdrive/Documents
*/

const tmpTraversedPath = arg0.split('/');
const tmpTraversedPath = arg0.split(this._consts.ROOT);
const tmpStr:string[] = [];
let dirPath = '';

Expand All @@ -475,7 +477,7 @@ ${(file.getIsFile)? '-':'d'}${this.addspaces(strPermission,10)} ${this.addspaces
traversedPath.forEach(el =>{
tmpStr.push(`/${el}`);
})
tmpStr.push('/');
tmpStr.push(this._consts.ROOT);

dirPath = tmpStr.join('');
return dirPath.replace(',','');
Expand Down Expand Up @@ -669,7 +671,7 @@ Mandatory argument to long options are mandotory for short options too.
}

private sendDirectoryUpdateNotification(arg0:string):void{
if(arg0.includes('/Desktop')){
if(arg0.includes('/Users/Desktop')){
this._fileService.addEventOriginator('filemanager');
}else{
this._fileService.addEventOriginator('fileexplorer');
Expand Down
16 changes: 11 additions & 5 deletions src/app/system-files/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
export class Constants{

IMAGE_FILE_EXTENSIONS = [
readonly EMPTY_STRING = '';
readonly ROOT = '/';
readonly DOUBLE_SLASH = '//';
readonly OSDISK = 'OSDisk (C:)';
readonly THISPC = 'This PC';
readonly URL = '.url';
readonly IMAGE_BASE_PATH = 'osdrive/Cheetah/System/Imageres/';

readonly IMAGE_FILE_EXTENSIONS = [
'.jpg',
'.png',
'.avif',
Expand All @@ -14,16 +22,14 @@ export class Constants{
'.xlm'
]


VIDEO_FILE_EXTENSIONS = [
readonly VIDEO_FILE_EXTENSIONS = [
'.mp4',
'.webm',
'.ogg',
'.mkv'
]


AUDIO_FILE_EXTENSIONS = [
readonly AUDIO_FILE_EXTENSIONS = [
'.mp3',
'.flac',
'.aac',
Expand Down
4 changes: 2 additions & 2 deletions src/osdrive/3d-objects.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=3D-Objects
IconPath=/osdrive/Cheetah/System/Imageres/3d-objects_folder.png
FileType=folder
ContentPath=Users/3D-Objects
ContentPath=/Users/3D-Objects
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/desktop.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Desktop
IconPath=/osdrive/Cheetah/System/Imageres/desktop_folder.png
FileType=folder
ContentPath=Users/Desktop
ContentPath=/Users/Desktop
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/documents.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Documents
IconPath=/osdrive/Cheetah/System/Imageres/documents_folder.png
FileType=folder
ContentPath=Users/Documents
ContentPath=/Users/Documents
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/downloads.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Downloads
IconPath=/osdrive/Cheetah/System/Imageres/downloads_folder.png
FileType=folder
ContentPath=Users/Downloads
ContentPath=/Users/Downloads
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/games.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Games
IconPath=/osdrive/Cheetah/System/Imageres/games_folder.png
FileType=folder
ContentPath=Users/Games
ContentPath=/Users/Games
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/music.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Music
IconPath=/osdrive/Cheetah/System/Imageres/music_folder.png
FileType=folder
ContentPath=Users/Music
ContentPath=/Users/Music
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/pictures.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Pictures
IconPath=/osdrive/Cheetah/System/Imageres/pictures_folder.png
FileType=folder
ContentPath=Users/Pictures
ContentPath=/Users/Pictures
OpensWith=fileexplorer
4 changes: 2 additions & 2 deletions src/osdrive/videos.url
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[InternetShortcut]
FileName=File Explorer
FileName=Videos
IconPath=/osdrive/Cheetah/System/Imageres/videos_folder.png
FileType=folder
ContentPath=Users/Videos
ContentPath=/Users/Videos
OpensWith=fileexplorer

0 comments on commit 0e9a62c

Please sign in to comment.