mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 10:38:26 +00:00
feature(commander) getDirPath -> addSlashToEnd
This commit is contained in:
parent
b1e741cb38
commit
8cf5a61a3c
1 changed files with 13 additions and 8 deletions
|
|
@ -38,7 +38,7 @@
|
|||
function readDir(params, error, files) {
|
||||
var i, n, stats, filesData, fill, name, fileParams,
|
||||
p = params,
|
||||
dirPath = getDirPath(p.path);
|
||||
dirPath = addSlashToEnd(p.path);
|
||||
|
||||
if (error)
|
||||
Util.exec(p.callback, error.toString());
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
|
||||
/* данные о файлах в формате JSON*/
|
||||
file = {};
|
||||
path = getDirPath(p.path);
|
||||
path = addSlashToEnd(p.path);
|
||||
json = {
|
||||
path : path,
|
||||
files : []
|
||||
|
|
@ -212,13 +212,18 @@
|
|||
return sorted;
|
||||
}
|
||||
|
||||
function getDirPath(pPath) {
|
||||
var lRet = pPath;
|
||||
function addSlashToEnd(path) {
|
||||
var length, isSlash;
|
||||
|
||||
if (lRet !== '/')
|
||||
lRet += '/';
|
||||
if (path) {
|
||||
length = path.length - 1;
|
||||
isSlash = path[length] === '/';
|
||||
|
||||
if (!isSlash)
|
||||
path += '/';
|
||||
}
|
||||
|
||||
return lRet;
|
||||
return path;
|
||||
}
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue