Fix directory path when is symlink

Change the directory path to follow symlinks
This commit is contained in:
steve-lad
2021-07-15 08:38:24 +02:00
parent 6e5cfaa3eb
commit 6e28b501e9
2 changed files with 16 additions and 15 deletions

View File

@@ -9,15 +9,16 @@ function createCats($currDirPos){
if(is_dir($currDirPos)){
// Remove unix ./..
foreach (array_diff(scandir($currDirPos),array('.','..')) as $subDir) {
//remove link information
$subDir = (explode(' ', $subDir));
if(is_dir("{$currDirPos}/{$subDir[0]}")) {
$xml .= "<Directory name = '{$subDir[0]}'><DirectoryPath>" . ltrim("{$currDirPos}/{$subDir[0]}",'./') . "/</DirectoryPath>";
$xml .= createCats("{$currDirPos}/{$subDir[0]}");
if (is_dir("{$currDirPos}/{$subDir}")) {
$thisPath = "{$currDirPos}/{$subDir}";
if (is_link("{$currDirPos}/{$subDir}")) {
$thisPath= $currDirPos . "/" . readlink("{$currDirPos}/{$subDir}");
}
$xml .= "<Directory name = '{$subDir}'><DirectoryPath>" . ltrim($thisPath,'./') . "/</DirectoryPath>";
$xml .= createCats("{$currDirPos}/{$subDir}");
$xml .= "</Directory>";
} else {
$xml .= "<FileName>{$subDir[0]}</FileName>";
$xml .= "<FileName>{$subDir}</FileName>";
}
}
}