if ((APP_MANAGER_ERROR_NONE == ret) && (nullptr != tmp_str)) {
app_id = tmp_str;
} else {
- LoggerE("Failed to get application ID: %d (%s)", ret, get_error_message(ret));
+ LoggerE("Failed to get application ID.");
}
free(tmp_str);
if ((PACKAGE_MANAGER_ERROR_NONE == ret) && (nullptr != tmp_str)) {
package_id = tmp_str;
} else {
- LoggerE("Can't get package name from app info: %d (%s)", ret, get_error_message(ret));
+ LoggerE("Failed to get package ID.");
}
free(tmp_str);
app_info_h app_info;
int err = app_info_create(app_id.c_str(), &app_info);
if (APP_MANAGER_ERROR_NONE != err) {
- LoggerE("Can't create app info handle from appId (%s): %d (%s)", app_id.c_str(), err,
- get_error_message(err));
+ LoggerE("Can't create app info handle from appId (%s)", app_id.c_str());
return nullptr;
}
SCOPE_EXIT {
int err = storage_foreach_device_supported(OnStorageDeviceSupported, nullptr);
- if (STORAGE_ERROR_NONE != err) {
- LoggerE("Unknown Error on getting storage paths %d (%s)", err, get_error_message(err));
+ if (err != STORAGE_ERROR_NONE) {
+ LoggerE("Unknown Error on getting storage paths");
}
int id = -1;
LoggerD("enter");
switch (error) {
case FilesystemError::None:
- LoggerE("UnknownException - PLATFORM ERROR");
ReportError(UnknownException("PLATFORM ERROR"), out);
break;
case FilesystemError::NotFound:
- LoggerE("NotFoundException - PLATFORM ERROR");
ReportError(NotFoundException("PLATFORM ERROR"), out);
break;
case FilesystemError::FileExists:
- LoggerE("IOException - File already exists");
ReportError(IOException("File already exists"), out);
break;
case FilesystemError::DirectoryExists:
- LoggerE("IOException - Directory already exists");
ReportError(IOException("Directory already exists"), out);
break;
case FilesystemError::PermissionDenied:
- LoggerE("IOException - Permission denied");
ReportError(IOException("Permission denied"), out);
break;
case FilesystemError::IOError:
- LoggerE("IOException - IO Error");
ReportError(IOException("IO Error"), out);
break;
case FilesystemError::Other:
- LoggerE("UnknownException - PLATFORM ERROR other");
- ReportError(UnknownException("PLATFORM ERROR other"), out);
+ ReportError(UnknownException("PLATFORM ERROR"), out);
break;
case FilesystemError::InvalidValue:
- LoggerE("InvalidValuesException - PLATFORM ERROR");
ReportError(InvalidValuesException("PLATFORM ERROR"), out);
break;
default:
- LoggerE("UnknownException - PLATFORM ERROR default");
- ReportError(UnknownException("PLATFORM ERROR default"), out);
+ ReportError(UnknownException("PLATFORM ERROR"), out);
break;
}
}
namespace FilesystemUtils {
std::string get_storage_dir_path(int id, storage_directory_e typeToCheck) {
LoggerD("Enter");
+ int result = STORAGE_ERROR_NONE;
char* platformPath = NULL;
- int result = storage_get_directory(id, typeToCheck, &platformPath);
- if (STORAGE_ERROR_NONE != result) {
- LoggerE("Cannot retrieve path for type %i: %d (%s)", typeToCheck, result,
- get_error_message(result));
+ result = storage_get_directory(id, typeToCheck, &platformPath);
+ if (result != STORAGE_ERROR_NONE) {
+ LoggerD("Cannot retrieve path for type %i", typeToCheck);
return std::string();
}
std::string path = std::string(platformPath);
}
function f_isSubDir(fullPathToCheck, fullPath) {
- var realFullPath = toRealPath(fullPath);
- return ((-1 !== fullPathToCheck.indexOf(realFullPath)) && (fullPathToCheck !== realFullPath));
+ return (-1 !== fullPathToCheck.indexOf(toRealPath(fullPath)));
};
function f_isCorrectRelativePath(relativePath) {
- return ((0 !== relativePath.indexOf('/')) &&
- (0 !== relativePath.indexOf('\\')) &&
+ return ((-1 === relativePath.indexOf('/')) &&
+ (-1 === relativePath.indexOf('\\')) &&
(-1 === relativePath.indexOf('?')) &&
(-1 === relativePath.indexOf('*')) &&
(-1 === relativePath.indexOf(':')) &&
}
return {
- clearCache: clearCache,
toRealPath: toRealPath,
toVirtualPath: toVirtualPath,
getFileInfo: getFileInfo,
return;
}
+ var lastChar;
+ var addFilenameToPath = false;
+ if (args.destinationFilePath.length) {
+ lastChar = args.destinationFilePath.substr(args.destinationFilePath.length - 1);
+ if (lastChar === '/') {
+ addFilenameToPath = true;
+ }
+ }
+
var _realOriginalPath = commonFS_.toRealPath(args.originFilePath);
var _realDestinationPath = commonFS_.toRealPath(args.destinationFilePath);
}
var _oldNode = native_.getResultObject(resultOldPath);
- var addFileName = false;
- var lastChar = _realDestinationPath.substr(_realDestinationPath.length -1);
-
- var resultNewPath = native_.callSync('File_statSync', {location: _realDestinationPath});
- if (native_.isSuccess(resultNewPath)) {
- var _newNode = native_.getResultObject(resultNewPath);
- if (_newNode.isDirectory) {
- if (lastChar !== '/') {
- _realDestinationPath += '/';
- }
- addFileName = true;
- }
- } else {
- var destinationFileName, destinationDirectoryPath;
- if (lastChar !== '/') {
- destinationFileName = _realDestinationPath.split('/').pop();
- }
- destinationDirectoryPath = _realDestinationPath.substr(0, _realDestinationPath.lastIndexOf('/') + 1);
-
- var resultDestinationDirectory = native_.callSync('File_statSync', {location: destinationDirectoryPath});
- if (native_.isFailure(resultDestinationDirectory)) {
- setTimeout(function() {
- native_.callIfPossible(args.onerror, native_.getErrorObject(resultDestinationDirectory));
- }, 0);
- return;
- }
-
- if (destinationFileName.length == 0) {
- addFileName = true;
- }
- }
-
- if (_oldNode.isFile && addFileName) {
- _realDestinationPath += _realOriginalPath.split('/').pop();
+ if (_oldNode.isFile && addFilenameToPath) {
+ _realDestinationPath = _realDestinationPath + _realOriginalPath.split('/').pop();
}
if (!args.overwrite) {
- var resultPath = native_.callSync('File_statSync', {location: _realDestinationPath});
- if (native_.isSuccess(resultPath)) {
+ var resultNewPath = native_.callSync('File_statSync', {location: _realDestinationPath});
+ if (native_.isSuccess(resultNewPath)) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
new WebAPIException(WebAPIException.IO_ERR, 'Overwrite is not allowed'));
}
var _myPath = commonFS_.toRealPath(args.directoryPath);
-
- if (_myPath !== undefined && !commonFS_.f_isSubDir(_myPath, this.fullPath)) {
- var m1 = 'Deleted directory should be under the current directory: ' + this.fullPath;
- setTimeout(function() {
- native_.callIfPossible(args.onerror,
- new WebAPIException(WebAPIException.INVALID_VALUES_ERR, m1));
- }, 0);
- return;
- }
-
var _result = native_.callSync('File_statSync', {location: _myPath});
if (native_.isFailure(_result)) {
setTimeout(function() {
}
function _StorageStateChangeListener(result) {
- commonFS_.clearCache();
var storage = new FileSystemStorage(result);
for (var id in callbacks) {
native_.callIfPossible(callbacks[id], storage);