aboutsummaryrefslogtreecommitdiffstats
path: root/php/node.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/node.php')
-rw-r--r--php/node.php26
1 files changed, 10 insertions, 16 deletions
diff --git a/php/node.php b/php/node.php
index c2ab5f1..bb404e0 100644
--- a/php/node.php
+++ b/php/node.php
@@ -7,24 +7,18 @@ require_once "user.php";
function get_directory(string $abstract_path,User $user)
{
global $database;
- if($abstract_path[0]!="/")
- {
+ if($abstract_path[0] != "/") {
return NULL;
}
- if($component=strtok($abstract_path,"/")==false)
- {
- return $user->home_directory;
- }
- $current_dir=$database->get_node_id($component,$user->home_directory);
- if($current_dir==NULL)
- return NULL;
- /*traverse path*/
- while($component=strtok("/"))
- {
- $current_dir=$database->get_node_id($component,$current_dir);
- if($current_dir==NULL)
- return NULL;
- }
+
+ $component = strtok($abstract_path,"/");
+ $current_dir = $user->home_directory;
+
+ while ($component) {
+ $current_dir = $database->get_node_id($component, $current_dir);
+ $component = strtok("/");
+ };
+
return $current_dir;
}