a: 'a'
};
+var tizen24home = "/opt/usr/media";
+
+//this variable need to match same variable in common/filesystem/filesystem_provider_storage.cc
+var kVirtualRootImages = "images";
+
var commonFS_ = (function() {
var cacheReady = false;
var listenerRegistered = false;
var cacheVirtualToReal = {};
var cacheStorages = [];
var uriPrefix = 'file://';
+ // special condition for previous versions paths
+ // (global paths usage issue workaround)
+ var isAppForEarlierVersion = privUtils_.isAppVersionEarlierThan("3.0");
+ var homeDir = undefined;
function clearCache() {
cacheVirtualToReal = {};
cacheReady = false;
}
+ // initalize home directory for correct mapping global paths from tizen 2.4
+ // (global paths usage issue workaround)
+ function initHomeDir(aPath) {
+ if (homeDir || !isAppForEarlierVersion) {
+ return;
+ }
+ var imagesPath = cacheVirtualToReal[kVirtualRootImages].path;
+
+ if (imagesPath[imagesPath.length-1] === "/") {
+ homeDir = imagesPath.split("/").slice(0, -2).join("/");
+ } else {
+ homeDir = imagesPath.split("/").slice(0, -1).join("/");
+ }
+ }
+
function initCache() {
if (cacheReady) {
return;
state: FileSystemStorageState.MOUNTED
};
}
+ // initalize home directory for correct mapping global paths from tizen 2.4
+ // (global paths usage issue workaround)
+ initHomeDir();
var result = native_.callSync('FileSystemManager_fetchStorages', {});
if (native_.isFailure(result)) {
return true;
}
+ function convertForEarlierVersionPath(aPath) {
+ if (isAppForEarlierVersion) {
+ if (aPath && aPath.indexOf(tizen24home) === 0) {
+ console.log("Converting 2.4 style path to 3.0 pattern");
+ aPath = homeDir + aPath.substr(tizen24home.length);
+ }
+ }
+ return aPath;
+ }
+
function toRealPath(aPath) {
var _fileRealPath = '';
// this line makes that '.' and '..' is supported in paths, but each method handle those cases
// and return error (see commonFS_.checkPathWithoutDots() method)
_fileRealPath = removeDotsFromPath(_fileRealPath);
+ // convert path to be compatibile with previous version of Tizen
+ // (global paths usage issue workaround)
+ _fileRealPath = convertForEarlierVersionPath(_fileRealPath);
+ // 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;
}
}
};
-Utils.prototype.checkPrivilegeAccess4Ver = function(new_ver, new_priv, old_priv) {
+Utils.prototype.isAppVersionEarlierThan= function(ver) {
var app_ver = this.getPkgApiVersion();
- var arr_new_ver = new_ver.split(".");
- var arr_app_ver = app_ver.split(".");
- var num_new;
+ var arr_ver = ver.split("."); // reference version
+ var arr_app_ver = app_ver.split("."); // application version
+ var num_ver;
var num_app;
- var sel = 0;
var i;
- var length = Math.min(arr_new_ver.length, arr_app_ver.length);
+ var length = Math.min(arr_ver.length, arr_app_ver.length);
for (i = 0; i < length; i++) {
- num_new = parseInt(arr_new_ver[i]);
+ num_ver = parseInt(arr_ver[i]);
num_app = parseInt(arr_app_ver[i]);
- if (num_app < num_new) {
- sel = 1;
- break;
- } else if (num_app > num_new) {
- sel = -1;
- break;
+ if (num_app < num_ver) {
+ return true;
+ } else if (num_app > num_ver) {
+ return false;
}
}
- if (sel == 0 && arr_new_ver.length > arr_app_ver.length) {
- sel = 1;
+ if (arr_ver.length > arr_app_ver.length) {
+ return true;
}
+ return false;
+}
- if (sel != 1) {
+Utils.prototype.checkPrivilegeAccess4Ver = function(new_ver, new_priv, old_priv) {
+ if (this.isAppVersionEarlierThan(new_ver)) {
this.checkPrivilegeAccess(new_priv);
} else if (old_priv != undefined) {
this.checkPrivilegeAccess(old_priv);