Added kNuErrFileAccessDenied. Return it when OpenRW fails with an

access permission problem, so that an application can follow it with
an OpenRO call for read-only files.
This commit is contained in:
Andy McFadden 2003-02-27 21:33:29 +00:00
parent 36f47b866c
commit 7469f782cb
3 changed files with 10 additions and 1 deletions

View File

@ -769,6 +769,9 @@ bail:
/*
* Open a temp file. If "fileName" contains six Xs ("XXXXXX"), it will
* be treated as a mktemp-style template, and modified before use.
*
* Thought for the day: consider using Win32 SetFileAttributes() to make
* temp files hidden. We will need to un-hide it before rolling it over.
*/
static NuError
Nu_OpenTempFile(char* fileName, FILE** pFp)
@ -914,8 +917,11 @@ Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags,
}
if (fp == nil) {
if (errno == EACCES)
err = kNuErrFileAccessDenied;
else
err = kNuErrFileOpen;
Nu_ReportError(NU_BLOB, errno, "Unable to open '%s'", archivePathname);
err = kNuErrFileOpen;
goto bail;
}

View File

@ -104,6 +104,8 @@ Nu_StrError(NuError err)
return "Unable to set file date";
case kNuErrFileSetAccess:
return "Unable to set file access";
case kNuErrFileAccessDenied:
return "Access denied";
case kNuErrNotNuFX:
return "Input is not a NuFX archive";

View File

@ -84,6 +84,7 @@ typedef enum NuError {
kNuErrReadDir = -35, /* error reading directory */
kNuErrFileSetDate = -36, /* unable to set file date */
kNuErrFileSetAccess = -37, /* unable to set file access permissions */
kNuErrFileAccessDenied = -38, /* equivalent to EACCES */
kNuErrNotNuFX = -40, /* 'NuFile' missing; not a NuFX archive? */
kNuErrBadMHVersion = -41, /* bad master header version */