Helpers: added transpose_user_path function

This commit is contained in:
Eric Schultz
2015-11-25 22:32:13 -06:00
parent 86814f808d
commit 15d0e51e22
+11
View File
@@ -203,4 +203,15 @@ function autov($file) {
clearstatcache(true, $docroot.$file);
echo "$file?v=".filemtime($docroot.$file);
}
function transpose_user_path($path) {
if (strpos($path, '/mnt/user/') === 0 && file_exists($path)) {
$realdisk = trim(shell_exec("getfattr --absolute-names -n user.LOCATIONS ".escapeshellarg($path)." 2>/dev/null|grep -Po '^user.LOCATIONS=\"\K[^\\\"]+'"));
if (!empty($realdisk)) {
// there may be several disks participating in this path (e.g. disk1,2,3) so
// only return the first disk and replace 'user' with say 'cache' or 'disk1'
$path = str_replace('/mnt/user/', '/mnt/'.strtok($realdisk.',', ',').'/', $dir);
}
}
return $path;
}
?>