blob: 3d56d99de8e252f4f8f490b7f05ff3d68c213851 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<?php
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)
{
global $database;
if($abstract_path[0]!="/")
{
return NULL;
}
if($component=strtok($abstract_path,"/")==false)
{
return $database->get_links_of($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;
}
return $database->get_links_of($current_dir);
}
?>
|