mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Refactor Node constructor
This commit is contained in:
parent
45406209d8
commit
84e5b2310e
@ -90,14 +90,13 @@ namespace vfs
|
|||||||
}
|
}
|
||||||
|
|
||||||
Node::Node(Node *Parent, const char *Name, NodeType Type,
|
Node::Node(Node *Parent, const char *Name, NodeType Type,
|
||||||
bool NoParent, Virtual *fs, int *Err)
|
bool NoParent, Virtual *_fs, int *Err)
|
||||||
{
|
{
|
||||||
assert(Name != nullptr);
|
assert(Name != nullptr);
|
||||||
assert(strlen(Name) != 0);
|
assert(strlen(Name) != 0);
|
||||||
assert((NoParent == false &&
|
|
||||||
fs == nullptr) ||
|
if (Parent && _fs == nullptr)
|
||||||
(NoParent == true &&
|
_fs = Parent->vFS;
|
||||||
fs != nullptr));
|
|
||||||
|
|
||||||
if (Err != nullptr)
|
if (Err != nullptr)
|
||||||
*Err = 0;
|
*Err = 0;
|
||||||
@ -145,10 +144,10 @@ namespace vfs
|
|||||||
Parent = nullptr;
|
Parent = nullptr;
|
||||||
const char *Path = Name;
|
const char *Path = Name;
|
||||||
|
|
||||||
Node *RootNode = fs->FileSystemRoot->Children[0];
|
Node *RootNode = _fs->FileSystemRoot->Children[0];
|
||||||
Node *CurrentParent = fs->GetParent(Path, Parent);
|
Node *CurrentParent = _fs->GetParent(Path, Parent);
|
||||||
|
|
||||||
if (fs->PathExists(Path, CurrentParent))
|
if (_fs->PathExists(Path, CurrentParent))
|
||||||
{
|
{
|
||||||
debug("Path \"%s\" already exists.", Path);
|
debug("Path \"%s\" already exists.", Path);
|
||||||
delete[] Path;
|
delete[] Path;
|
||||||
@ -158,7 +157,7 @@ namespace vfs
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CleanPath = fs->NormalizePath(Path, CurrentParent);
|
const char *CleanPath = _fs->NormalizePath(Path, CurrentParent);
|
||||||
|
|
||||||
cwk_segment segment;
|
cwk_segment segment;
|
||||||
if (!cwk_path_get_first_segment(CleanPath, &segment))
|
if (!cwk_path_get_first_segment(CleanPath, &segment))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user