Skip to content

Commit 3a79ee8

Browse files
committed
I'm crushing your head!
1 parent 1df42a9 commit 3a79ee8

11 files changed

Lines changed: 562 additions & 372 deletions

File tree

apps/Folder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ cwarn("No path given (Win._fullpath)");
395395
}
396396
dir = await fs.pathToNode(path);
397397
if (!dir) {
398+
delete this.node;
398399
if (path) poperr(`Directory not found: ${path}`);
399400
else cwarn("Opening in 'app mode'");
400401
return;
@@ -428,7 +429,7 @@ cwarn("No path given (Win._fullpath)");
428429
load_dir();
429430
}//»
430431
else load_dir();
431-
432+
this.node = dir;
432433
if (dir.type!==FS_TYPE) {
433434
num_entries = Object.keys(dir.kids).length-2;
434435
stat_num();

apps/Terminal.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -894,25 +894,6 @@ objToString(obj ){//«
894894
return `[object ${obj.constructor.name}]`;
895895
}
896896
//»
897-
async getHistory(val){//«
898-
let fnode = await fsapi.pathToNode(HISTORY_FOLDER);
899-
if (!fnode){
900-
if (!await fsapi.mkDir(globals.user.HOME_PATH, ".history")){
901-
cerr("Could not make the .history folder!");
902-
return;
903-
}
904-
}
905-
else if (fnode.appName !== FOLDER_APP){
906-
cwarn("History directory path is NOT a directory!!!");
907-
return;
908-
}
909-
let node = await fsapi.pathToNode(HISTORY_PATH);
910-
if (!node) return;
911-
let text = await node.text;
912-
if (!text) return;
913-
return text.split("\n");
914-
}
915-
//»
916897
scrollMiddle(){//«
917898
const{main}=this;
918899
let y1 = main.scrollTop;
@@ -2003,6 +1984,8 @@ historyDownMatching(){//«
20031984
}
20041985
}//»
20051986
async saveSpecialCommand(){//«
1987+
cwarn("UPDATE saveSpecialCommand to call node.setValue (and not fsapi.writeFile!!!)");
1988+
return;
20061989
let s = this.getComArr().join("");
20071990
if (!s.match(/[a-z]/i)) {
20081991
log("Not saving", s);
@@ -2013,7 +1996,8 @@ log("Not saving", s);
20131996
};
20141997
//»
20151998
async appendToHistory(str){//«
2016-
if (!await fsapi.writeFile(HISTORY_PATH, `${str}\n`, {append: true})) {
1999+
// if (!await fsapi.writeFile(HISTORY_PATH, `${str}\n`, {append: true})) {
2000+
if (!await this.historyNode.setValue(`${str}\n`, {append: true})) {
20172001
cwarn(`Could not write to history: ${HISTORY_PATH}`);
20182002
}
20192003
};
@@ -2049,6 +2033,30 @@ async initHistory(termBuffer){//«
20492033
this.history = arr.reverse();
20502034
}
20512035
}//»
2036+
async getHistory(val){//«
2037+
let fnode = await fsapi.pathToNode(HISTORY_FOLDER);
2038+
if (!fnode){
2039+
if (!await fsapi.mkDir(globals.user.HOME_PATH, ".history")){
2040+
cerr("Could not make the .history folder!");
2041+
return;
2042+
}
2043+
}
2044+
else if (fnode.appName !== FOLDER_APP){
2045+
cwarn("History directory path is NOT a directory!!!");
2046+
return;
2047+
}
2048+
let node = await fsapi.pathToNode(HISTORY_PATH);
2049+
if (!node) {
2050+
node = await fsapi.touchFile(fnode, "shell.txt");
2051+
this.historyNode = node;
2052+
return;
2053+
}
2054+
this.historyNode = node;
2055+
let text = await node.text;
2056+
if (!text) return;
2057+
return text.split("\n");
2058+
}
2059+
//»
20522060

20532061
/*
20542062
async saveHistory(){//«

apps/TextEdit.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,19 @@ cwarn("Got topwin.fullpath but not topwin.icon!!!");
111111

112112
let ext = EXTENSIONS[USE_EXT];
113113

114-
let {path, name} = await Desk.api.saveAs(topwin, ext);
115-
//cwarn("WHAT IN THE HELLLLL????????");
116-
//Win.up();
117-
//Win.on();
118-
if (!path) {
114+
//let {path, name} = await Desk.api.saveAs(topwin, ext);
115+
let {parNode, name} = await Desk.api.saveAs(topwin, ext);
116+
if (!parNode) {
119117
return;
120118
}
119+
let path = parNode.fullpath;
121120
name = name.trim();
122121
if (!name.match(/^[-._a-zA-Z0-9 ]+$/)){
123122
return poperr("Invalid name");
124123
}
125124
let fullpath = `${path}/${name}.${ext}`;
126-
127-
if (! await fsapi.checkDirPerm(path)) return poperr(`${path}: permission denied`);
125+
//if (! await fsapi.checkDirPerm(path)) return poperr(`${path}: permission denied`);
126+
if (!parNode.okWrite) return poperr(`${path}: permission denied`);
128127
if (await fsapi.pathToNode(fullpath)) return poperr(`${fullpath}: Already exists`);
129128

130129
let node = await fsapi.writeFile(fullpath, area.value);

coms/extra.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const validate_out_path = async(outpath)=>{//«
6666
let parpath = arr.join("/");
6767
let parnode = await pathToNode(parpath);
6868
if (!parnode) return `${parpath}: The directory doesn't exist`;
69-
if (! await fsapi.checkDirPerm(parnode)){
69+
// if (! await fsapi.checkDirPerm(parnode)){
70+
if (!parnode.okWrite){
7071
return `${parpath}: permission denied`;
7172
}
7273
return true;

coms/fs.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/*9/3/25: Have been doing a major update to piping logic in shell.js. The derived commands
1+
/*9/3/25: Have been doing a major update to piping logic in shell.js. The derived commands«
22
should define pipeIn methods for streaming purposes, and pipeDone methods in order to
33
receive every all at once in a JS array, after the EOF has been received.
44
com_brep uses a highly non-trivial piping logic using Uint8Array's.
5-
*/
5+
»*/
66
//Imports«
77

88
//import { util, api as capi } from "util";
@@ -439,7 +439,8 @@ return {mess: "YIM ON THE YIM YIM YIM", type: 2};
439439
let path = arr.join("/");
440440
parnode = await fsapi.pathToNode(path);
441441
if (!parnode) return this.no(`${path}: no such directory`);
442-
if (!await fsapi.checkDirPerm(path)) return this.no(`${fullpath}: permission denied`);
442+
// if (!await fsapi.checkDirPerm(path)) return this.no(`${fullpath}: permission denied`);
443+
if (!parnode.okWrite) return this.no(`${fullpath}: permission denied`);
443444
val = "";
444445
typ = parnode.root.type;
445446
}
@@ -676,13 +677,12 @@ async run(){
676677
err(`${parpath}: Not a directory`);
677678
continue;
678679
}
679-
680-
let OK_TYPES = [FS_TYPE, SHM_TYPE];
680+
let OK_TYPES = [FS_TYPE, SHM_TYPE, USERS_TYPE];
681681
if (!OK_TYPES.includes(parnode.type)) {
682682
err(`${fullpath}: The parent directory has an unsupported type: '${parnode.type}'`);
683683
continue;
684684
}
685-
if (!await fsapi.checkDirPerm(parnode)) {
685+
if (!parnode.okWrite) {
686686
err(`${path}: Permission denied`);
687687
continue;
688688
}
@@ -767,7 +767,8 @@ async run(){
767767
continue;
768768
}
769769
// if (!await fsapi.checkDirPerm(parnode)) {
770-
if (parnode.type === FS_TYPE && !await fsapi.checkDirPerm(parnode)) {
770+
if (!parnode.okWrite) {
771+
// if (parnode.type === FS_TYPE && !await fsapi.checkDirPerm(parnode)) {
771772
err(`${fullpath}: permission denied`);
772773
continue;
773774
}
@@ -877,7 +878,8 @@ async run(){
877878
return err("the target node does not have an associated blob in the blob store");
878879
}
879880

880-
if (!await fsapi.checkDirPerm(target_node.par)) {
881+
// if (!await fsapi.checkDirPerm(target_node.par)) {
882+
if (!target_node.par.okWrite) {
881883
return err(`${target_node.par.fullpath}: permission denied`);
882884
}
883885

@@ -897,7 +899,8 @@ async run(){
897899
if (parnode.type !== FS_TYPE) {
898900
return err(`${fullpath}: the parent directory is not of type '${FS_TYPE}'`);
899901
}
900-
if (!await fsapi.checkDirPerm(parnode)) {
902+
// if (!await fsapi.checkDirPerm(parnode)) {
903+
if (!parnode.okWrite) {
901904
return err(`${path}: permission denied`);
902905
}
903906
let newnode = await fsapi.makeHardLink(parnode, fname, blobid);
@@ -943,7 +946,8 @@ async run(){
943946
if (parnode.type !== FS_TYPE) {
944947
return err(`${fullpath}: the parent directory is not of type '${FS_TYPE}'`);
945948
}
946-
if (!await fsapi.checkDirPerm(parnode)) {
949+
// if (!await fsapi.checkDirPerm(parnode)) {
950+
if (!parnode.okWrite) {
947951
return err(`${path}: permission denied`);
948952
}
949953
let newnode = await fsapi.makeLink(parnode, fname, target, normPath(target, this.term.cur_dir));

0 commit comments

Comments
 (0)