Changeset 21329 for trunk/src/kernel32/oslibdos.cpp
- Timestamp:
- Jul 7, 2009, 7:40:22 PM (16 years ago)
- 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 $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 95 95 96 96 97 97 char* 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 } 98 121 99 122 //****************************************************************************** … … 171 194 USHORT sel = RestoreOS2FS(); 172 195 char OemFileName[260]; 173 CharToOemA( pszFileName, OemFileName);196 CharToOemA(ODINHelperStripUNC((char*)pszFileName), OemFileName); 174 197 175 198 if(DosOpenLProc) { … … 266 289 return ERROR_WRONG_DISK_W; 267 290 291 case ERROR_SHARING_BUFFER_EXCEEDED: //36 292 return ERROR_SHARING_BUFFER_EXCEEDED_W; 293 268 294 case ERROR_BAD_NETPATH: //53 269 295 return ERROR_BAD_NETPATH_W; 270 271 case ERROR_SHARING_BUFFER_EXCEEDED: //36272 return ERROR_SHARING_BUFFER_EXCEEDED_W;273 296 274 297 case ERROR_CANNOT_MAKE: //82 … … 439 462 char lOemFileName[260]; 440 463 441 CharToOemA( lpszFileName, lOemFileName);464 CharToOemA(ODINHelperStripUNC(lpszFileName), lOemFileName); 442 465 443 466 if(flags & OSLIB_ACCESS_READONLY) … … 508 531 char lOemOldFile[260], lOemNewFile[260]; 509 532 510 CharToOemA( lpszOldFile, lOemOldFile);511 CharToOemA( lpszNewFile, lOemNewFile);533 CharToOemA(ODINHelperStripUNC((char*)lpszOldFile), lOemOldFile); 534 CharToOemA(ODINHelperStripUNC((char*)lpszNewFile), lOemNewFile); 512 535 513 536 rc = DosCopy((PSZ)lOemOldFile, (PSZ)lOemNewFile, fFailIfExist ? 0: DCPY_EXISTING); … … 522 545 char lOemOldFile[260], lOemNewFile[260]; 523 546 524 CharToOemA( lpszOldFile, lOemOldFile);525 CharToOemA( lpszNewFile, lOemNewFile);547 CharToOemA(ODINHelperStripUNC((char*)lpszOldFile), lOemOldFile); 548 CharToOemA(ODINHelperStripUNC((char*)lpszNewFile), lOemNewFile); 526 549 527 550 // we need to know the current drive for relative paths … … 574 597 char lOemDir[260]; 575 598 576 CharToOemA( lpszDir, lOemDir);599 CharToOemA(ODINHelperStripUNC((char*)lpszDir), lOemDir); 577 600 578 601 rc = DosDeleteDir((PSZ)lOemDir); … … 587 610 char lOemDir[260]; 588 611 589 CharToOemA( lpszDir, lOemDir);612 CharToOemA(ODINHelperStripUNC((char*)lpszDir), lOemDir); 590 613 591 614 rc = DosCreateDir((PSZ)lOemDir, NULL); … … 697 720 char lOemFileName[260]; 698 721 699 CharToOemA( lpszFileName, lOemFileName);722 CharToOemA(ODINHelperStripUNC(lpszFileName), lOemFileName); 700 723 701 724 rc = DosDelete(lOemFileName); … … 775 798 776 799 // Note: we only handle standard "GetFileExInfoStandard" requests 777 rc = DosQueryPathInfo( pszName, /* query the file information */800 rc = DosQueryPathInfo(ODINHelperStripUNC(pszName), /* query the file information */ 778 801 FIL_STANDARD, 779 802 &fs3, … … 804 827 switch(cmd) { 805 828 case OSLIB_SEARCHDIR: 806 if(DosSearchPath(SEARCH_IGNORENETERRS, path,829 if(DosSearchPath(SEARCH_IGNORENETERRS, ODINHelperStripUNC(path), 807 830 name, full_name, length_fullname) != 0) { 808 831 return 0; … … 812 835 813 836 case OSLIB_SEARCHCURDIR: 814 if(DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_CUR_DIRECTORY, path,837 if(DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_CUR_DIRECTORY, ODINHelperStripUNC(path), 815 838 name, full_name, length_fullname) != 0) { 816 839 return 0; … … 822 845 FILESTATUS3 fileinfo; 823 846 824 if(DosQueryPathInfo( name, FIL_STANDARD, &fileinfo, sizeof(fileinfo)) != 0) {847 if(DosQueryPathInfo(ODINHelperStripUNC(name), FIL_STANDARD, &fileinfo, sizeof(fileinfo)) != 0) { 825 848 return 0; 826 849 } … … 858 881 ULONG cbInfoBuf) 859 882 { 860 APIRET rc = DosQueryPathInfo( pszPathName, ulInfoLevel,883 APIRET rc = DosQueryPathInfo( ODINHelperStripUNC(pszPathName), ulInfoLevel, 861 884 pInfoBuf, cbInfoBuf ); 862 885 … … 888 911 ULONG openFlag = 0; 889 912 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); 891 916 892 917 //TODO: lpSecurityAttributes (inheritance) … … 980 1005 #endif 981 1006 982 if(strlen(lpszFile ) == 2 && lpszFile[1] == ':') {1007 if(strlen(lpszFileLoc) == 2 && lpszFileLoc[1] == ':') { 983 1008 //app tries to open logical volume/partition 984 1009 openMode |= OPEN_FLAGS_DASD; 985 1010 } 1011 986 1012 int retry = 0; 987 1013 while (retry < 3) 988 1014 { 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, 991 1017 &hFile, 992 1018 &actionTaken, … … 1048 1074 // @@@AH 2001-06-02 Win2k SP2 returns error 2 in this case 1049 1075 int winError = error2WinError(rc); 1050 if (winError == ERROR_OPEN_FAILED_W )1076 if (winError == ERROR_OPEN_FAILED_W || winError == ERROR_PATH_NOT_FOUND_W) 1051 1077 { 1052 1078 //Windows returns ERROR_FILE_EXISTS if create new & file exists … … 1303 1329 break; 1304 1330 } 1305 1331 #if 0 1306 1332 // PH Note: for a negative 32-bit seek, the OS/2 64-bit version 1307 1333 // needs to be skipped. 1308 if( (f64BitIO) && (OffsetHigh) ) 1334 if( (f64BitIO) && (OffsetHigh) && 1335 (*OffsetHigh != 0xAAAAAAAA) && 1336 (*OffsetHigh != 0)) //workaround for flash10 video 1309 1337 { 1310 1338 offsetL.ulLo = OffsetLow; … … 1316 1344 newoffset = newoffsetL.ulLo; 1317 1345 } 1318 else rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset); 1346 else 1347 #endif 1348 rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset); 1319 1349 1320 1350 if(rc) … … 2235 2265 char lOemFileName[260]; 2236 2266 2237 CharToOemA( lpFileName, lOemFileName);2267 CharToOemA(ODINHelperStripUNC((char*)lpFileName), lOemFileName); 2238 2268 2239 2269 APIRET rc = DosFindFirst((PSZ)lOemFileName,&hDir,attrs,&result,sizeof(result),&searchCount,FIL_STANDARD); … … 2241 2271 //check root: skip "." and ".." (HPFS, not on FAT) 2242 2272 //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))) 2244 2274 { 2245 2275 while ((strcmp(result.achName,".") == 0) || … … 2294 2324 char lOemFileName[260]; 2295 2325 2296 CharToOemA( lpFileName, lOemFileName);2326 CharToOemA(ODINHelperStripUNC((char*)lpFileName), lOemFileName); 2297 2327 APIRET rc = DosFindFirst((PSZ)lOemFileName,&hDir,attrs,result,searchCount*sizeof(FILEFINDBUF3),&searchCount,FIL_STANDARD); 2298 2328 SetErrorMode(oldmode); … … 2386 2416 { 2387 2417 FILESTATUS3 statusBuf; 2388 char *lOemFileName;2418 char lOemFileName[CCHMAXPATH]; 2389 2419 char *lpszBackslash, *lpszColon; 2390 2420 APIRET rc; 2391 2421 2392 lOemFileName = (char *)malloc(strlen(lpFileName)+64); 2393 lOemFileName[0] = 0; 2422 //testestest 2423 if(strlen(lpFileName) > CCHMAXPATH) DebugInt3(); 2424 //testestset 2394 2425 2395 2426 //Convert file name from Windows to OS/2 codepage 2396 CharToOemA( lpFileName, lOemFileName);2427 CharToOemA(ODINHelperStripUNC(lpFileName), lOemFileName); 2397 2428 lpszBackslash = CharPrevA(lOemFileName, lOemFileName + strlen(lOemFileName)); 2398 2429 if(lpszBackslash) … … 2401 2432 { 2402 2433 lpszColon = CharPrevA(lOemFileName, lpszBackslash); 2403 if( strlen(lOemFileName) > 1 &&lpszColon && *lpszColon != ':')2434 if(lpszColon && *lpszColon != ':') 2404 2435 {//only rootdir is allowed to have terminating backslash 2405 2436 *lpszBackslash = 0; … … 2422 2453 rc = DosQueryPathInfo(lOemFileName, FIL_STANDARD, &statusBuf, sizeof(statusBuf)); 2423 2454 } 2424 free(lOemFileName);2425 2455 2426 2456 if(rc == NO_ERROR)
Note:
See TracChangeset
for help on using the changeset viewer.