Adds renaming.

This commit is contained in:
Lars Jung 2012-08-12 15:43:33 +02:00
parent 35d85b4e99
commit 9a447a83bd
2 changed files with 35 additions and 1 deletions

View File

@ -247,6 +247,13 @@ var H5AI_CONFIG = {
"size": 150
},
/*
Allow to rename files.
*/
"rename": {
"enabled": false
},
/*
Make entries selectable. At the moment only needed for packaged download and delete.
*/

View File

@ -193,13 +193,40 @@ else if ($action === "delete") {
}
if ($errors->size) {
json_fail(1, "deletion failed for some");
json_fail(2, "deletion failed for some");
} else {
json_exit();
}
}
else if ($action === "rename") {
json_fail(1, "renaming disabled", !$options["rename"]["enabled"]);
list($href, $name) = check_keys(array("href", "name"));
$d = H5ai::normalize_path(dirname($href), true);
$n = basename($href);
$code = $h5ai->getHttpCode($d);
if ($code == 401) {
}
if ($code == "h5ai" && !$h5ai->is_ignored($n)) {
$absPath = $h5ai->getAbsPath($href);
$folder = H5ai::normalize_path(dirname($absPath));
if (!rename($absPath, $folder . "/" . $name)) {
json_fail(2, "renaming failed");
}
}
json_exit();
}
else {
json_fail(100, "unsupported action");
}