From cbd5dca6a922a7f3c32479a43594c9dfe214e2ef Mon Sep 17 00:00:00 2001
From: Pawel Kaczmarek
Date: Mon, 23 Feb 2015 16:05:43 +0100
Subject: [PATCH] [Filesystem] File.resolve
[Verification]
tizen.filesystem.resolve(
'documents',
function(dir) {
var file = dir.resolve("file.txt");
console.log('file: ', file);
},
function(e) { console.log("Error" + e.message);},
"rw");
//should return file object
Change-Id: Ifd67b9547f50b2749ce587fd137dd1991e96c4c8
Signed-off-by: Pawel Kaczmarek
---
src/filesystem/js/file.js | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js
index dbb61fb4..55b8e3be 100644
--- a/src/filesystem/js/file.js
+++ b/src/filesystem/js/file.js
@@ -230,18 +230,24 @@ File.prototype.resolve = function(filePath) {
{name: 'filePath', type: types_.STRING}
]);
- var data = {
- filePath: args.filePath
- };
-
- var result = native_.callSync('File_resolve', data);
+ if (this.isFile) {
+ throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ 'File object which call this method is not directory');
+ }
- if (native_.isFailure(result)) {
- throw native_.getErrorObject(result);
+ if (!this.f_isCorrectRelativePath(args.filePath)) {
+ throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Invalid path');
}
- var returnObject = new File(native_.getResultObject(result));
- return returnObject;
+ var _newPath = this.fullPath + '/' + args.filePath;
+ var _realPath = commonFS_.toRealPath(_newPath);
+ var _result = native_.callSync('File_statSync', {location: _realPath});
+ if (native_.isFailure(_result)) {
+ throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, native_.getErrorObject(_result));
+ }
+ var _statObj = native_.getResultObject(_result);
+ var _fileInfo = commonFS_.getFileInfo(_newPath, _statObj, false, this.mode);
+ return new File(_fileInfo);
};
--
2.34.1