[Box Backup-commit] COMMIT r1317 - box/chris/general/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Sat, 03 Mar 2007 21:42:39 +0000
Author: chris
Date: 2007-03-03 21:42:39 +0000 (Sat, 03 Mar 2007)
New Revision: 1317
Modified:
box/chris/general/lib/common/FileStream.cpp
Log:
Throw Common AccessDenied instead of Common OSFileOpenError when access
to a file is denied, to improve log messages (from chris/merge)
Modified: box/chris/general/lib/common/FileStream.cpp
===================================================================
--- box/chris/general/lib/common/FileStream.cpp 2007-03-03 21:41:31 UTC (rev 1316)
+++ box/chris/general/lib/common/FileStream.cpp 2007-03-03 21:42:39 UTC (rev 1317)
@@ -11,6 +11,8 @@
#include "FileStream.h"
#include "CommonException.h"
+#include <errno.h>
+
#include "MemLeakFindOn.h"
// --------------------------------------------------------------------------
@@ -36,7 +38,15 @@
#endif
{
MEMLEAKFINDER_NOT_A_LEAK(this);
- THROW_EXCEPTION(CommonException, OSFileOpenError)
+
+ if(errno == EACCES)
+ {
+ THROW_EXCEPTION(CommonException, AccessDenied)
+ }
+ else
+ {
+ THROW_EXCEPTION(CommonException, OSFileOpenError)
+ }
}
#ifdef WIN32
this->fileName = Filename;
@@ -211,7 +221,7 @@
NULL
);
- if ( (res == 0) || (numBytesWritten != NBytes))
+ if ((res == 0) || (numBytesWritten != (DWORD)NBytes))
{
// DWORD err = GetLastError();
THROW_EXCEPTION(CommonException, OSFileWriteError)