Bug 956646 - Add renameTo to nsIFile interface. r=bsmedberg

This commit is contained in:
Yuan Xulei 2014-01-06 16:51:39 +08:00
parent 1450a0f93a
commit 41a99188eb
4 changed files with 29 additions and 1 deletions

View File

@ -557,6 +557,12 @@ 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)
{

View File

@ -42,7 +42,7 @@ interface nsISimpleEnumerator;
* 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
{
/**
@ -180,6 +180,16 @@ interface nsIFile : nsISupports
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.

View File

@ -2000,6 +2000,13 @@ 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)
{

View File

@ -2150,6 +2150,11 @@ 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)