Changeset 3167 for trunk/src/ole32/stg_stream.cpp
- Timestamp:
- Mar 19, 2000, 4:35:32 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/stg_stream.cpp
r1033 r3167 1 /* $Id: stg_stream.cpp,v 1. 1 1999-09-24 21:49:44davidr Exp $ */1 /* $Id: stg_stream.cpp,v 1.2 2000-03-19 15:33:07 davidr Exp $ */ 2 2 /* 3 3 * Compound Storage (32 bit version) … … 65 65 StgStreamImpl* StgStreamImpl_Construct( 66 66 StorageBaseImpl* parentStorage, 67 DWORD grfMode, 67 68 ULONG ownerProperty) 68 69 { … … 76 77 * Set-up the virtual function table and reference count. 77 78 */ 78 newStream->lpvtbl= &StgStreamImpl_Vtbl;79 ICOM_VTBL(newStream) = &StgStreamImpl_Vtbl; 79 80 newStream->ref = 0; 80 81 … … 86 87 IStorage_AddRef((IStorage*)newStream->parentStorage); 87 88 89 newStream->grfMode = grfMode; 88 90 newStream->ownerProperty = ownerProperty; 89 91 … … 431 433 *pcbWritten = 0; 432 434 435 /* 436 * Do we have permission to write to this stream? 437 */ 438 if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE))) 439 return STG_E_ACCESSDENIED; 440 433 441 if (cb == 0) 434 442 { … … 533 541 } 534 542 535 /* 536 * We don't support files with offsets of 64 bits. 537 */ 538 assert(dlibMove.HighPart == 0); 539 540 /* 541 * Check if we end-up before the beginning of the file. That should trigger an 542 * error. 543 */ 544 if ( (dlibMove.LowPart<0) && (plibNewPosition->LowPart < (ULONG)(-dlibMove.LowPart)) ) 545 { 543 #if SIZEOF_LONG_LONG >= 8 544 plibNewPosition->QuadPart += dlibMove.QuadPart; 545 #else 546 /* 547 * do some multiword arithmetic: 548 * treat HighPart as a signed value 549 * treat LowPart as unsigned 550 * NOTE: this stuff is two's complement specific! 551 */ 552 if (dlibMove.HighPart < 0) { /* dlibMove is < 0 */ 553 /* calculate the absolute value of dlibMove ... */ 554 dlibMove.HighPart = -dlibMove.HighPart; 555 dlibMove.LowPart ^= -1; 556 /* ... and subtract with carry */ 557 if (dlibMove.LowPart > plibNewPosition->LowPart) { 558 /* carry needed, This accounts for any underflows at [1]*/ 559 plibNewPosition->HighPart -= 1; 560 } 561 plibNewPosition->LowPart -= dlibMove.LowPart; /* [1] */ 562 plibNewPosition->HighPart -= dlibMove.HighPart; 563 } else { 564 /* add directly */ 565 int initialLowPart = plibNewPosition->LowPart; 566 plibNewPosition->LowPart += dlibMove.LowPart; 567 if((plibNewPosition->LowPart < initialLowPart) || 568 (plibNewPosition->LowPart < dlibMove.LowPart)) { 569 /* LowPart has rolled over => add the carry digit to HighPart */ 570 plibNewPosition->HighPart++; 571 } 572 plibNewPosition->HighPart += dlibMove.HighPart; 573 } 574 /* 575 * Check if we end-up before the beginning of the file. That should 576 * trigger an error. 577 */ 578 if (plibNewPosition->HighPart < 0) { 579 return STG_E_INVALIDPOINTER; 580 } 581 546 582 /* 547 * I don't know what error to send there. 583 * We currently don't support files with offsets of >32 bits. 584 * Note that we have checked for a negative offset already 548 585 */ 549 return E_FAIL; 550 } 551 552 /* 553 * Move the actual file pointer 554 * If the file pointer ends-up after the end of the stream, the next Write operation will 555 * make the file larger. This is how it is documented. 556 */ 557 plibNewPosition->LowPart += dlibMove.LowPart; 586 assert(plibNewPosition->HighPart <= 0); 587 588 #endif 589 590 /* 591 * tell the caller what we calculated 592 */ 558 593 This->currentPosition = *plibNewPosition; 559 594 … … 587 622 return STG_E_INVALIDFUNCTION; 588 623 624 /* 625 * Do we have permission? 626 */ 627 if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE))) 628 return STG_E_ACCESSDENIED; 629 589 630 if (This->streamSize.LowPart == libNewSize.LowPart) 590 631 return S_OK; … … 828 869 grfStatFlag); 829 870 871 pstatstg->grfMode = This->grfMode; 872 830 873 return S_OK; 831 874 }
Note:
See TracChangeset
for help on using the changeset viewer.