Ignore:
Timestamp:
Aug 22, 2002, 4:21:27 PM (23 years ago)
Author:
sandervl
Message:

Rewrote GetFileAttributesA & translate filename used from Windows to OS/2 codepage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/oslibdos.cpp

    r8864 r9095  
    1 /* $Id: oslibdos.cpp,v 1.107 2002-07-13 15:58:20 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.108 2002-08-22 14:21:26 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    22722272//******************************************************************************
    22732273//******************************************************************************
    2274 BOOL  OSLibDosFindClose(DWORD hFindFile)
     2274BOOL OSLibDosFindClose(DWORD hFindFile)
    22752275{
    22762276  APIRET rc = DosFindClose((HDIR)hFindFile);
     
    22832283  SetLastError(ERROR_SUCCESS_W);
    22842284  return TRUE;
     2285}
     2286//******************************************************************************
     2287//******************************************************************************
     2288DWORD OSLibGetFileAttributes(LPSTR lpFileName)
     2289{
     2290   FILESTATUS3 statusBuf;
     2291   char        lOemFileName[CCHMAXPATH];
     2292   char       *lpszBackslash, *lpszColon;
     2293   APIRET      rc;
     2294
     2295   //Convert file name from Windows to OS/2 codepage
     2296   CharToOemA(lpFileName, lOemFileName);
     2297   lpszBackslash = CharPrevA(lOemFileName, lOemFileName + strlen(lOemFileName));
     2298   if(lpszBackslash)
     2299   {
     2300       if(*lpszBackslash == '\\')
     2301       {
     2302           lpszColon = CharPrevA(lOemFileName, lpszBackslash);
     2303           if(lpszColon && *lpszColon != ':')
     2304           {//only rootdir is allowed to have terminating backslash
     2305               *lpszBackslash = 0;
     2306           }
     2307       }
     2308       else
     2309       if(*lpszBackslash == ':')
     2310       {//root dir must end with backslash
     2311           strcat(lOemFileName, "\\");
     2312       }
     2313   }
     2314
     2315   rc = DosQueryPathInfo(lOemFileName, FIL_STANDARD, &statusBuf, sizeof(statusBuf));
     2316   if(rc == ERROR_TOO_MANY_OPEN_FILES)
     2317   {
     2318       LONG  reqCount = 2;
     2319       ULONG maxFiles;
     2320
     2321       if(DosSetRelMaxFH(&reqCount, &maxFiles) == NO_ERROR)
     2322           rc = DosQueryPathInfo(lOemFileName, FIL_STANDARD, &statusBuf, sizeof(statusBuf));
     2323   }
     2324
     2325   if(rc == NO_ERROR)
     2326   {
     2327      DWORD status = 0;
     2328      if(!(statusBuf.attrFile & NOT_NORMAL))
     2329          status |= FILE_ATTRIBUTE_NORMAL_W;
     2330      if(statusBuf.attrFile & FILE_READONLY)
     2331          status |= FILE_ATTRIBUTE_READONLY_W;
     2332      if(statusBuf.attrFile & FILE_HIDDEN)
     2333          status |= FILE_ATTRIBUTE_HIDDEN_W;
     2334      if(statusBuf.attrFile & FILE_SYSTEM)
     2335          status |= FILE_ATTRIBUTE_SYSTEM_W;
     2336      if(statusBuf.attrFile & FILE_DIRECTORY)
     2337          status |= FILE_ATTRIBUTE_DIRECTORY_W;
     2338      if(statusBuf.attrFile & FILE_ARCHIVED)
     2339          status |= FILE_ATTRIBUTE_ARCHIVE_W;
     2340
     2341      SetLastError(ERROR_SUCCESS_W);
     2342      return status;
     2343   }
     2344   SetLastError(error2WinError(rc));
     2345   return -1;
    22852346}
    22862347//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.