aboutsummaryrefslogtreecommitdiffstats
path: root/php/node.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/node.php')
-rw-r--r--php/node.php44
1 files changed, 18 insertions, 26 deletions
diff --git a/php/node.php b/php/node.php
index 062da90..62b9ad2 100644
--- a/php/node.php
+++ b/php/node.php
@@ -1,39 +1,31 @@
<?php
require_once "database.php";
+require_once "user.php";
- class Node
+
+ /*returns an assoc arrat of Node-s*/
+ /*path is in terms of the simulated filesystem*/
+ function get_directory(string $abstract_path,User $user)
{
- public $node_id;
- public $is_directory;
- public $relative_path;
- public $type;
- public $name;
- public $note;
- function __construct($node_id)
+ if($abstract_path[0]!="/")
{
- $this->node_id=$node_id;
+ return NULL;
}
- }
-
- class Current_Directory extends Node
- {
- /*an array of the dir_ids taken to reach here*/
- public $path;
-
- function __construct($user_id)
+ if($component=strtok($abstract_path,"/")==false)
{
- $this->dir_id=get_home_id($user_id);
- $this->path=[$dir_id];
+ return NULL;
}
- function change_directory($directory_id):bool
+ $current_dir=$database->get_node($component,$user->home_directory);
+ if($current_dir==NULL)
+ return NULL;
+ /*traverse path*/
+ while($component=strtok("/"))
{
- global $database;
- if(!$database->is_directory($directory_id))
- {
- return false;
- }
-
+ $current_dir=get_node($component,$current_dir);
+ if($current_dir==NULL)
+ return NULL;
}
+ return get_links_of(NULL,$current_dir);
}
?>