From 66630e4154b7c1c47d6223fe5a8607cd269446a0 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 23 Oct 2009 20:43:48 +0200 Subject: Some changes, and implemented rm in userland shell. --- Source/Library/Interface/FSNode.iface.h | 1 + Source/Library/Userland/Binding/FSNode.class.h | 37 +++++++++++++++------- Source/Library/Userland/Binding/Process.class.h | 5 +++ Source/Library/Userland/Binding/Thread.class.h | 5 +++ .../Userland/Binding/VirtualTerminal.class.h | 5 +++ 5 files changed, 41 insertions(+), 12 deletions(-) (limited to 'Source/Library') diff --git a/Source/Library/Interface/FSNode.iface.h b/Source/Library/Interface/FSNode.iface.h index cba4621..3a5dfad 100644 --- a/Source/Library/Interface/FSNode.iface.h +++ b/Source/Library/Interface/FSNode.iface.h @@ -24,6 +24,7 @@ enum { #define FNIF_GETPERM 0x16 #define FNIF_GETPATH 0x17 #define FNIF_SETCWD 0x18 //Sets node as current working directory +#define FNIF_REMOVE 0x19 #define FNIF_GETIDXCHILD 0x20 //Get child node from index #define FNIF_GETNAMECHILD 0x21 //Get child node from name diff --git a/Source/Library/Userland/Binding/FSNode.class.h b/Source/Library/Userland/Binding/FSNode.class.h index 61ac991..1fdc7ef 100644 --- a/Source/Library/Userland/Binding/FSNode.class.h +++ b/Source/Library/Userland/Binding/FSNode.class.h @@ -1,17 +1,11 @@ +#ifndef DEF_FSNODE_CLASS_H +#define DEF_FSNODE_CLASS_H + #include #include class FSNode : public RessourceCaller { public: - static FSNode getRoot() { - return FSNode(sCall(FNIF_OBJTYPE, FNIF_SGETRFN)); - } - static FSNode getCwd() { - return FSNode(sCall(FNIF_OBJTYPE, FNIF_SGETCWD)); - } - static FSNode find(String path) { //Finds a node starting from root node - return FSNode(sCall(FNIF_OBJTYPE, FNIF_SFIND, (u32int)&path, 0)); - } FSNode(u32int id) : RessourceCaller(id, FNIF_OBJTYPE) {} String getName() { @@ -41,13 +35,32 @@ class FSNode : public RessourceCaller { void setCwd() { doCall(FNIF_SETCWD); } + bool remove() { + return doCall(FNIF_REMOVE) != 0; + } FSNode getChild(u32int idx) { return FSNode(doCall(FNIF_GETIDXCHILD, idx)); } FSNode getChild(String name) { return FSNode(doCall(FNIF_GETNAMECHILD, (u32int)&name)); } - FSNode findFrom(String path) { //Search a filesystem node starting from here - return FSNode(sCall(FNIF_OBJTYPE, FNIF_SFIND, (u32int)&path, resId())); - } }; + +namespace FS { + +inline FSNode rootNode() { + return FSNode(RessourceCaller::sCall(FNIF_OBJTYPE, FNIF_SGETRFN)); +} + +inline FSNode cwdNode() { + return FSNode(RessourceCaller::sCall(FNIF_OBJTYPE, FNIF_SGETCWD)); +} + +inline FSNode find(String name, FSNode cwd = FSNode(0)) { + if (!cwd.valid()) cwd = rootNode(); + return FSNode(RessourceCaller::sCall(FNIF_OBJTYPE, FNIF_SFIND, (u32int)&name, cwd.resId())); +} + +} + +#endif diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h index 935bb39..ddca6be 100644 --- a/Source/Library/Userland/Binding/Process.class.h +++ b/Source/Library/Userland/Binding/Process.class.h @@ -1,3 +1,6 @@ +#ifndef DEF_PROCESS_CLASS_H +#define DEF_PROCESS_CLASS_H + #include #include @@ -30,3 +33,5 @@ class Process : public RessourceCaller { return String::unserialize(doCall(PRIF_GETCMDLINE)); } }; + +#endif diff --git a/Source/Library/Userland/Binding/Thread.class.h b/Source/Library/Userland/Binding/Thread.class.h index a19c256..1588d8c 100644 --- a/Source/Library/Userland/Binding/Thread.class.h +++ b/Source/Library/Userland/Binding/Thread.class.h @@ -1,3 +1,6 @@ +#ifndef DEF_THREAD_CLASS_H +#define DEF_THREAD_CLASS_H + #include #include @@ -17,3 +20,5 @@ class Thread : public RessourceCaller { doCall(THIF_FINISH, errcode); } }; + +#endif diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h index 06a8dd7..1bfce85 100644 --- a/Source/Library/Userland/Binding/VirtualTerminal.class.h +++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h @@ -1,3 +1,6 @@ +#ifndef DEF_VIRTUALTERMINAL_CLASS_H +#define DEF_VIRTUALTERMINAL_CLASS_H + #include #include @@ -52,3 +55,5 @@ class VirtualTerminal : public RessourceCaller { }; extern VirtualTerminal invt, outvt; + +#endif -- cgit v1.2.3