void FilesystemInstance::CopyTo(const picojson::value& args,
picojson::object& out) {
LoggerD("enter");
+ CHECK_EXIST(args, "callbackId", out)
+ CHECK_EXIST(args, "originFilePath", out)
+ CHECK_EXIST(args, "destinationFilePath", out)
+ CHECK_EXIST(args, "overwrite", out)
+
double callback_id = args.get("callbackId").get<double>();
const std::string& originPath = args.get("originFilePath").get<std::string>();
const std::string& destinationPath = args.get("destinationFilePath").get<std::string>();
var _realOriginalPath = commonFS_.toRealPath(args.originFilePath);
var _realDestinationPath = commonFS_.toRealPath(args.destinationFilePath);
+ if (!_realOriginalPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ 'Source path is not valid'));
+ }, 0);
+ return;
+ }
+
+ if (!_realDestinationPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ 'Destination path is not valid'));
+ }, 0);
+ return;
+ }
+
var resultOldPath = native_.callSync('File_statSync', {location: _realOriginalPath});
if (native_.isFailure(resultOldPath)) {
setTimeout(function() {
var _realOriginalPath = commonFS_.toRealPath(args.originFilePath);
var _realDestinationPath = commonFS_.toRealPath(args.destinationFilePath);
+ if (!_realOriginalPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ 'Source path is not valid'));
+ }, 0);
+ return;
+ }
+
+ if (!_realDestinationPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ 'Destination path is not valid'));
+ }, 0);
+ return;
+ }
+
var resultOldPath = native_.callSync('File_statSync', {location: _realOriginalPath});
if (native_.isFailure(resultOldPath)) {
setTimeout(function() {
_fileInfo,
_realNewPath = commonFS_.toRealPath(_newPath);
+ if (!_realNewPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ 'Path is not valid'));
+ }, 0);
+ return;
+ }
+
if (this.isDirectory) {
if (this.mode === 'r') {
throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
var _outputPath = this.fullPath + '/' + args.relativeFilePath;
var _outputRealPath = commonFS_.toRealPath(_outputPath);
+ if (!_outputRealPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ 'Path is not valid'));
+ }, 0);
+ return;
+ }
var _resultExist = native_.callSync('File_statSync', {location: _outputRealPath});
if (native_.isSuccess(_resultExist)) {
var _newPath = this.fullPath + '/' + args.filePath;
var _realPath = commonFS_.toRealPath(_newPath);
+ if (!_realPath) {
+ setTimeout(function() {
+ native_.callIfPossible(args.onerror,
+ new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ 'Path is not valid'));
+ }, 0);
+ return;
+ }
var _result = native_.callSync('File_statSync', {location: _realPath});
if (native_.isFailure(_result)) {
throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(_result));