diff options
author | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-13 00:19:20 +0200 |
---|---|---|
committer | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-13 00:19:20 +0200 |
commit | a218bdd5fc29f4dab9f68c4eb9173db0627046c1 (patch) | |
tree | e652d4bdfde58f258352e203fa681b6347cb942a /php | |
parent | a6cedb9c67284ebdf7e475c1b9fdab63b5a44c79 (diff) | |
download | fileup-a218bdd5fc29f4dab9f68c4eb9173db0627046c1.tar.gz |
Compressed get_directory
Diffstat (limited to 'php')
-rw-r--r-- | php/node.php | 26 |
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; } |