summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-13 13:09:10 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-13 13:09:10 +0200
commitb808b613a5c7e0b6c6c45b28f7f0169dc13afaa2 (patch)
tree99d656cfc6425f3d4720a8d1bd3b7a5717d0a558 /Source/Kernel
parentbdf19d4a139005390670380cb2c811febdfa5747 (diff)
downloadMelon-b808b613a5c7e0b6c6c45b28f7f0169dc13afaa2.tar.gz
Melon-b808b613a5c7e0b6c6c45b28f7f0169dc13afaa2.zip
Created some files
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamDirNode.class.cpp0
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamDirNode.class.h0
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.cpp0
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.h0
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFileNode.class.cpp0
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFileNode.class.h0
-rw-r--r--Source/Kernel/VFS/DirectoryNode.proto.h42
-rw-r--r--Source/Kernel/VFS/FSNode.proto.h7
-rw-r--r--Source/Kernel/VFS/FileNode.proto.h24
-rw-r--r--Source/Kernel/VFS/FileSystem.proto.h4
-rw-r--r--Source/Kernel/VFS/VFS.ns.h10
11 files changed, 85 insertions, 2 deletions
diff --git a/Source/Kernel/FileSystems/RamFS/RamDirNode.class.cpp b/Source/Kernel/FileSystems/RamFS/RamDirNode.class.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Kernel/FileSystems/RamFS/RamDirNode.class.cpp
diff --git a/Source/Kernel/FileSystems/RamFS/RamDirNode.class.h b/Source/Kernel/FileSystems/RamFS/RamDirNode.class.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Kernel/FileSystems/RamFS/RamDirNode.class.h
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.h b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
diff --git a/Source/Kernel/FileSystems/RamFS/RamFileNode.class.cpp b/Source/Kernel/FileSystems/RamFS/RamFileNode.class.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Kernel/FileSystems/RamFS/RamFileNode.class.cpp
diff --git a/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h b/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h
diff --git a/Source/Kernel/VFS/DirectoryNode.proto.h b/Source/Kernel/VFS/DirectoryNode.proto.h
index 08e474b..f9c1c9f 100644
--- a/Source/Kernel/VFS/DirectoryNode.proto.h
+++ b/Source/Kernel/VFS/DirectoryNode.proto.h
@@ -1,4 +1,46 @@
#ifndef DEF_DIRECTORYNODE_PROTO_H
#define DEF_DIRECTORYNODE_PROTO_H
+#include <VFS/FSNode.proto.h>
+#include <Library/Vector.class.h>
+
+class DirectoryNode : public virtual FSNode {
+ protected:
+ Vector<FSNode*> m_children;
+ bool m_contentLoaded;
+
+ protected:
+ DirectoryNode() : m_children(), m_contentLoaded(false) {}
+
+ virtual bool FSLoadContent() = 0;
+
+ public:
+ bool loadContent() {
+ if (m_contentLoaded) return true;
+ bool b = FSLoadContent();
+ m_length = m_children.size();
+ if (b) m_contentLoaded = true;
+ return b;
+ }
+
+ FSNode* getChild(u32int index) {
+ if (!m_contentLoaded)
+ if (!loadContent)
+ return NULL;
+ if (index >= m_children.size()) return NULL;
+ return m_children[index];
+ }
+
+ FSNode* getChild(String name) {
+ if (!m_contentLoaded)
+ if (!loadContent)
+ return NULL;
+ for (u32int i = 0; i < m_children.size(); i++) {
+ if (m_children[i]->getName() == name)
+ return m_children[i];
+ }
+ return NULL;
+ }
+};
+
#endif
diff --git a/Source/Kernel/VFS/FSNode.proto.h b/Source/Kernel/VFS/FSNode.proto.h
index bc350f9..62d28be 100644
--- a/Source/Kernel/VFS/FSNode.proto.h
+++ b/Source/Kernel/VFS/FSNode.proto.h
@@ -22,15 +22,16 @@ class FSNode {
FSNode *m_parent;
u32int m_inode;
- public:
FSNode(String name, FileSystem* fs, FSNode* parent, u32int inode, u32int length = 0, u32int permissions = 0777,
u32int uid = 0, u32int gid = 0) :
m_name(name), m_fs(fs), m_parent(parent), m_inode(inode), m_length(length), m_premissions(permissions),
m_uid(uid), m_gid(gid) {}
+
+ public:
virtual u8int type() = 0;
- String getName() { return m_name; }
+ const String& getName() { return m_name; }
u32int getLength() { return m_length; }
u32int getPermissions() { return m_permissions; }
u32int getUid() { return m_uid; }
@@ -39,6 +40,7 @@ class FSNode {
FSNode* getParent() { return m_parent; }
u32int getInode() { return m_inode; }
+ protected:
//Must be implemented by *FSNode
virtual bool FSSetName(String name) = 0;
virtual bool FSTruncate() = 0;
@@ -47,6 +49,7 @@ class FSNode {
virtual bool FSSetGid(u32int gid) = 0;
virtual bool FSSetParent(FSNode* parent) = 0;
+ public:
bool setName(String name) {
bool b = FSSetName(name);
if (b) m_name = name;
diff --git a/Source/Kernel/VFS/FileNode.proto.h b/Source/Kernel/VFS/FileNode.proto.h
new file mode 100644
index 0000000..b02c277
--- /dev/null
+++ b/Source/Kernel/VFS/FileNode.proto.h
@@ -0,0 +1,24 @@
+#ifndef DEF_FILENODE_PROTO_H
+#define DEF_FILENODE_PROTO_H
+
+#include <VFS/FSNode.proto.h>
+
+class FileNode : public virtual FSNode {
+ protected:
+ DirectoryNode() {}
+
+ virtual bool FSRead(u64int position, u32int max_length, u8int *data) = 0;
+ virtual bool FSWrite(u64int position, u32int length, u8int *data) = 0;
+
+ public:
+ bool read(u64int position, u32int max_length, u8int *data) {
+ return FSRead(position, max_length, data);
+ }
+
+ bool write(u64int position, u32int length, u8int *data) {
+ return FSWrite(position, length, data);
+ }
+
+};
+
+#endif
diff --git a/Source/Kernel/VFS/FileSystem.proto.h b/Source/Kernel/VFS/FileSystem.proto.h
new file mode 100644
index 0000000..523caf7
--- /dev/null
+++ b/Source/Kernel/VFS/FileSystem.proto.h
@@ -0,0 +1,4 @@
+#ifndef DEF_FILESYSTEM_PROTO_H
+#define DEF_FILESYSTEM_PROTO_H
+
+#endif
diff --git a/Source/Kernel/VFS/VFS.ns.h b/Source/Kernel/VFS/VFS.ns.h
new file mode 100644
index 0000000..cdd6e23
--- /dev/null
+++ b/Source/Kernel/VFS/VFS.ns.h
@@ -0,0 +1,10 @@
+#ifndef DEF_VFS_NS_H
+#define DEF_VFS_NS_H
+
+#include <VFS/FSNode.proto.h>
+
+namespace VFS {
+
+}
+
+#endif