Bug 956646 - Add renameTo to nsIFile interface. r=bsmedberg
authorYuan Xulei <xyuan@mozilla.com>
Mon, 06 Jan 2014 16:51:39 +0800
changeset 186609 c5448956922605fe0111f4c6c40cd919fe295472
parent 186608 9b7c28e40c1cbb50b5621cba7a62a4b53a250d53
child 186610 587d8a9a277305a3643035f4836c895e171c6197
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs956646
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 956646 - Add renameTo to nsIFile interface. r=bsmedberg
netwerk/ipc/RemoteOpenFileChild.cpp
xpcom/io/nsIFile.idl
xpcom/io/nsLocalFileUnix.cpp
xpcom/io/nsLocalFileWin.cpp
--- a/netwerk/ipc/RemoteOpenFileChild.cpp
+++ b/netwerk/ipc/RemoteOpenFileChild.cpp
@@ -553,16 +553,22 @@ RemoteOpenFileChild::MoveTo(nsIFile *new
 
 NS_IMETHODIMP
 RemoteOpenFileChild::MoveToNative(nsIFile *newParent, const nsACString &newName)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
+RemoteOpenFileChild::RenameTo(nsIFile *newParentDir, const nsAString &newName)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 RemoteOpenFileChild::Remove(bool recursive)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 RemoteOpenFileChild::GetPermissions(uint32_t *aPermissions)
 {
--- a/xpcom/io/nsIFile.idl
+++ b/xpcom/io/nsIFile.idl
@@ -37,17 +37,17 @@ interface nsISimpleEnumerator;
  * All methods with string parameters have two forms.  The preferred
  * form operates on UCS-2 encoded characters strings.  An alternate
  * form operates on characters strings encoded in the "native" charset.
  *
  * A string containing characters encoded in the native charset cannot
  * be safely passed to javascript via xpconnect.  Therefore, the "native
  * methods" are not scriptable.
  */
-[scriptable, uuid(272a5020-64f5-485c-a8c4-44b2882ae0a2), builtinclass]
+[scriptable, uuid(a99a6a06-f90d-4659-8fce-c2f87feb1167), builtinclass]
 interface nsIFile : nsISupports
 {
     /**
      *  Create Types
      *
      *  NORMAL_FILE_TYPE - A normal file.
      *  DIRECTORY_TYPE   - A directory/folder.
      */
@@ -176,16 +176,26 @@ interface nsIFile : nsISupports
      *       This param allows you to specify a new name for
      *       the file to be moved. This param may be empty, in
      *       which case the current leaf name will be used.
      */
     void moveTo(in nsIFile newParentDir, in AString newName);
     [noscript] void moveToNative(in nsIFile newParentDir, in ACString newName);
 
     /**
+     *  renameTo
+     *
+     *  This method is identical to moveTo except that if this file or directory
+     *  is moved to a a different volume, it fails and returns an error
+     *  (NS_ERROR_FILE_ACCESS_DENIED).
+     *  This object will still point to the old location after renaming.
+     */
+    void renameTo(in nsIFile newParentDir, in AString newName);
+
+    /**
      *  This will try to delete this file.  The 'recursive' flag
      *  must be PR_TRUE to delete directories which are not empty.
      *
      *  This will not resolve any symlinks.
      */
     void remove(in boolean recursive);
 
     /**
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -1995,16 +1995,23 @@ nsLocalFile::CopyToFollowingLinks(nsIFil
 {
     SET_UCS_2ARGS_2(CopyToFollowingLinksNative , newParentDir, newName);
 }
 nsresult  
 nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
 {
     SET_UCS_2ARGS_2(MoveToNative, newParentDir, newName);
 }
+
+NS_IMETHODIMP
+nsLocalFile::RenameTo(nsIFile *newParentDir, const nsAString &newName)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 nsresult
 nsLocalFile::GetTarget(nsAString &_retval)
 {   
     GET_UCS(GetNativeTarget, _retval);
 }
 
 // nsIHashable
 
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -2145,16 +2145,21 @@ nsLocalFile::CopyToFollowingLinks(nsIFil
 }
 
 NS_IMETHODIMP
 nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
 {
     return CopyMove(newParentDir, newName, false, true);
 }
 
+NS_IMETHODIMP
+nsLocalFile::RenameTo(nsIFile *newParentDir, const nsAString & newName)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
 
 NS_IMETHODIMP
 nsLocalFile::Load(PRLibrary * *_retval)
 {
     // Check we are correctly initialized.
     CHECK_mWorkingPath();
 
     bool isFile;