if (inFile.Error() != noErr) return NS_FILE_RESULT(inFile.Error()); OSErr err = noErr;
OSErr err = inFile.Error(); if (err != noErr) if (err != fnfErr || !(nsprMode & PR_CREATE_FILE)) return NS_FILE_RESULT(inFile.Error()); err = noErr;
NS_IMETHODIMP FileImpl::Open(    const nsFileSpec& inFile,    int nsprMode,    PRIntn accessMode)//----------------------------------------------------------------------------------------{    if (mFileDesc)        if ((nsprMode & mNSPRMode) == nsprMode)            return NS_OK;        else            return NS_FILE_RESULT(PR_ILLEGAL_ACCESS_ERROR);            const int nspr_modes[]={        PR_WRONLY | PR_CREATE_FILE,        PR_WRONLY | PR_CREATE_FILE | PR_APPEND,        PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,        PR_RDONLY,        PR_RDONLY | PR_APPEND,        PR_RDWR | PR_CREATE_FILE,        PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,//      "wb",//      "ab", //      "wb",//      "rb",//      "r+b",//      "w+b",        0 };    const int* currentLegalMode = nspr_modes;    while (*currentLegalMode && nsprMode != *currentLegalMode)        ++currentLegalMode;    if (!*currentLegalMode)         return NS_FILE_RESULT(PR_ILLEGAL_ACCESS_ERROR);#ifdef XP_MAC     // Use the file spec to open the file, because one path can be common to     // several files on the Macintosh (you can have several volumes with the     // same name, see).    mFileDesc = 0;    if (inFile.Error() != noErr)        return NS_FILE_RESULT(inFile.Error());    OSErr err = noErr;#if DEBUG    const OSType kCreator = 'CWIE';#else    const OSType kCreator = 'MOSS';#endif    // Resolve the alias to the original file.    nsFileSpec original = inFile;    PRBool ignoredResult;    original.ResolveAlias(ignoredResult);    const FSSpec& spec = original.operator const FSSpec&();    if (nsprMode & PR_CREATE_FILE)        err = FSpCreate(&spec, kCreator, 'TEXT', 0);    if (err == dupFNErr)        err = noErr;    if (err != noErr)        return NS_FILE_RESULT(err);        SInt8 perm;    if (nsprMode & PR_RDWR)       perm = fsRdWrPerm;    else if (nsprMode & PR_WRONLY)       perm = fsWrPerm;    else       perm = fsRdPerm;    short refnum;    err = FSpOpenDF(&spec, perm, &refnum);    if (err == noErr && (nsprMode & PR_TRUNCATE))        err = SetEOF(refnum, 0);    if (err == noErr && (nsprMode & PR_APPEND))        err = SetFPos(refnum, fsFromLEOF, 0);    if (err != noErr)        return NS_FILE_RESULT(err);    if ((mFileDesc = PR_ImportFile(refnum)) == 0)        return NS_FILE_RESULT(PR_GetError());#else    //    Platforms other than Macintosh...    //  Another bug in NSPR: Mac PR_Open assumes a unix style path, but Win PR_Open assumes    //  a windows path.    if ((mFileDesc = PR_Open((const char*)nsFileSpec(inFile), nsprMode, accessMode)) == 0)        return NS_FILE_RESULT(PR_GetError());#endif     mNSPRMode = nsprMode;     mLength = PR_Available(mFileDesc);     return NS_OK;} // FileImpl::Open