[Features] Fixed issues:
1. resolve "documents/" works as resolving "documents"
2. multiple "/" is filepaths are merged to single one
[Verification] Code compiles without errors.
TCTs of Filesystem, Calendar, Alarm, Archive and Exif return 100% passrate.
Scenarios with results below:
1.
tizen.filesystem.resolve(
'images/',
function(dir) {
var a = dir.createDirectory('testt');
console.log("path: " + a.path + " fullPath: " + a.fullPath);
}, function(e) {
console.log("Error: " + e.message);
}, "rw"
);
---------
path: images/ fullPath: images/testt
2.
tizen.filesystem.resolve(
'images/testt/',
function(dir) {
console.log("Mount point Name is " + dir.path);
console.log("path: " + dir.path + " fullPath: " + dir.fullPath);
}, function(e) {
console.log("Error: " + e.message);
}, "rw"
);
---------
path: images/ fullPath: images/testt
3.
tizen.filesystem.resolve(
'images//////testt/',
function(dir) {
console.log("Mount point Name is " + dir.path);
console.log("path: " + dir.path + " fullPath: " + dir.fullPath);
}, function(e) {
console.log("Error: " + e.message);
}, "rw"
);
---------
path: images/ fullPath: images/testt
Change-Id: I66ce92a5207148dfa82109e187b8e4f58727aead
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
cacheReady = true;
}
+ function mergeMultipleSlashes(str) {
+ var s = str[0];
+ var resStr = s;
+ for (var i=1; i < str.length; ++i ) {
+ if (!(str[i] === s && str[i] === '/')) {
+ s = str[i];
+ resStr+=str[i];
+ }
+ }
+ return resStr;
+ }
+
function toRealPath(aPath) {
var _fileRealPath = '';
} else {
_fileRealPath = aPath;
}
-
+ // if path is valid try to cut last '/' if it is present
+ if (_fileRealPath) {
+ _fileRealPath = mergeMultipleSlashes(_fileRealPath);
+ var lastCharIndex = _fileRealPath.length-1;
+ if (_fileRealPath[lastCharIndex] === '/') {
+ _fileRealPath = _fileRealPath.substr(0,lastCharIndex);
+ }
+ }
return _fileRealPath;
}
}
}
- return aPath;
+ // cutting of last '/' if it is present
+ var lastCharIndex = aPath.length-1;
+ if (aPath[lastCharIndex] === '/') {
+ aPath = aPath.substr(0,lastCharIndex);
+ }
+ return mergeMultipleSlashes(aPath);
}
function getFileInfo(aStatObj, secondIter, aMode) {
}
if (_oldNode.isFile && addFileName) {
- _realDestinationPath += _realOriginalPath.split('/').pop();
+ _realDestinationPath += '/' + _realOriginalPath.split('/').pop();
}
if (!args.overwrite) {