Bug 187031 [nsLocalFileWin] nsLocalFile::Remove returns os remove values (-1) as nsresults

r=dougt sr=darin
This commit is contained in:
timeless%mozdev.org 2003-06-18 23:19:11 +00:00
parent 7155f9d29a
commit 4942b03239
13 changed files with 51 additions and 55 deletions

View File

@ -54,7 +54,7 @@ PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN;
#include <sys/time.h>
#include <dirent.h>
#include "nsAppDirectoryServiceDefs.h"
#include "nsLocalFileUnix.h"
#include "nsLocalFile.h"
#include "nsIEnumerator.h"
#include "nsITimelineService.h"

View File

@ -49,6 +49,10 @@
// nsXPComInit needs to know about how we are implemented,
// so here we will export it. Other users should not depend
// on this.
#include <errno.h>
#include "nsILocalFile.h"
#ifdef XP_WIN
#include "nsLocalFileWin.h"
#elif defined(XP_MACOSX)
@ -63,6 +67,36 @@
#error NOT_IMPLEMENTED
#endif
#define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
inline nsresult
nsresultForErrno(int err)
{
switch (err) {
case 0:
return NS_OK;
case ENOENT:
return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
case ENOTDIR:
return NS_ERROR_FILE_DESTINATION_NOT_DIR;
#ifdef ENOLINK
case ENOLINK:
return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
#endif /* ENOLINK */
case EEXIST:
return NS_ERROR_FILE_ALREADY_EXISTS;
#ifdef EPERM
case EPERM:
#endif /* EPERM */
case EACCES:
return NS_ERROR_FILE_ACCESS_DENIED;
default:
return NS_ERROR_FAILURE;
}
}
#define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
void NS_StartupLocalFile();
void NS_ShutdownLocalFile();

View File

@ -28,7 +28,7 @@
#include "nsMemory.h"
#include "nsXPIDLString.h"
#include "nsLocalFileMac.h"
#include "nsLocalFile.h"
#include "nsNativeCharsetUtils.h"
#include "nsISimpleEnumerator.h"
#include "nsIComponentManager.h"

View File

@ -30,10 +30,8 @@
#include "nsString.h"
#include "nsCRT.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsILocalFileMac.h"
#include "nsIFactory.h"
#include "nsLocalFile.h"
#include <Processes.h>

View File

@ -27,7 +27,7 @@
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsLocalFileOS2.h"
#include "nsLocalFile.h"
#include "nsNativeCharsetUtils.h"
#include "nsISimpleEnumerator.h"
@ -1075,14 +1075,14 @@ nsLocalFile::Remove(PRBool recursive)
}
}
#ifdef XP_OS2_VACPP
rv = rmdir((char *) filePath); // todo: save return value?
rv = rmdir((char *) filePath) == -1 ? NSRESULT_FOR_ERRNO() : NS_OK;
#else
rv = rmdir(filePath); // todo: save return value?
rv = rmdir(filePath) == -1 ? NSRESULT_FOR_ERRNO() : NS_OK;
#endif
}
else
{
rv = remove(filePath); // todo: save return value?
rv = remove(filePath) == -1 ? NSRESULT_FOR_ERRNO() : NS_OK;
}
MakeDirty();

View File

@ -37,9 +37,7 @@
#include "nsString.h"
#include "nsCRT.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsIFactory.h"
#include "nsLocalFile.h"
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
@ -53,6 +51,10 @@
#include <os2.h>
#ifdef XP_OS2_VACPP
#define ENOTDIR EBADPOS
#endif
class NS_COM nsLocalFile : public nsILocalFile
{
public:

View File

@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsLocalFileOSX.h"
#include "nsLocalFile.h"
#include "nsString.h"
#include "nsReadableUtils.h"

View File

@ -40,7 +40,6 @@
#define nsLocalFileMac_h__
#include "nsILocalFileMac.h"
#include "nsLocalFile.h"
#include "nsString.h"
class nsDirEnumerator;

View File

@ -56,10 +56,9 @@
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsLocalFileUnix.h"
#include "nsLocalFile.h"
#include "nsIComponentManager.h"
#include "nsXPIDLString.h"
#include "prproces.h"

View File

@ -32,11 +32,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "nscore.h"
#include "nsILocalFile.h"
#include "nsLocalFile.h"
#include "nsString.h"
#include "nsReadableUtils.h"
@ -68,34 +64,6 @@
#include <sys/mount.h>
#endif
#define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
inline nsresult
nsresultForErrno(int err)
{
switch (err) {
case 0:
return NS_OK;
case ENOENT:
return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
case ENOTDIR:
return NS_ERROR_FILE_DESTINATION_NOT_DIR;
#ifdef ENOLINK
case ENOLINK:
return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
#endif /* ENOLINK */
case EEXIST:
return NS_ERROR_FILE_ALREADY_EXISTS;
case EPERM:
case EACCES:
return NS_ERROR_FILE_ACCESS_DENIED;
default:
return NS_ERROR_FAILURE;
}
}
#define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
class NS_COM nsLocalFile : public nsILocalFile
{
public:

View File

@ -26,7 +26,7 @@
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsLocalFileWin.h"
#include "nsLocalFile.h"
#include "nsNativeCharsetUtils.h"
#include "nsISimpleEnumerator.h"
@ -1070,7 +1070,7 @@ nsLocalFile::CopySingleFile(nsIFile *sourceFile, nsIFile *destParent, const nsAC
if (copyOK)
{
// remove the backup copy.
(void) remove(backup.get());
remove(backup.get());
}
else
{
@ -1405,11 +1405,11 @@ nsLocalFile::Remove(PRBool recursive)
iterator->HasMoreElements(&more);
}
}
rv = rmdir(filePath); // todo: save return value?
rv = rmdir(filePath) == -1 ? NSRESULT_FOR_ERRNO() : NS_OK;
}
else
{
rv = remove(filePath); // todo: save return value?
rv = remove(filePath) == -1 ? NSRESULT_FOR_ERRNO() : NS_OK;
}
MakeDirty();

View File

@ -30,9 +30,7 @@
#include "nsString.h"
#include "nsCRT.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsIFactory.h"
#include "nsLocalFile.h"
#include "windows.h"

View File

@ -29,7 +29,7 @@
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsILocalFile.h"
#include "nsLocalFile.h"
#include "nscore.h"
#include "nspr.h"
@ -58,8 +58,6 @@
#ifdef XP_MAC
#define COMPONENT_REG "\pComponent Registry"
#include "MoreFilesExtras.h"
#include "nsLocalFileMac.h"
#include "nsILocalFileMac.h"
#endif
#ifdef XP_UNIX