Changeset 111 for trunk/src/kernel32/Fileio.cpp
- Timestamp:
- Jun 17, 1999, 8:22:43 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/Fileio.cpp
r100 r111 1 /* $Id: Fileio.cpp,v 1. 5 1999-06-10 20:47:58phaller Exp $ */1 /* $Id: Fileio.cpp,v 1.6 1999-06-17 18:21:42 phaller Exp $ */ 2 2 3 3 /* … … 31 31 { 32 32 HANDLE rc; 33 HANDLE hFile;34 35 if(lpszName == NULL)36 return(NULL);37 38 dprintf(("KERNEL32: CreateFile %s\n", lpszName));39 40 if(strncmp(lpszName,41 "\\\\.\\",42 4) == 0)43 {44 return(OS2CreateFile((char *)&lpszName[4],45 fdwAccess,46 fdwShareMode));47 }48 33 49 34 dprintf(("KERNEL32: CreateFileA(%s,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n", … … 56 41 hTemplateFile)); 57 42 58 rc = O32_CreateFile(lpszName,59 fdwAccess,60 fdwShareMode,61 lpsa,62 fdwCreate,63 fdwAttrsAndFlags,64 hTemplateFile);65 66 /* @@@PH 1998/02/12 Handle Manager support */67 if (rc == -1)68 43 rc = HMCreateFile(lpszName, 69 44 fdwAccess, … … 74 49 hTemplateFile); 75 50 76 /* @@@PH experimental Handlemanager support */77 if (HMHandleAllocate(&hFile,78 rc) == NO_ERROR)79 rc = hFile;80 81 dprintf(("KERNEL32: CreateFile returned %08xh\n",82 rc));83 84 51 return(rc); 85 52 } … … 151 118 //****************************************************************************** 152 119 //****************************************************************************** 153 DWORD WIN32API GetFileType(HANDLE file) 154 { 155 DWORD rc; 156 HFILE hFile; 157 158 /* @@@PH 1998/02/12 Handle Manager support */ 159 if (IS_HM_HANDLE(file)) 160 return (HMGetFileType(file)); 161 162 /* @@@PH experimental Handlemanager support */ 163 if (HMHandleTranslateToOS2(file, 164 &hFile) == NO_ERROR) 165 file = hFile; 166 167 dprintf(("KERNEL32: GetFileType %08xh\n", 168 file)); 169 170 rc = O32_GetFileType(file); 171 if(rc == 0) 172 { 173 //bugfix 174 rc = 1; 175 } 176 177 dprintf(("KERNEL32: GetFileType returned %08xh\n", 178 rc)); 179 180 return(rc); 120 DWORD WIN32API GetFileType(HANDLE hFile) 121 { 122 dprintf(("KERNEL32: GetFileType(%08xh)\n", 123 hFile)); 124 125 return(HMGetFileType(hFile)); 181 126 } 182 127 //****************************************************************************** … … 185 130 BY_HANDLE_FILE_INFORMATION *arg2) 186 131 { 187 DWORD rc; 188 HFILE hFile; 189 190 /* @@@PH experimental Handlemanager support */ 191 if (HMHandleTranslateToOS2(arg1, 192 &hFile) == NO_ERROR) 193 arg1 = hFile; 194 195 196 rc = O32_GetFileInformationByHandle(arg1, 197 arg2); 198 199 dprintf(("KERNEL32: GetFileInformationByHandle (%08xh) returned %08xh\n", 132 dprintf(("KERNEL32: GetFIleInformationByHandle(%08xh,%0xh)\n", 200 133 arg1, 201 rc)); 202 203 /* @@@PH irrelevant 204 if(rc == 0) 205 { 206 //might be converted _lopen handle, so go get it 207 // arg1 = ConvertHandle(arg1); 208 rc = O32_GetFileInformationByHandle(arg1, arg2); 209 dprintf(("KERNEL32: GetFileInformationByHandle (%X) returned %d\n", arg1, rc)); 210 } 211 */ 212 213 return(rc); 134 arg2)); 135 136 return(HMGetFileInformationByHandle(arg1,arg2)); 214 137 } 215 138 //****************************************************************************** … … 217 140 BOOL WIN32API SetEndOfFile( HANDLE arg1) 218 141 { 219 HFILE hFile;220 221 /* @@@PH experimental Handlemanager support */222 if (HMHandleTranslateToOS2(arg1,223 &hFile) == NO_ERROR)224 arg1 = hFile;225 226 142 dprintf(("KERNEL32: SetEndOfFile(%08xh)\n", 227 143 arg1)); 228 144 229 return O32_SetEndOfFile(arg1);145 return HMSetEndOfFile(arg1); 230 146 } 231 147 //****************************************************************************** … … 236 152 const FILETIME *arg4) 237 153 { 238 HFILE hFile;239 240 /* @@@PH experimental Handlemanager support */241 if (HMHandleTranslateToOS2(arg1,242 &hFile) == NO_ERROR)243 arg1 = hFile;244 245 154 dprintf(("KERNEL32: SetFileTime(%08xh,%08xh,%08xh,%08xh)\n", 246 155 arg1, … … 249 158 arg4)); 250 159 251 return O32_SetFileTime(arg1,252 253 254 160 return HMSetFileTime(arg1, 161 arg2, 162 arg3, 163 arg4); 255 164 } 256 165 //****************************************************************************** … … 288 197 DWORD WIN32API GetFileSize( HANDLE arg1, PDWORD arg2) 289 198 { 290 HFILE hFile;291 292 /* @@@PH experimental Handlemanager support */293 if (HMHandleTranslateToOS2(arg1,294 &hFile) == NO_ERROR)295 arg1 = hFile;296 297 199 dprintf(("KERNEL32: GetFileSize (%08xh, %08xh)\n", 298 200 arg1, 299 201 arg2)); 300 202 301 return O32_GetFileSize(arg1,302 203 return HMGetFileSize(arg1, 204 arg2); 303 205 } 304 206 //****************************************************************************** … … 377 279 { 378 280 BOOL rc; 379 HFILE hFile; 380 381 /* @@@PH 1998/02/12 Handle Manager support */ 382 if (IS_HM_HANDLE(arg1)) 383 return (HMReadFile(arg1, arg2, arg3, arg4, arg5)); 384 385 /* @@@PH 1999/06/09 Handle Manager support */ 386 387 /* @@@PH experimental Handlemanager support */ 388 if (HMHandleTranslateToOS2(arg1, 389 &hFile) == NO_ERROR) 390 arg1 = hFile; 391 392 rc = O32_ReadFile(arg1, 393 arg2, 394 arg3, 395 arg4, 396 arg5); 281 282 rc = HMReadFile(arg1, 283 arg2, 284 arg3, 285 arg4, 286 arg5); 397 287 398 288 dprintf(("KERNEL32: ReadFile %X %d bytes returned %d\n", … … 410 300 DWORD dwMoveMethod) 411 301 { 412 HANDLE hFile2; 413 414 // dprintf(("KERNEL32: SetFilePointer\n")); 415 416 /* @@@PH experimental Handlemanager support */ 417 if (HMHandleTranslateToOS2(hFile, 418 &hFile2) == NO_ERROR) 419 hFile = hFile2; 420 421 return(O32_SetFilePointer(hFile, 422 lDistanceToMove, 423 lpDistanceToMoveHigh, 424 dwMoveMethod)); 302 dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n", 303 hFile, 304 lDistanceToMove, 305 lpDistanceToMoveHigh, 306 dwMoveMethod)); 307 308 return(HMSetFilePointer(hFile, 309 lDistanceToMove, 310 lpDistanceToMoveHigh, 311 dwMoveMethod)); 425 312 } 426 313 //****************************************************************************** 427 314 //****************************************************************************** 428 315 BOOL WIN32API WriteFile(HANDLE hFile, 429 LPCVOID buffer, 430 DWORD nrbytes, 431 LPDWORD nrbyteswritten, 432 LPOVERLAPPED lpOverlapped) 433 { 434 BOOL rc; 435 HANDLE hFile2; 436 437 //@@@PH translate handle 438 //KSO Aug 31 1998: when writing 0 bytes to a file win32 sets eof here. 439 if (nrbytes == 0 && !IS_HM_HANDLE(hFile)) 440 { 441 *nrbyteswritten = 0; 442 return O32_SetEndOfFile(hFile); 443 } 444 445 /* @@@PH 1998/02/12 Handle Manager support */ 446 if (IS_HM_HANDLE(hFile)) 447 return (HMWriteFile(hFile, 448 buffer, 449 nrbytes, 450 nrbyteswritten, 451 lpOverlapped)); 452 453 /* @@@PH experimental Handlemanager support */ 454 if (HMHandleTranslateToOS2(hFile, 455 &hFile2) == NO_ERROR) 456 hFile = hFile2; 457 458 459 rc = O32_WriteFile(hFile, buffer, nrbytes, nrbyteswritten, (LPOVERLAPPED)lpOverlapped); 460 if(rc == 0 && GetLastError() == 436) { //ERROR_VIO_INVALID_HANDLE (OS/2) 461 //// dprintf(("KERNEL32: WriteFile %s\n", buffer)); 462 return(TRUE); 463 } 464 dprintf(("KERNEL32: WriteFile handle = %X, %d bytes, returned %d (%X)\n", hFile, nrbytes, rc, GetLastError())); 465 return(rc); 316 LPCVOID buffer, 317 DWORD nrbytes, 318 LPDWORD nrbyteswritten, 319 LPOVERLAPPED lpOverlapped) 320 { 321 dprintf(("KERNEL32: WriteFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n", 322 hFile, 323 buffer, 324 nrbytes, 325 nrbyteswritten, 326 lpOverlapped)); 327 328 return (HMWriteFile(hFile, 329 buffer, 330 nrbytes, 331 nrbyteswritten, 332 lpOverlapped)); 466 333 } 467 334 //****************************************************************************** … … 586 453 DWORD arg5) 587 454 { 588 HFILE hFile;589 590 /* @@@PH experimental Handlemanager support */591 if (HMHandleTranslateToOS2(arg1,592 &hFile) == NO_ERROR)593 arg1 = hFile;594 595 455 dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n", 596 456 arg1, … … 600 460 arg5)); 601 461 602 return O32_LockFile(arg1,603 604 605 606 462 return HMLockFile(arg1, 463 arg2, 464 arg3, 465 arg4, 466 arg5); 607 467 } 608 468 … … 630 490 DWORD nNumberOfBytesToLockLow, 631 491 DWORD nNumberOfBytesToLockHigh, 632 LPOVERLAPPED LPOVERLAPPED) 633 { 634 HFILE hFile2; 635 636 /* @@@PH experimental Handlemanager support */ 637 if (HMHandleTranslateToOS2(hFile, 638 &hFile2) == NO_ERROR) 639 hFile = hFile2; 640 492 LPOVERLAPPED lpOverlapped) 493 { 641 494 dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n", 642 495 hFile, … … 645 498 nNumberOfBytesToLockLow, 646 499 nNumberOfBytesToLockHigh, 647 LPOVERLAPPED));648 649 return( O32_LockFile(hFile,650 LPOVERLAPPED->Offset,651 LPOVERLAPPED->OffsetHigh,652 nNumberOfBytesToLockLow,653 nNumberOfBytesToLockHigh));500 lpOverlapped)); 501 502 return(HMLockFile(hFile, 503 lpOverlapped->Offset, 504 lpOverlapped->OffsetHigh, 505 nNumberOfBytesToLockLow, 506 nNumberOfBytesToLockHigh)); 654 507 } 655 508 … … 715 568 { 716 569 HFILE hFile; 717 ULONG ulWindowsHandle; /* translated windows handle */718 570 719 571 dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n", … … 722 574 arg3)); 723 575 724 hFile = O32_OpenFile(arg1, /* call open32 */ 725 arg2, 726 arg3); 727 728 /* @@@PH 1999/06/09 HandleManager support temporarily disabled */ 729 if (hFile != 0) /* check if handle is valid */ 730 { 731 if (HMHandleAllocate(&ulWindowsHandle, /* allocate translation handle */ 732 hFile) == NO_ERROR) 733 return (ulWindowsHandle); 734 } 576 hFile = HMOpenFile(arg1, /* call open32 */ 577 arg2, 578 arg3); 735 579 736 580 return (hFile); … … 744 588 DWORD arg5) 745 589 { 746 HFILE hFile2;747 748 /* @@@PH experimental Handlemanager support */749 if (HMHandleTranslateToOS2(arg1,750 &hFile2) == NO_ERROR)751 arg1 = hFile2;752 753 590 dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n", 754 591 arg1, … … 758 595 arg5)); 759 596 760 return O32_UnlockFile(arg1,761 762 763 764 597 return HMUnlockFile(arg1, 598 arg2, 599 arg3, 600 arg4, 601 arg5); 765 602 } 766 603 … … 786 623 DWORD nNumberOfBytesToLockLow, 787 624 DWORD nNumberOfBytesToLockHigh, 788 LPOVERLAPPED LPOVERLAPPED) 789 { 790 HFILE hFile2; 791 792 /* @@@PH experimental Handlemanager support */ 793 if (HMHandleTranslateToOS2(hFile, 794 &hFile2) == NO_ERROR) 795 hFile = hFile2; 796 625 LPOVERLAPPED lpOverlapped) 626 { 797 627 dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n", 798 628 hFile, … … 800 630 nNumberOfBytesToLockLow, 801 631 nNumberOfBytesToLockHigh, 802 LPOVERLAPPED));803 804 return( O32_UnlockFile(hFile,805 LPOVERLAPPED->Offset,806 LPOVERLAPPED->OffsetHigh,807 nNumberOfBytesToLockLow,808 nNumberOfBytesToLockHigh));632 lpOverlapped)); 633 634 return(HMUnlockFile(hFile, 635 lpOverlapped->Offset, 636 lpOverlapped->OffsetHigh, 637 nNumberOfBytesToLockLow, 638 nNumberOfBytesToLockHigh)); 809 639 } 810 640 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.