зеркало из https://github.com/mozilla/pjs.git
Changing nsFileSpec Copy and Move function names to match their
functionality, and also to free up the namespace for a *real* Copy and Move that allow renaming the leaf name rather than just copying into different directories (i.e. to make backup files). r=ssu
This commit is contained in:
Родитель
93a539cce9
Коммит
4b0ca9d0cd
|
@ -1183,7 +1183,7 @@ nsPrefMigration::DoTheCopyAndRename(nsIFileSpec * oldPathSpec, nsIFileSpec *newP
|
|||
}
|
||||
else {
|
||||
// copy the file
|
||||
fileOrDirName.Copy(newPath);
|
||||
fileOrDirName.CopyToDir(newPath);
|
||||
|
||||
if (needToRenameFiles) {
|
||||
// rename the file, if it matches
|
||||
|
@ -1294,7 +1294,7 @@ nsPrefMigration::RenameAndMove4xPopFilterFile(nsIFileSpec * profilePath)
|
|||
PR_FREEIF(popServerName);
|
||||
|
||||
// copy the 4.x file from <profile>/mailrule to the <profile>/Mail/<hostname>/mailrule
|
||||
file.Copy(migratedPopDirectory);
|
||||
file.CopyToDir(migratedPopDirectory);
|
||||
|
||||
// make migratedPopDirectory point the the copied filter file,
|
||||
// <profile>/Mail/<hostname>/mailrule
|
||||
|
@ -1334,7 +1334,7 @@ nsPrefMigration::RenameAndMove4xImapFilterFile(nsIFileSpec * profilePath, const
|
|||
migratedImapDirectory += hostname;
|
||||
|
||||
// copy the 4.x file from "<profile>/<hostname> Rules" to <profile>/ImapMail/<hostname>/
|
||||
file.Copy(migratedImapDirectory);
|
||||
file.CopyToDir(migratedImapDirectory);
|
||||
|
||||
// make migratedPopDirectory point the the copied filter file,
|
||||
// "<profile>/ImapMail/<hostname>/<hostname> Rules"
|
||||
|
|
|
@ -510,8 +510,8 @@ class NS_COM nsFileSpec
|
|||
const nsAutoCString newName(inNewName);
|
||||
return Rename(newName);
|
||||
}
|
||||
nsresult Copy(const nsFileSpec& inNewParentDirectory) const;
|
||||
nsresult Move(const nsFileSpec& inNewParentDirectory);
|
||||
nsresult CopyToDir(const nsFileSpec& inNewParentDirectory) const;
|
||||
nsresult MoveToDir(const nsFileSpec& inNewParentDirectory);
|
||||
nsresult Execute(const char* args) const;
|
||||
nsresult Execute(const nsString& args) const
|
||||
{
|
||||
|
|
|
@ -278,7 +278,7 @@ void nsFileSpec::RecursiveCopy(nsFileSpec newDir) const
|
|||
newDir.CreateDirectory();
|
||||
}
|
||||
|
||||
filePath.Copy(newDir);
|
||||
filePath.CopyToDir(newDir);
|
||||
}
|
||||
} // nsFileSpec::RecursiveCopy
|
||||
|
||||
|
@ -359,7 +359,7 @@ static int CrudeFileCopy(const char* in, const char* out)
|
|||
} // nsFileSpec::Rename
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
||||
nsresult nsFileSpec::CopyToDir(const nsFileSpec& inParentDirectory) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
@ -375,10 +375,10 @@ nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
|||
result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath));
|
||||
}
|
||||
return result;
|
||||
} // nsFileSpec::Copy
|
||||
} // nsFileSpec::CopyToDir
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Move(const nsFileSpec& inNewParentDirectory)
|
||||
nsresult nsFileSpec::MoveToDir(const nsFileSpec& inNewParentDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
|
|
@ -391,14 +391,14 @@ NS_IMETHODIMP nsFileSpecImpl::Rename(const char *newLeafName)
|
|||
NS_IMETHODIMP nsFileSpecImpl::CopyToDir(const nsIFileSpec *newParentDir)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mFileSpec.Copy(FILESPEC(newParentDir));
|
||||
return mFileSpec.CopyToDir(FILESPEC(newParentDir));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsFileSpecImpl::MoveToDir(const nsIFileSpec *newParentDir)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mFileSpec.Move(FILESPEC(newParentDir));
|
||||
return mFileSpec.MoveToDir(FILESPEC(newParentDir));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1023,7 +1023,7 @@ void nsFileSpec::RecursiveCopy(nsFileSpec newDir) const
|
|||
newDir.CreateDirectory();
|
||||
}
|
||||
|
||||
filePath.Copy(newDir);
|
||||
filePath.CopyToDir(newDir);
|
||||
}
|
||||
} // nsFileSpec::RecursiveCopy
|
||||
|
||||
|
@ -1046,7 +1046,7 @@ nsresult nsFileSpec::Rename(const char* inNewName)
|
|||
} // nsFileSpec::Rename
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Copy(const nsFileSpec& newParentDir) const
|
||||
nsresult nsFileSpec::CopyToDir(const nsFileSpec& newParentDir) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
@ -1063,10 +1063,10 @@ nsresult nsFileSpec::Copy(const nsFileSpec& newParentDir) const
|
|||
|
||||
return rv;
|
||||
|
||||
} // nsFileSpec::Copy
|
||||
} // nsFileSpec::CopyToDir
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Move(const nsFileSpec& newParentDir)
|
||||
nsresult nsFileSpec::MoveToDir(const nsFileSpec& newParentDir)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only move into a directory
|
||||
|
@ -1085,7 +1085,7 @@ nsresult nsFileSpec::Move(const nsFileSpec& newParentDir)
|
|||
nsCRT::free(leafName);
|
||||
}
|
||||
return result;
|
||||
} // nsFileSpec::Move
|
||||
} // nsFileSpec::MoveToDir
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Execute(const char* /*args - how can this be cross-platform? problem! */ ) const
|
||||
|
|
|
@ -353,7 +353,7 @@ nsresult nsFileSpec::Rename( const char *inNewName)
|
|||
return rc;
|
||||
}
|
||||
|
||||
nsresult nsFileSpec::Copy( const nsFileSpec &inParentDirectory) const
|
||||
nsresult nsFileSpec::CopyToDir( const nsFileSpec &inParentDirectory) const
|
||||
{
|
||||
// Copy the file this filespec represents into the given directory.
|
||||
nsresult rc = NS_FILE_FAILURE;
|
||||
|
@ -381,10 +381,10 @@ nsresult nsFileSpec::Copy( const nsFileSpec &inParentDirectory) const
|
|||
}
|
||||
|
||||
// XXX not sure about the semantics of this method...
|
||||
nsresult nsFileSpec::Move( const nsFileSpec &aParentDirectory)
|
||||
nsresult nsFileSpec::MoveToDir( const nsFileSpec &aParentDirectory)
|
||||
{
|
||||
// Copy first & then delete self to avoid drive-clashes
|
||||
nsresult rc = Copy( aParentDirectory);
|
||||
nsresult rc = CopyToDir( aParentDirectory);
|
||||
if( NS_SUCCEEDED(rc))
|
||||
{
|
||||
Delete( PR_FALSE); // XXX why no return code ?
|
||||
|
|
|
@ -332,7 +332,7 @@ void nsFileSpec::RecursiveCopy(nsFileSpec newDir) const
|
|||
newDir.CreateDirectory();
|
||||
}
|
||||
|
||||
filePath.Copy(newDir);
|
||||
filePath.CopyToDir(newDir);
|
||||
}
|
||||
} // nsFileSpec::RecursiveCopy
|
||||
|
||||
|
@ -416,7 +416,7 @@ static int CrudeFileCopy(const char* in, const char* out)
|
|||
} // nsFileSpec::Rename
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
||||
nsresult nsFileSpec::CopyToDir(const nsFileSpec& inParentDirectory) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
@ -432,10 +432,10 @@ nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
|||
result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath));
|
||||
}
|
||||
return result;
|
||||
} // nsFileSpec::Copy
|
||||
} // nsFileSpec::CopyToDir
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Move(const nsFileSpec& inNewParentDirectory)
|
||||
nsresult nsFileSpec::MoveToDir(const nsFileSpec& inNewParentDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
|
|
@ -463,7 +463,7 @@ void nsFileSpec::RecursiveCopy(nsFileSpec newDir) const
|
|||
newDir.CreateDirectory();
|
||||
}
|
||||
|
||||
filePath.Copy(newDir);
|
||||
filePath.CopyToDir(newDir);
|
||||
}
|
||||
} // nsFileSpec::RecursiveCopy
|
||||
|
||||
|
@ -494,7 +494,7 @@ nsresult nsFileSpec::Rename(const char* inNewName)
|
|||
} // nsFileSpec::Rename
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
||||
nsresult nsFileSpec::CopyToDir(const nsFileSpec& inParentDirectory) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
@ -512,10 +512,10 @@ nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
|||
return NS_OK;
|
||||
}
|
||||
return NS_FILE_FAILURE;
|
||||
} // nsFileSpec::Copy
|
||||
} // nsFileSpec::CopyToDir
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Move(const nsFileSpec& inNewParentDirectory)
|
||||
nsresult nsFileSpec::MoveToDir(const nsFileSpec& inNewParentDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// We can only copy into a directory, and (for now) can not copy entire directories
|
||||
|
@ -538,7 +538,7 @@ nsresult nsFileSpec::Move(const nsFileSpec& inNewParentDirectory)
|
|||
|
||||
}
|
||||
return NS_FILE_FAILURE;
|
||||
} // nsFileSpec::Move
|
||||
} // nsFileSpec::MoveToDir
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsFileSpec::Execute(const char* inArgs ) const
|
||||
|
|
|
@ -228,14 +228,19 @@ REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedF
|
|||
|
||||
if ( !doomedFile.Exists() )
|
||||
{
|
||||
// Now that we have removed the existing file, we can move the mExtracedFile or mPatchedFile into place.
|
||||
// Now that we have removed the existing file, we can move the replacement file into place.
|
||||
nsFileSpec parentofFinalFile;
|
||||
nsFileSpec parentofReplacementFile;
|
||||
|
||||
doomedFile.GetParent(parentofFinalFile);
|
||||
replacementFile.GetParent(parentofReplacementFile);
|
||||
|
||||
// XXX looks dangerous, the replacement file name may NOT be unique in the
|
||||
// target directory if we have to move it! Either we should never move the
|
||||
// files like this (i.e. error if not in the same dir) or we need to take
|
||||
// a little more care in the move.
|
||||
if(parentofReplacementFile != parentofFinalFile)
|
||||
result = replacementFile.Move(parentofFinalFile);
|
||||
result = replacementFile.MoveToDir(parentofFinalFile);
|
||||
else
|
||||
result = NS_OK;
|
||||
|
||||
|
@ -249,6 +254,7 @@ REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedF
|
|||
else
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
// XXX Holy cow! what the fsck is this? Fix it!
|
||||
if (DoWindowsReplaceExistingFileStuff(replacementFile.GetNativePathCString(), doomedFile.GetNativePathCString()) == 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -362,7 +368,7 @@ void ReplaceScheduledFiles(void)
|
|||
nsFileSpec parentofTarget;
|
||||
targetFile.GetParent(parentofTarget);
|
||||
|
||||
nsresult result = replaceFile.Move(parentofTarget);
|
||||
nsresult result = replaceFile.MoveToDir(parentofTarget);
|
||||
if ( NS_SUCCEEDED(result) )
|
||||
{
|
||||
char* leafName = targetFile.GetLeafName();
|
||||
|
|
|
@ -398,7 +398,7 @@ nsInstallFileOpItem::NativeFileOpDirRename(nsFileSpec* aSrc, nsString* aTarget)
|
|||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileCopy(nsFileSpec* aSrc, nsFileSpec* aTarget)
|
||||
{
|
||||
return aSrc->Copy(*aTarget);
|
||||
return aSrc->CopyToDir(*aTarget);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
@ -417,7 +417,7 @@ nsInstallFileOpItem::NativeFileOpFileExecute(nsFileSpec* aTarget, nsString* aPar
|
|||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileMove(nsFileSpec* aSrc, nsFileSpec* aTarget)
|
||||
{
|
||||
return aSrc->Move(*aTarget);
|
||||
return aSrc->MoveToDir(*aTarget);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
|
Загрузка…
Ссылка в новой задаче