[Filesystem] Minor corrections 76/179376/6
authorArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Thu, 17 May 2018 11:24:10 +0000 (13:24 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Thu, 24 May 2018 08:42:30 +0000 (08:42 +0000)
+ Code formatted.

[Verification] TCT passrate 100%

Change-Id: Ia56a19e1089dd1f4a9b0d0d0f7ae33cf75a5f2da
Signed-off-by: Arkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
src/filesystem/filesystem_instance.cc
src/filesystem/filesystem_utils.cc
src/filesystem/js/file_handle.js
src/filesystem/js/file_system_manager.js

index bd11dcdf34a422e8cc38b66fc9c69d6c862dda8d..63abe8204cf1d48cefd76bb59e8609ad5b5f841c 100644 (file)
@@ -596,7 +596,7 @@ bool add_utf8_chars_to_buffer(FILE* file, std::vector<std::uint8_t>& buf, int ch
       continue;
     }
     character = getc(file);
-    if(EOF == character) {
+    if (EOF == character) {
       return false;
     }
     buf.push_back(character);
@@ -1222,7 +1222,6 @@ void FilesystemInstance::FileSystemManagerGetCanonicalPath(const picojson::value
   FilesystemManager::GetInstance().GetCanonicalPath(path, onSuccess, onError);
 }
 
-
 namespace {
 
 FILE* OpenFile(const std::string& path, const std::string& fopen_mode) {
@@ -1243,9 +1242,9 @@ FILE* MakeParentsAndOpenFile(const std::string& path, const std::string& fopen_m
   std::string first_nonexistent_parent = FilesystemUtils::Dirname(path);
   struct ::stat buf;
 
-  while (!FilesystemUtils::CheckIfExists(FilesystemUtils::Dirname(first_nonexistent_parent),
-         &buf)) {
-      first_nonexistent_parent = FilesystemUtils::Dirname(first_nonexistent_parent);
+  while (
+      !FilesystemUtils::CheckIfExists(FilesystemUtils::Dirname(first_nonexistent_parent), &buf)) {
+    first_nonexistent_parent = FilesystemUtils::Dirname(first_nonexistent_parent);
   }
 
   FilesystemUtils::Mkdir(FilesystemUtils::Dirname(path), true);
@@ -1255,7 +1254,8 @@ FILE* MakeParentsAndOpenFile(const std::string& path, const std::string& fopen_m
     return file;
   }
 
-  std::system_error fopen_error = std::system_error(errno, std::generic_category(), "Could not open file");
+  std::system_error fopen_error =
+      std::system_error(errno, std::generic_category(), "Could not open file");
 
   try {
     FilesystemUtils::RemoveDirectoryRecursively(first_nonexistent_parent);
@@ -1266,7 +1266,7 @@ FILE* MakeParentsAndOpenFile(const std::string& path, const std::string& fopen_m
   throw fopen_error;
 }
 
-} //namespace
+}  // namespace
 
 void FilesystemInstance::FileSystemManagerOpenFile(const picojson::value& args,
                                                    picojson::object& out) {
@@ -1297,8 +1297,8 @@ void FilesystemInstance::FileSystemManagerOpenFile(const picojson::value& args,
       file = OpenFile(path, open_mode);
     }
   } catch (const std::system_error& error) {
-      FilesystemUtils::TranslateException(error, out);
-      return;
+    FilesystemUtils::TranslateException(error, out);
+    return;
   }
 
   opened_files.emplace(std::make_pair(unique_id, std::make_shared<FileHandle>(file)));
@@ -1322,7 +1322,7 @@ void FilesystemInstance::FileSystemManagerCreateDirectory(const picojson::value&
 
     try {
       FilesystemUtils::Mkdir(path, make_parents);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(path), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
@@ -1345,14 +1345,21 @@ void FilesystemInstance::FileSystemManagerDeleteFile(const picojson::value& args
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
+      struct stat buf {};
+      if (!FilesystemUtils::CheckIfExists(path, &buf) || !FilesystemUtils::CheckIfFile(buf)) {
+        LogAndReportError(NotFoundException("Given path does not point to file."), obj);
+        return;
+      }
       FilesystemUtils::Unlink(path);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(FilesystemUtils::Dirname(path)), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1374,6 +1381,9 @@ void FilesystemInstance::FileSystemManagerDeleteDirectory(const picojson::value&
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
       struct stat buf {};
@@ -1386,11 +1396,10 @@ void FilesystemInstance::FileSystemManagerDeleteDirectory(const picojson::value&
       } else {
         FilesystemUtils::RemoveDirectory(path);
       }
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(FilesystemUtils::Dirname(path)), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1398,7 +1407,6 @@ void FilesystemInstance::FileSystemManagerDeleteDirectory(const picojson::value&
 
 void FilesystemInstance::FileSystemManagerCopyFile(const picojson::value& args,
                                                    picojson::object& out) {
-  // TODO: currently does not create file with the same name as src if dest is a directory
   ScopeLogger();
   CHECK_PRIVILEGE_ACCESS(kPrivilegeFilesystemWrite, &out);
   CHECK_PRIVILEGE_ACCESS(kPrivilegeFilesystemRead, &out);
@@ -1414,6 +1422,9 @@ void FilesystemInstance::FileSystemManagerCopyFile(const picojson::value& args,
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
       struct stat buf {};
@@ -1422,25 +1433,17 @@ void FilesystemInstance::FileSystemManagerCopyFile(const picojson::value& args,
         return;
       }
       buf = {};
-      if (!FilesystemUtils::CheckIfExists(destination_path, &buf) ||
-          !FilesystemUtils::CheckIfDir(buf)) {
-        LogAndReportError(NotFoundException("Given path does not point to directory."), obj);
-        return;
-      }
-
-      buf = {};
-      std::string new_path = destination_path + '/' + FilesystemUtils::PosixBasename(path);
-      if (!overwrite && FilesystemUtils::CheckIfExists(new_path, &buf)) {
-        LogAndReportError(IOException("File or directory with conflicting name already exists."),
-                          obj);
+      if (FilesystemUtils::CheckIfExists(destination_path, &buf) && !overwrite) {
+        LogAndReportError(
+            IOException("Given path points to an existing resource, overwriting is not allowed."),
+            obj);
         return;
       }
       FilesystemUtils::CopyFile(path, destination_path, overwrite);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(destination_path), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1463,6 +1466,9 @@ void FilesystemInstance::FileSystemManagerCopyDirectory(const picojson::value& a
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
       struct stat buf {};
@@ -1471,23 +1477,18 @@ void FilesystemInstance::FileSystemManagerCopyDirectory(const picojson::value& a
         return;
       }
       buf = {};
-      if (!FilesystemUtils::CheckIfExists(destination_path, &buf) ||
-          !FilesystemUtils::CheckIfDir(buf)) {
-        LogAndReportError(NotFoundException("Given path does not point to directory."), obj);
-        return;
-      }
-      std::string new_path = destination_path + '/' + FilesystemUtils::PosixBasename(path);
-      buf = {};
-      if (FilesystemUtils::CheckIfExists(new_path, &buf) && !FilesystemUtils::CheckIfDir(buf)) {
+      bool exists = FilesystemUtils::CheckIfExists(destination_path, &buf);
+      if (exists && !FilesystemUtils::CheckIfDir(buf)) {
         LogAndReportError(IOException("File with conflicting name already exists."), obj);
         return;
+      } else if (!exists) {
+        FilesystemUtils::Mkdir(destination_path);
       }
       FilesystemUtils::CopyDirectory(path, destination_path, overwrite);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(destination_path), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1511,6 +1512,9 @@ void FilesystemInstance::FileSystemManagerMoveFile(const picojson::value& args,
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
       struct stat buf {};
@@ -1533,11 +1537,10 @@ void FilesystemInstance::FileSystemManagerMoveFile(const picojson::value& args,
         return;
       }
       FilesystemUtils::MoveFile(path, new_path, overwrite);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(new_path), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1560,6 +1563,9 @@ void FilesystemInstance::FileSystemManagerMoveDirectory(const picojson::value& a
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
       struct stat buf {};
@@ -1576,15 +1582,15 @@ void FilesystemInstance::FileSystemManagerMoveDirectory(const picojson::value& a
       buf = {};
       std::string new_path = destination_path + '/' + FilesystemUtils::PosixBasename(path);
       if (FilesystemUtils::CheckIfExists(new_path, &buf) && !FilesystemUtils::CheckIfDir(buf)) {
-        LogAndReportError(IOException("File or directory with conflicting name already exists."), obj);
+        LogAndReportError(IOException("File or directory with conflicting name already exists."),
+                          obj);
         return;
       }
       FilesystemUtils::MoveDirectory(path, destination_path, overwrite);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(new_path), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1605,6 +1611,9 @@ void FilesystemInstance::FileSystemManagerRename(const picojson::value& args,
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
+    SCOPE_EXIT {
+      this->PostMessage(response.serialize().c_str());
+    };
 
     try {
       struct stat buf {};
@@ -1623,11 +1632,10 @@ void FilesystemInstance::FileSystemManagerRename(const picojson::value& args,
         return;
       }
       FilesystemUtils::Rename(path, new_path);
-      ReportSuccess(obj);
+      ReportSuccess(picojson::value(new_path), obj);
     } catch (const std::system_error& e) {
       FilesystemUtils::TranslateException(e, obj);
     }
-    this->PostMessage(response.serialize().c_str());
   });
 
   ReportSuccess(out);
@@ -1945,7 +1953,8 @@ void FilesystemInstance::FileHandleReadString(const picojson::value& args, picoj
         if (!(std::feof(
                 handle->file_handle))) {  // read number of characters if not whole file read
           LoggerD("count parameter given: %d", count);
-          if (!whole_file && !add_utf8_chars_to_buffer(handle->file_handle, buf, count - char_count,
+          if (!whole_file &&
+              !add_utf8_chars_to_buffer(handle->file_handle, buf, count - char_count,
                                         expected_extension_bytes)) {
             LogAndReportError(
                 IOException("File doesn't contain UTF-8 encoded string with given length"), out);
@@ -2179,8 +2188,7 @@ void FilesystemInstance::FileHandleFlush(const picojson::value& args, picojson::
       int ret = fflush(handle->file_handle);
       if (ret) {
         int errsv = errno;
-        std::string error_message =
-            std::string("flush failed, error message: ") + strerror(errsv);
+        std::string error_message = std::string("flush failed, error message: ") + strerror(errsv);
         LogAndReportError(IOException(error_message.c_str()), out);
         return;
       }
@@ -2229,8 +2237,7 @@ void FilesystemInstance::FileHandleSync(const picojson::value& args, picojson::o
       int ret = fsync(fileno(handle->file_handle));
       if (ret) {
         int errsv = errno;
-        std::string error_message =
-            std::string("sync failed, error message: ") + strerror(errsv);
+        std::string error_message = std::string("sync failed, error message: ") + strerror(errsv);
         LogAndReportError(IOException(error_message.c_str()), out);
         return;
       }
@@ -2284,8 +2291,7 @@ void FilesystemInstance::FileHandleClose(const picojson::value& args, picojson::
       handle->file_handle = nullptr;
       if (ret) {
         int errsv = errno;
-        std::string error_message =
-            std::string("close failed, error message: ") + strerror(errsv);
+        std::string error_message = std::string("close failed, error message: ") + strerror(errsv);
         LogAndReportError(IOException(error_message.c_str()), out);
         return;
       }
index 3ae857471f91c94c7de07ed1598b766e7083413c..3ab4dd39f6e14342920872bace674229739325d5 100644 (file)
@@ -117,8 +117,9 @@ std::string Dirname(const std::string& path) {
   return dir;
 }
 
-void CopyFile(const std::string& src, const std::string& dest, bool overwrite) {
-  ScopeLogger("From: %s; To %s", src.c_str(), dest.c_str());
+void CopyFileOverExistingDirectory(const std::string& src, const std::string& dest,
+                                   bool overwrite) {
+  ScopeLogger("From: %s, To %s", src.c_str(), dest.c_str());
   struct stat buf {};
   if (CheckIfExists(dest, &buf) && CheckIfDir(buf)) {
     if (overwrite) {
@@ -128,6 +129,11 @@ void CopyFile(const std::string& src, const std::string& dest, bool overwrite) {
                               "Failed to copy file: overwrite is not allowed."};
     }
   }
+  CopyFile(src, dest, overwrite);
+}
+
+void CopyFile(const std::string& src, const std::string& dest, bool overwrite) {
+  ScopeLogger("From: %s; To %s", src.c_str(), dest.c_str());
 
   GError* error = nullptr;
   auto source_ptr = std::unique_ptr<GFile, decltype(&g_object_unref)>(
@@ -153,27 +159,27 @@ void CopyFile(const std::string& src, const std::string& dest, bool overwrite) {
 }
 
 void CopyDirectory(const std::string& src, const std::string& dest, bool overwrite) {
-  ScopeLogger("From: %s; To %s", src.c_str(), dest.c_str());
-  std::string dest_dir = dest + '/' + PosixBasename(src);
-  struct stat buf {};
-  bool exists = CheckIfExists(dest_dir, &buf);
-  if (exists && !CheckIfDir(buf)) {
-    if (overwrite) {
-      Unlink(dest_dir);
-      Mkdir(dest_dir);
-    } else {
-      throw std::system_error{EIO, std::generic_category(),
-                              "Failed to copy directory: overwrite is not allowed."};
-    }
-  } else if (!exists) {
-    Mkdir(dest_dir);
-  }
-
+  ScopeLogger("From: %s, To %s", src.c_str(), dest.c_str());
   ListDirectory(src, [&](const char* name, unsigned char type) {
     if (DT_DIR == type) {
+      std::string dest_dir = dest + '/' + name;
+      struct stat buf {};
+      bool exists = CheckIfExists(dest_dir, &buf);
+      if (exists && !CheckIfDir(buf)) {
+        if (overwrite) {
+          Unlink(dest_dir);
+          Mkdir(dest_dir);
+        } else {
+          throw std::system_error{EIO, std::generic_category(),
+                                  "Failed to copy directory: overwriting is not allowed."};
+        }
+      } else if (!exists) {
+        Mkdir(dest_dir);
+      }
+
       CopyDirectory(src + '/' + name, dest_dir, overwrite);
     } else {  // copying of regular files as well as other types of items pointed by src
-      CopyFile(src + '/' + name, dest_dir + '/' + name, overwrite);
+      CopyFileOverExistingDirectory(src + '/' + name, dest + '/' + name, overwrite);
     }
     // Set errno to 0 to prevent from reporting readdir error after successful iterating through
     // directory.
@@ -189,7 +195,7 @@ void ListDirectory(const std::string& path, std::function<void(const char*, unsi
                             "Failed to open directory: "s + std::strerror(errno)};
   }
 
-  std::unique_ptr<DIR, void (*)(DIR*)> dir_ptr(d, [](DIR * d) {
+  std::unique_ptr<DIR, void (*)(DIR*)> dir_ptr(d, [](DIR* d) {
     if (::closedir(d)) {
       LoggerW("closedir failed");
     }
@@ -210,7 +216,7 @@ void ListDirectory(const std::string& path, std::function<void(const char*, unsi
 }
 
 void RemoveDirectoryRecursively(const std::string& path) {
-  ScopeLogger("%s", path);
+  ScopeLogger("%s", path.c_str());
   auto res =
       nftw(path.c_str(),
            [](const char* fpath, const struct stat* sb, int typeflag, struct FTW* ftwbuf) -> int {
index 50e35b01a2bf2d219295fd22319fa64b88f4c372..e3602597e82fc867940c4b411957e8a9d2d09693 100644 (file)
@@ -97,11 +97,7 @@ FileHandle.prototype.readString = function() {
   if ((this.mode === 'w') || (this.mode === 'a')) {
     throw new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is write-only');
   }
-  var data = {
-    id: this.id,
-    count: args.count,
-    inputEncoding: args.inputEncoding
-  };
+  var data = {id: this.id, count: args.count, inputEncoding: args.inputEncoding};
   var result = native_.callSync('FileHandle_readString', data);
 
   if (native_.isFailure(result)) {
@@ -123,7 +119,8 @@ FileHandle.prototype.readStringNonBlocking = function() {
   if ((this.mode === 'w') || (this.mode === 'a')) {
     throw new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is write-only');
   }
-  var data = {id: this.id, size: args.size, inputEncoding: args.inputEncoding, blocking: false};
+  var data =
+      {id: this.id, size: args.size, inputEncoding: args.inputEncoding, blocking: false};
 
   var callback = function(result) {
     if (native_.isFailure(result)) {
@@ -173,7 +170,12 @@ FileHandle.prototype.writeStringNonBlocking = function() {
   if ('r' === this.mode) {
     throw new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only');
   }
-  var data = {id: this.id, string: args.string, outputEncoding: args.outputEncoding, blocking: false};
+  var data = {
+    id: this.id,
+    string: args.string,
+    outputEncoding: args.outputEncoding,
+    blocking: false
+  };
 
   var callback = function(result) {
     if (native_.isFailure(result)) {
@@ -260,7 +262,7 @@ FileHandle.prototype.writeBlob = function() {
     throw new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only');
   }
 
-  var encodedData = ArrayToString(new Uint8Array(blobToUint8Array(args.blob)));
+  var encodedData = ArrayToString(blobToUint8Array(args.blob));
   var data = {id: this.id, data: encodedData};
   var result = native_.callSync('FileHandle_writeData', data);
   if (native_.isFailure(result)) {
@@ -280,7 +282,7 @@ FileHandle.prototype.writeBlobNonBlocking = function() {
     throw new WebAPIException(WebAPIException.IO_ERR, 'FileHandle state is read-only');
   }
 
-  var encodedData = ArrayToString(new Uint8Array(blobToUint8Array(args.blob)));
+  var encodedData = ArrayToString(blobToUint8Array(args.blob));
   var data = {id: this.id, data: encodedData, blocking: false};
   var callback = function(result) {
     if (native_.isFailure(result)) {
index b40df95b1a34f16554b45ea0c6a578712e19c1a3..59fce182ef70460abc71d72e5b3a2739e6083e6f 100644 (file)
@@ -88,14 +88,15 @@ FileSystemManager.prototype.createDirectory = function() {
 
   if (!data.path) {
     throw new WebAPIException(
-        WebAPIException.NOT_FOUND_ERR, 'Invalid path: ' + args.path);
+        WebAPIException.INVALID_VALUES_ERR, 'Invalid path: ' + args.path);
   }
 
   var callback = function(result) {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -116,14 +117,15 @@ FileSystemManager.prototype.deleteFile = function() {
 
   if (!data.path) {
     throw new WebAPIException(
-        WebAPIException.NOT_FOUND_ERR, 'Invalid path: ' + args.path);
+        WebAPIException.INVALID_VALUES_ERR, 'Invalid path: ' + args.path);
   }
 
   var callback = function(result) {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -156,7 +158,8 @@ FileSystemManager.prototype.deleteDirectory = function() {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -197,7 +200,8 @@ FileSystemManager.prototype.copyFile = function() {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -209,8 +213,7 @@ FileSystemManager.prototype.copyFile = function() {
 
 FileSystemManager.prototype.copyDirectory = function() {
   var args = validator_.validateArgs(arguments, [
-    {name: 'path', type: types_.STRING},
-    {name: 'destinationPath', type: types_.STRING},
+    {name: 'path', type: types_.STRING}, {name: 'destinationPath', type: types_.STRING},
     {name: 'overwrite', type: types_.BOOLEAN, optional: true},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
@@ -236,7 +239,8 @@ FileSystemManager.prototype.copyDirectory = function() {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -248,8 +252,7 @@ FileSystemManager.prototype.copyDirectory = function() {
 
 FileSystemManager.prototype.moveFile = function() {
   var args = validator_.validateArgs(arguments, [
-    {name: 'path', type: types_.STRING},
-    {name: 'destinationPath', type: types_.STRING},
+    {name: 'path', type: types_.STRING}, {name: 'destinationPath', type: types_.STRING},
     {name: 'overwrite', type: types_.BOOLEAN, optional: true},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
@@ -275,7 +278,8 @@ FileSystemManager.prototype.moveFile = function() {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -287,8 +291,7 @@ FileSystemManager.prototype.moveFile = function() {
 
 FileSystemManager.prototype.moveDirectory = function() {
   var args = validator_.validateArgs(arguments, [
-    {name: 'path', type: types_.STRING},
-    {name: 'destinationPath', type: types_.STRING},
+    {name: 'path', type: types_.STRING}, {name: 'destinationPath', type: types_.STRING},
     {name: 'overwrite', type: types_.BOOLEAN, optional: true},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
@@ -314,7 +317,8 @@ FileSystemManager.prototype.moveDirectory = function() {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -326,8 +330,7 @@ FileSystemManager.prototype.moveDirectory = function() {
 
 FileSystemManager.prototype.rename = function() {
   var args = validator_.validateArgs(arguments, [
-    {name: 'path', type: types_.STRING},
-    {name: 'newName', type: types_.STRING},
+    {name: 'path', type: types_.STRING}, {name: 'newName', type: types_.STRING},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
   ]);
@@ -348,7 +351,8 @@ FileSystemManager.prototype.rename = function() {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
     } else {
-      native_.callIfPossible(args.successCallback);
+      var path = native_.getResultObject(result);
+      native_.callIfPossible(args.successCallback, commonFS_.toVirtualPath(path));
     }
   };
 
@@ -442,7 +446,6 @@ FileSystemManager.prototype.toURI = function() {
 
 FileSystemManager.prototype.isFile = function() {
   var args = validator_.validateArgs(arguments, [{name: 'path', type: types_.STRING}]);
-
   // The toRealPath function will convert any string to absolute path, if possible.
   // The function returns undefined for path, which starts with not-existing virtual root.
   var realPath = commonFS_.toRealPath(args.path);
@@ -463,7 +466,6 @@ FileSystemManager.prototype.isFile = function() {
 
 FileSystemManager.prototype.isDirectory = function() {
   var args = validator_.validateArgs(arguments, [{name: 'path', type: types_.STRING}]);
-
   // The toRealPath function will convert any string to absolute path, if possible.
   // The function returns undefined for path, which starts with not-existing virtual root.
   var realPath = commonFS_.toRealPath(args.path);
@@ -484,7 +486,6 @@ FileSystemManager.prototype.isDirectory = function() {
 
 FileSystemManager.prototype.pathExists = function() {
   var args = validator_.validateArgs(arguments, [{name: 'path', type: types_.STRING}]);
-
   // The toRealPath function will convert any string to absolute path, if possible.
   // The function returns undefined for path, which starts with not-existing virtual root.
   var realPath = commonFS_.toRealPath(args.path);
@@ -540,7 +541,9 @@ function resolve() {
   if (!args.has.mode) {
     args.mode = 'rw';
   } else if ('rwo' == args.mode) {
-    throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'rwo mode was introduced in version 5.0 and is not supported in earlier version methods');
+    throw new WebAPIException(
+        WebAPIException.INVALID_VALUES_ERR,
+        'rwo mode was introduced in version 5.0 and is not supported in earlier version methods');
   }
 
   // resolving a path on unmounted storage should result in exception