From b79da4bf1b39d6b203a083c7bcbef106dff06eaa Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 12 Feb 2021 22:35:02 +0200 Subject: mkdir --- php/mkdir.php | 14 ++++++++++++++ php/node.php | 25 ++++++++++++++++++++++--- php/readdir.php | 4 ++-- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 php/mkdir.php (limited to 'php') diff --git a/php/mkdir.php b/php/mkdir.php new file mode 100644 index 0000000..cf5e8e4 --- /dev/null +++ b/php/mkdir.php @@ -0,0 +1,14 @@ + diff --git a/php/node.php b/php/node.php index 3d56d99..b3b2c3f 100644 --- a/php/node.php +++ b/php/node.php @@ -3,7 +3,6 @@ require_once "database.php"; require_once "user.php"; - /*returns an assoc arrat of Node-s*/ /*path is in terms of the simulated filesystem*/ function get_directory(string $abstract_path,User $user) { @@ -14,7 +13,7 @@ require_once "user.php"; } if($component=strtok($abstract_path,"/")==false) { - return $database->get_links_of($user->home_directory); + return $user->home_directory; } $current_dir=$database->get_node_id($component,$user->home_directory); if($current_dir==NULL) @@ -26,7 +25,27 @@ require_once "user.php"; if($current_dir==NULL) return NULL; } - return $database->get_links_of($current_dir); + return $current_dir; + } + + /*returns an assoc arrat of Node-s*/ + /*path is in terms of the simulated filesystem*/ + function get_directory_contents(string $abstract_path,User $user) + { + global $database; + $dir_id=get_directory($abstract_path,$user); + if($dir_id==NULL) + return NULL; + return $database->get_links_of($dir_id); + } + + /*path is in terms of the simulated filesystem*/ + function create_directory(string $abstract_path,string $directory_name,string $note,User $user) + { + global $database; + $dir_id=$database->create_dangling_directory(); + $parent_dir_id=get_directory($abstract_path,$user); + $database->link_nodes($parent_dir_id,$dir_id,$directory_name,$note); } ?> diff --git a/php/readdir.php b/php/readdir.php index e46d4ad..04587ee 100644 --- a/php/readdir.php +++ b/php/readdir.php @@ -1,10 +1,10 @@ -- cgit v1.2.3