File.fullPath property returned real path that is not expected.
This property should return virtual path.
Moreover, cacheRealToVirtual was removed as obsolete.
[Verification]
TCT tests should pass.
File.fullPath property should return virtual root path.
Change-Id: I8cd712e0830e38e7823bcb8b902830385d2b24cb
Signed-off-by: Kamil Lysik <k.lysik@samsung.com>
CommonFS.prototype.cacheVirtualToReal = {};
-CommonFS.prototype.cacheRealToVirtual = {};
-
CommonFS.prototype.cacheStorages = [];
-CommonFS.prototype.getFileInfo = function(aPath, aStatObj, secondIter, aMode) {
+CommonFS.prototype.getFileInfo = function(aStatObj, secondIter, aMode) {
var _result = {},
_pathTokens,
_fileParentPath = '',
i;
-
- if (aPath.indexOf('file://') === 0) {
- aPath = aPath.substr('file://'.length);
- }
-
- if (aPath[0] === '/') {
- aPath = aPath.substr(1);
- _fileParentPath = '/';
- }
+ var aPath = this.toVirtualPath(aStatObj.path);
_result.readOnly = aStatObj.readOnly;
_result.isFile = aStatObj.isFile;
_result.isDirectory = aStatObj.isDirectory;
_result.created = new Date(aStatObj.ctime * 1000);
_result.modified = new Date(aStatObj.mtime * 1000);
- _result.fullPath = _fileParentPath + aPath;
+ _result.fullPath = aPath;
_result.fileSize = aStatObj.size;
_result.mode = aMode;
if (_result.isDirectory) {
_result.parent = (secondIter) ? null : _fileParentPath;
} else {
_result.parent = null;
- _result.path = _fileParentPath === '/' ? _fileParentPath : aPath;
- _result.name = _fileParentPath === '/' ? aPath : '';
+ _result.path = aPath;
+ _result.name = '';
}
return _result;
};
for (i = 1; i < _pathTokens.length; ++i) {
_fileRealPath += '/' + _pathTokens[i];
}
- this.cacheRealToVirtual[_fileRealPath] = aPath;
} else {
//If path token is not present in cache then it is invalid
_fileRealPath = undefined;
if (_virtualPath.indexOf('file://') === 0) {
_virtualPath = _virtualPath.substr('file://'.length);
}
- for (var real_path in this.cacheRealToVirtual) {
- if (_virtualPath.indexOf(real_path) === 0) {
- return _virtualPath.replace(
- real_path,
- this.cacheRealToVirtual[real_path]);
+
+ for (var virtual_root in this.cacheVirtualToReal) {
+ var real_root_path = this.cacheVirtualToReal[virtual_root].path;
+ if (aPath.indexOf(real_root_path, 0) === 0) {
+ return aPath.replace(real_root_path, virtual_root)
}
}
state: FileSystemStorageState.MOUNTED
};
- this.cacheRealToVirtual[widgetsPaths['wgt-package']] = 'wgt-package';
- this.cacheRealToVirtual[widgetsPaths['wgt-private']] = 'wgt-private';
- this.cacheRealToVirtual[widgetsPaths['wgt-private-tmp']] = 'wgt-private-tmp';
-
var d = this.cacheVirtualToReal;
for (var i in d) {
this.cacheStorages.push({
storage_id: data[i].storage_id
});
}
- this.cacheRealToVirtual[data[i].paths[j]] = j;
}
this.cacheStorages.push({
label: data[i].name,
};
CommonFS.prototype.clearCache = function() {
- this.cacheRealToVirtual = {};
this.cacheVirtualToReal = {};
this.cacheStorages = [];
};
var _location = {location: commonFS_.toRealPath(_parentPath)};
var _result = native_.callSync('File_statSync', _location);
var _statObj = native_.getResultObject(_result);
- var _info = commonFS_.getFileInfo(_parentPath, _statObj, true);
+ var _info = commonFS_.getFileInfo(_statObj, true);
return new File(_info);
} else {
return null;
var aFiles = native_.getResultObject(result);
var _result = [],
i,
- _resolvedPath,
_statObj,
_fileInfo;
for (i = 0; i < aFiles.length; ++i) {
- _resolvedPath = aFiles[i].path;
_statObj = aFiles[i];
- _fileInfo = commonFS_.getFileInfo(_resolvedPath, _statObj);
+ _fileInfo = commonFS_.getFileInfo(_statObj);
if (_fileFilter === null) {
_result.push(new File(_fileInfo));
var _result = native_.callSync('File_statSync', {location: _realNewPath});
_statObj = native_.getResultObject(_result);
- _fileInfo = commonFS_.getFileInfo(_realNewPath, _statObj, false, this.mode);
+ _fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode);
return new File(_fileInfo);
} else {
throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
var _result = native_.callSync('File_statSync', {location: _outputRealPath});
var _statObj = native_.getResultObject(_result);
- var _fileInfo = commonFS_.getFileInfo(_outputPath, _statObj, false, this.mode);
+ var _fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode);
return new File(_fileInfo);
throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(_result));
}
var _statObj = native_.getResultObject(_result);
- var _fileInfo = commonFS_.getFileInfo(_newPath, _statObj, false, this.mode);
+ var _fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode);
return new File(_fileInfo);
};
return;
}
var _statObj = native_.getResultObject(_result);
- var _info = commonFS_.getFileInfo(_myPath, _statObj);
+ var _info = commonFS_.getFileInfo(_statObj);
var _node = new File(_info);
if (!_node.isDirectory) {
}
var aStatObj = native_.getResultObject(result);
-
- var _result;
- var _path = (args.location.indexOf('file://') === 0) ?
- commonFS_.toVirtualPath(args.location) : args.location;
- if (_path[_path.length - 1] === '/') {
- _path = _path.substr(0, _path.length - 1);
- }
- _result = commonFS_.getFileInfo(_path, aStatObj, false, args.mode);
+ var _result = commonFS_.getFileInfo(aStatObj, false, args.mode);
if (_result.readOnly && args.mode !== 'r') {
throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR);
} else {