Ignore:
Timestamp:
Jul 7, 2009, 7:40:22 PM (16 years ago)
Author:
vladest
Message:

Added functionality, required for Flash10 to kernel32

File:
1 edited

Legend:

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

    r21302 r21329  
    1 /* $Id: oslibdos.cpp,v 1.120 2003-06-02 16:25:19 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.120 2003/06/02 16:25:19 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    9595
    9696
    97 
     97char* ODINHelperStripUNC(char* strUNC)
     98{
     99    char *retStr = strUNC;
     100
     101    if (!strUNC) return NULL;
     102
     103    /* first possible case */
     104    if (strUNC[0] == '\\' &&
     105        (strUNC[1] == '?' || (strUNC[1] >= 'A' && strUNC[1] <= 'Z' )) &&
     106        strUNC[2] == '\\')
     107    {
     108
     109        retStr = &strUNC[3];
     110    }
     111    /* second possible case */
     112    if (strUNC[0] == '\\' && strUNC[1] == '\\' &&
     113        (strUNC[2] == '?' || (strUNC[2] >= 'A' && strUNC[2] <= 'Z' )) &&
     114        strUNC[3] == '\\')
     115    {
     116
     117        retStr = &strUNC[4];
     118    }
     119    return retStr;
     120}
    98121
    99122//******************************************************************************
     
    171194 USHORT sel = RestoreOS2FS();
    172195 char OemFileName[260];
    173  CharToOemA(pszFileName, OemFileName);
     196 CharToOemA(ODINHelperStripUNC((char*)pszFileName), OemFileName);
    174197
    175198    if(DosOpenLProc) {
     
    266289        return ERROR_WRONG_DISK_W;
    267290
     291    case ERROR_SHARING_BUFFER_EXCEEDED: //36
     292        return ERROR_SHARING_BUFFER_EXCEEDED_W;
     293
    268294    case ERROR_BAD_NETPATH: //53
    269295        return ERROR_BAD_NETPATH_W;
    270 
    271     case ERROR_SHARING_BUFFER_EXCEEDED: //36
    272         return ERROR_SHARING_BUFFER_EXCEEDED_W;
    273296
    274297    case ERROR_CANNOT_MAKE: //82
     
    439462 char lOemFileName[260];
    440463
    441   CharToOemA(lpszFileName, lOemFileName);
     464  CharToOemA(ODINHelperStripUNC(lpszFileName), lOemFileName);
    442465
    443466  if(flags & OSLIB_ACCESS_READONLY)
     
    508531 char lOemOldFile[260], lOemNewFile[260];
    509532
    510   CharToOemA(lpszOldFile, lOemOldFile);
    511   CharToOemA(lpszNewFile, lOemNewFile);
     533  CharToOemA(ODINHelperStripUNC((char*)lpszOldFile), lOemOldFile);
     534  CharToOemA(ODINHelperStripUNC((char*)lpszNewFile), lOemNewFile);
    512535
    513536  rc = DosCopy((PSZ)lOemOldFile, (PSZ)lOemNewFile, fFailIfExist ? 0: DCPY_EXISTING);
     
    522545 char lOemOldFile[260], lOemNewFile[260];
    523546
    524   CharToOemA(lpszOldFile, lOemOldFile);
    525   CharToOemA(lpszNewFile, lOemNewFile);
     547  CharToOemA(ODINHelperStripUNC((char*)lpszOldFile), lOemOldFile);
     548  CharToOemA(ODINHelperStripUNC((char*)lpszNewFile), lOemNewFile);
    526549
    527550  // we need to know the current drive for relative paths
     
    574597 char lOemDir[260];
    575598
    576   CharToOemA(lpszDir, lOemDir);
     599  CharToOemA(ODINHelperStripUNC((char*)lpszDir), lOemDir);
    577600
    578601  rc = DosDeleteDir((PSZ)lOemDir);
     
    587610 char lOemDir[260];
    588611
    589   CharToOemA(lpszDir, lOemDir);
     612  CharToOemA(ODINHelperStripUNC((char*)lpszDir), lOemDir);
    590613
    591614  rc = DosCreateDir((PSZ)lOemDir, NULL);
     
    697720    char lOemFileName[260];
    698721
    699     CharToOemA(lpszFileName, lOemFileName);
     722    CharToOemA(ODINHelperStripUNC(lpszFileName), lOemFileName);
    700723
    701724    rc = DosDelete(lOemFileName);
     
    775798
    776799  // Note: we only handle standard "GetFileExInfoStandard" requests
    777   rc = DosQueryPathInfo(pszName,               /* query the file information */
     800  rc = DosQueryPathInfo(ODINHelperStripUNC(pszName),               /* query the file information */
    778801                        FIL_STANDARD,
    779802                        &fs3,
     
    804827  switch(cmd) {
    805828  case OSLIB_SEARCHDIR:
    806         if(DosSearchPath(SEARCH_IGNORENETERRS, path,
     829        if(DosSearchPath(SEARCH_IGNORENETERRS, ODINHelperStripUNC(path),
    807830                         name, full_name, length_fullname) != 0) {
    808831                return 0;
     
    812835
    813836  case OSLIB_SEARCHCURDIR:
    814         if(DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_CUR_DIRECTORY, path,
     837        if(DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_CUR_DIRECTORY, ODINHelperStripUNC(path),
    815838                         name, full_name, length_fullname) != 0) {
    816839                return 0;
     
    822845    FILESTATUS3 fileinfo;
    823846
    824         if(DosQueryPathInfo(name, FIL_STANDARD, &fileinfo, sizeof(fileinfo)) != 0) {
     847        if(DosQueryPathInfo(ODINHelperStripUNC(name), FIL_STANDARD, &fileinfo, sizeof(fileinfo)) != 0) {
    825848                return 0;
    826849        }
     
    858881                            ULONG cbInfoBuf)
    859882{
    860    APIRET rc = DosQueryPathInfo( pszPathName, ulInfoLevel,
     883   APIRET rc = DosQueryPathInfo( ODINHelperStripUNC(pszPathName), ulInfoLevel,
    861884                                 pInfoBuf, cbInfoBuf );
    862885
     
    888911   ULONG   openFlag = 0;
    889912   ULONG   openMode = OPEN_FLAGS_NOINHERIT; //default is not inherited by child processes
    890    APIRET  rc = ERROR_NOT_ENOUGH_MEMORY;;
     913   APIRET  rc = ERROR_NOT_ENOUGH_MEMORY;
     914
     915   CHAR* lpszFileLoc = ODINHelperStripUNC(lpszFile);
    891916
    892917   //TODO: lpSecurityAttributes (inheritance)
     
    9801005#endif
    9811006
    982    if(strlen(lpszFile) == 2 && lpszFile[1] == ':') {
     1007   if(strlen(lpszFileLoc) == 2 && lpszFileLoc[1] == ':') {
    9831008        //app tries to open logical volume/partition
    9841009        openMode |= OPEN_FLAGS_DASD;
    9851010   }
     1011   
    9861012   int retry = 0;
    9871013   while (retry < 3)
    9881014   {
    989         dprintf(("DosOpen %s openFlag=%x openMode=%x", lpszFile, openFlag, openMode));
    990         rc = OdinDosOpenL((PSZ)lpszFile,
     1015        dprintf(("DosOpen %s openFlag=%x openMode=%x", lpszFileLoc, openFlag, openMode));
     1016        rc = OdinDosOpenL((PSZ)lpszFileLoc,
    9911017                           &hFile,
    9921018                           &actionTaken,
     
    10481074      // @@@AH 2001-06-02 Win2k SP2 returns error 2 in this case
    10491075      int winError = error2WinError(rc);
    1050       if (winError == ERROR_OPEN_FAILED_W)
     1076      if (winError == ERROR_OPEN_FAILED_W || winError == ERROR_PATH_NOT_FOUND_W)
    10511077      {
    10521078          //Windows returns ERROR_FILE_EXISTS if create new & file exists
     
    13031329      break;
    13041330  }
    1305 
     1331#if 0
    13061332  // PH Note: for a negative 32-bit seek, the OS/2 64-bit version
    13071333  // needs to be skipped.
    1308   if( (f64BitIO) && (OffsetHigh) )
     1334  if( (f64BitIO) && (OffsetHigh) &&
     1335     (*OffsetHigh != 0xAAAAAAAA) &&
     1336     (*OffsetHigh != 0)) //workaround for flash10 video
    13091337  {
    13101338        offsetL.ulLo = OffsetLow;
     
    13161344        newoffset = newoffsetL.ulLo;
    13171345  }
    1318   else  rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
     1346  else
     1347#endif
     1348      rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
    13191349
    13201350  if(rc)
     
    22352265  char    lOemFileName[260];
    22362266
    2237   CharToOemA(lpFileName, lOemFileName);
     2267  CharToOemA(ODINHelperStripUNC((char*)lpFileName), lOemFileName);
    22382268
    22392269  APIRET rc = DosFindFirst((PSZ)lOemFileName,&hDir,attrs,&result,sizeof(result),&searchCount,FIL_STANDARD);
     
    22412271  //check root: skip "." and ".." (HPFS, not on FAT)
    22422272  //check in OSLibDosFindNext not necessary: "." and ".." are the first two entries
    2243   if ((rc == 0) && isRoot((LPSTR)lpFileName))
     2273  if ((rc == 0) && isRoot((LPSTR)ODINHelperStripUNC((char*)lpFileName)))
    22442274  {
    22452275    while ((strcmp(result.achName,".") == 0) ||
     
    22942324  char  lOemFileName[260];
    22952325
    2296   CharToOemA(lpFileName, lOemFileName);
     2326  CharToOemA(ODINHelperStripUNC((char*)lpFileName), lOemFileName);
    22972327  APIRET rc = DosFindFirst((PSZ)lOemFileName,&hDir,attrs,result,searchCount*sizeof(FILEFINDBUF3),&searchCount,FIL_STANDARD);
    22982328  SetErrorMode(oldmode);
     
    23862416{
    23872417   FILESTATUS3 statusBuf;
    2388    char        *lOemFileName;
     2418   char        lOemFileName[CCHMAXPATH];
    23892419   char       *lpszBackslash, *lpszColon;
    23902420   APIRET      rc;
    23912421
    2392    lOemFileName = (char *)malloc(strlen(lpFileName)+64);
    2393    lOemFileName[0] = 0;
     2422//testestest
     2423   if(strlen(lpFileName) > CCHMAXPATH) DebugInt3();
     2424//testestset
    23942425
    23952426   //Convert file name from Windows to OS/2 codepage
    2396    CharToOemA(lpFileName, lOemFileName);
     2427   CharToOemA(ODINHelperStripUNC(lpFileName), lOemFileName);
    23972428   lpszBackslash = CharPrevA(lOemFileName, lOemFileName + strlen(lOemFileName));
    23982429   if(lpszBackslash)
     
    24012432       {
    24022433           lpszColon = CharPrevA(lOemFileName, lpszBackslash);
    2403            if(strlen(lOemFileName) > 1 && lpszColon && *lpszColon != ':')
     2434           if(lpszColon && *lpszColon != ':')
    24042435           {//only rootdir is allowed to have terminating backslash
    24052436               *lpszBackslash = 0;
     
    24222453           rc = DosQueryPathInfo(lOemFileName, FIL_STANDARD, &statusBuf, sizeof(statusBuf));
    24232454   }
    2424    free(lOemFileName);
    24252455
    24262456   if(rc == NO_ERROR)
Note: See TracChangeset for help on using the changeset viewer.