Changeset 2389

Show
Ignore:
Timestamp:
30/11/2008 21:54:55 (22 months ago)
Author:
chris
Message:

openfile() stores its Windows error code (from GetLastError?() or
synthetic) in winerrno, to enable better error handling outside.

Location:
box/trunk/lib/win32
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/win32/emu.cpp

    r2287 r2389  
    3131static bool gFinishTimer; 
    3232static CRITICAL_SECTION gLock; 
     33 
     34DWORD winerrno; 
    3335 
    3436typedef struct  
     
    286288        if (len == 0) 
    287289        { 
     290                winerrno = GetLastError(); 
    288291                if (logErrors) 
    289292                { 
    290293                        ::syslog(LOG_WARNING,  
    291294                                "Failed to convert string to wide string: " 
    292                                 "%s", GetErrorMessage(GetLastError()).c_str()); 
     295                                "%s", GetErrorMessage(winerrno).c_str()); 
    293296                } 
    294297                errno = EINVAL; 
     
    306309                                "out of memory"); 
    307310                } 
     311                winerrno = ERROR_OUTOFMEMORY; 
    308312                errno = ENOMEM; 
    309313                return NULL; 
     
    322326        if (len == 0) 
    323327        { 
     328                winerrno = GetLastError(); 
    324329                if (logErrors) 
    325330                { 
    326331                        ::syslog(LOG_WARNING,  
    327332                                "Failed to convert string to wide string: " 
    328                                 "%s", GetErrorMessage(GetLastError()).c_str()); 
     333                                "%s", GetErrorMessage(winerrno).c_str()); 
    329334                } 
    330335                errno = EACCES; 
     
    520525                        pFileName); 
    521526                errno = ENAMETOOLONG; 
     527                winerrno = ERROR_INVALID_NAME; 
    522528                tmpStr = ""; 
    523529                return tmpStr; 
     
    595601HANDLE openfile(const char *pFileName, int flags, int mode) 
    596602{ 
     603        winerrno = ERROR_INVALID_FUNCTION; 
     604 
    597605        std::string AbsPathWithUnicode =  
    598606                ConvertPathToAbsoluteUnicode(pFileName); 
     
    668676        if (hdir == INVALID_HANDLE_VALUE) 
    669677        { 
    670                 switch(GetLastError()) 
     678                winerrno = GetLastError(); 
     679                switch(winerrno) 
    671680                { 
    672681                        case ERROR_SHARING_VIOLATION: 
     
    685694        } 
    686695 
     696        winerrno = NO_ERROR; 
    687697        return hdir; 
    688698} 
  • box/trunk/lib/win32/emu.h

    r2207 r2389  
    246246#define O_LOCK 0x10000 
    247247 
     248extern DWORD winerrno; /* used to report errors from openfile() */ 
    248249HANDLE openfile(const char *filename, int flags, int mode); 
    249250