diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/7zip/Common/MultiOutStream.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/CPP/7zip/Common/MultiOutStream.cpp b/CPP/7zip/Common/MultiOutStream.cpp index 8efb977..1954311 100644 --- a/CPP/7zip/Common/MultiOutStream.cpp +++ b/CPP/7zip/Common/MultiOutStream.cpp | |||
@@ -183,7 +183,7 @@ bool CMultiOutStream::IsRestricted_for_Close(unsigned index) const | |||
183 | FString CMultiOutStream::GetFilePath(unsigned index) | 183 | FString CMultiOutStream::GetFilePath(unsigned index) |
184 | { | 184 | { |
185 | FString name; | 185 | FString name; |
186 | name.Add_UInt32(index + 1); | 186 | name.Add_UInt32((UInt32)(index + 1)); |
187 | while (name.Len() < 3) | 187 | while (name.Len() < 3) |
188 | name.InsertAtFront(FTEXT('0')); | 188 | name.InsertAtFront(FTEXT('0')); |
189 | name.Insert(0, Prefix); | 189 | name.Insert(0, Prefix); |
@@ -209,7 +209,7 @@ HRESULT CMultiOutStream::CloseStream(unsigned index) | |||
209 | // we close stream and delete file, but we still keep item in Streams[] vector | 209 | // we close stream and delete file, but we still keep item in Streams[] vector |
210 | HRESULT CMultiOutStream::CloseStream_and_DeleteFile(unsigned index) | 210 | HRESULT CMultiOutStream::CloseStream_and_DeleteFile(unsigned index) |
211 | { | 211 | { |
212 | PRF(printf("\n====== %u, CloseStream_AndDelete \n", index)); | 212 | PRF(printf("\n====== %u, CloseStream_AndDelete \n", index)) |
213 | RINOK(CloseStream(index)) | 213 | RINOK(CloseStream(index)) |
214 | FString path = GetFilePath(index); | 214 | FString path = GetFilePath(index); |
215 | path += Streams[index].Postfix; | 215 | path += Streams[index].Postfix; |
@@ -223,7 +223,7 @@ HRESULT CMultiOutStream::CloseStream_and_DeleteFile(unsigned index) | |||
223 | 223 | ||
224 | HRESULT CMultiOutStream::CloseStream_and_FinalRename(unsigned index) | 224 | HRESULT CMultiOutStream::CloseStream_and_FinalRename(unsigned index) |
225 | { | 225 | { |
226 | PRF(printf("\n====== %u, CloseStream_and_FinalRename \n", index)); | 226 | PRF(printf("\n====== %u, CloseStream_and_FinalRename \n", index)) |
227 | CVolStream &s = Streams[index]; | 227 | CVolStream &s = Streams[index]; |
228 | // HRESULT res = S_OK; | 228 | // HRESULT res = S_OK; |
229 | bool mtime_WasSet = false; | 229 | bool mtime_WasSet = false; |
@@ -261,6 +261,8 @@ HRESULT CMultiOutStream::CloseStream_and_FinalRename(unsigned index) | |||
261 | 261 | ||
262 | HRESULT CMultiOutStream::PrepareToOpenNew() | 262 | HRESULT CMultiOutStream::PrepareToOpenNew() |
263 | { | 263 | { |
264 | PRF(printf("PrepareToOpenNew NumListItems =%u, NumOpenFiles_AllowedMax = %u \n", NumListItems, NumOpenFiles_AllowedMax)) | ||
265 | |||
264 | if (NumListItems < NumOpenFiles_AllowedMax) | 266 | if (NumListItems < NumOpenFiles_AllowedMax) |
265 | return S_OK; | 267 | return S_OK; |
266 | /* when we create zip archive: in most cases we need only starting | 268 | /* when we create zip archive: in most cases we need only starting |
@@ -270,7 +272,7 @@ HRESULT CMultiOutStream::PrepareToOpenNew() | |||
270 | const int index = Head; | 272 | const int index = Head; |
271 | if (index == -1) | 273 | if (index == -1) |
272 | return E_FAIL; | 274 | return E_FAIL; |
273 | PRF(printf("\n== %u, PrepareToOpenNew::CloseStream, NumListItems =%u \n", index, NumListItems)); | 275 | PRF(printf("\n== %u, PrepareToOpenNew::CloseStream, NumListItems =%u \n", index, NumListItems)) |
274 | /* we don't expect non-restricted stream here in normal cases (if _restrict_Global was not changed). | 276 | /* we don't expect non-restricted stream here in normal cases (if _restrict_Global was not changed). |
275 | if there was non-restricted stream, it should be closed before */ | 277 | if there was non-restricted stream, it should be closed before */ |
276 | // if (!IsRestricted_for_Close(index)) return CloseStream_and_FinalRename(index); | 278 | // if (!IsRestricted_for_Close(index)) return CloseStream_and_FinalRename(index); |
@@ -280,7 +282,7 @@ HRESULT CMultiOutStream::PrepareToOpenNew() | |||
280 | 282 | ||
281 | HRESULT CMultiOutStream::CreateNewStream(UInt64 newSize) | 283 | HRESULT CMultiOutStream::CreateNewStream(UInt64 newSize) |
282 | { | 284 | { |
283 | PRF(printf("\n== %u, CreateNewStream, size =%u \n", Streams.Size(), (unsigned)newSize)); | 285 | PRF(printf("\n== %u, CreateNewStream, size =%u \n", Streams.Size(), (unsigned)newSize)) |
284 | 286 | ||
285 | if (Streams.Size() >= k_NumVols_MAX) | 287 | if (Streams.Size() >= k_NumVols_MAX) |
286 | return E_INVALIDARG; // E_OUTOFMEMORY | 288 | return E_INVALIDARG; // E_OUTOFMEMORY |
@@ -358,7 +360,7 @@ HRESULT CMultiOutStream::CreateStreams_If_Required(unsigned streamIndex) | |||
358 | 360 | ||
359 | HRESULT CMultiOutStream::ReOpenStream(unsigned streamIndex) | 361 | HRESULT CMultiOutStream::ReOpenStream(unsigned streamIndex) |
360 | { | 362 | { |
361 | PRF(printf("\n====== %u, ReOpenStream \n", streamIndex)); | 363 | PRF(printf("\n====== %u, ReOpenStream \n", streamIndex)) |
362 | RINOK(PrepareToOpenNew()) | 364 | RINOK(PrepareToOpenNew()) |
363 | CVolStream &s = Streams[streamIndex]; | 365 | CVolStream &s = Streams[streamIndex]; |
364 | 366 | ||
@@ -370,7 +372,7 @@ HRESULT CMultiOutStream::ReOpenStream(unsigned streamIndex) | |||
370 | s.Pos = 0; | 372 | s.Pos = 0; |
371 | 373 | ||
372 | HRESULT hres; | 374 | HRESULT hres; |
373 | if (s.StreamSpec->Open(path, OPEN_EXISTING)) | 375 | if (s.StreamSpec->Open_EXISTING(path)) |
374 | { | 376 | { |
375 | if (s.Postfix.IsEmpty()) | 377 | if (s.Postfix.IsEmpty()) |
376 | { | 378 | { |
@@ -384,6 +386,7 @@ HRESULT CMultiOutStream::ReOpenStream(unsigned streamIndex) | |||
384 | { | 386 | { |
385 | if (realSize == s.RealSize) | 387 | if (realSize == s.RealSize) |
386 | { | 388 | { |
389 | PRF(printf("\n ReOpenStream OK realSize = %u\n", (unsigned)realSize)) | ||
387 | InsertToLinkedList(streamIndex); | 390 | InsertToLinkedList(streamIndex); |
388 | return S_OK; | 391 | return S_OK; |
389 | } | 392 | } |
@@ -412,7 +415,7 @@ HRESULT CMultiOutStream::OptReOpen_and_SetSize(unsigned index, UInt64 size) | |||
412 | { | 415 | { |
413 | RINOK(ReOpenStream(index)) | 416 | RINOK(ReOpenStream(index)) |
414 | } | 417 | } |
415 | PRF(printf("\n== %u, OptReOpen_and_SetSize, size =%u RealSize = %u\n", index, (unsigned)size, (unsigned)s.RealSize)); | 418 | PRF(printf("\n== %u, OptReOpen_and_SetSize, size =%u RealSize = %u\n", index, (unsigned)size, (unsigned)s.RealSize)) |
416 | // comment it to debug tail after data | 419 | // comment it to debug tail after data |
417 | return s.SetSize2(size); | 420 | return s.SetSize2(size); |
418 | } | 421 | } |
@@ -440,7 +443,7 @@ Note: we don't remove zero sized first volume, if (_length == 0) | |||
440 | 443 | ||
441 | HRESULT CMultiOutStream::Normalize_finalMode(bool finalMode) | 444 | HRESULT CMultiOutStream::Normalize_finalMode(bool finalMode) |
442 | { | 445 | { |
443 | PRF(printf("\n== Normalize_finalMode: _length =%d \n", (unsigned)_length)); | 446 | PRF(printf("\n== Normalize_finalMode: _length =%d \n", (unsigned)_length)) |
444 | 447 | ||
445 | unsigned i = Streams.Size(); | 448 | unsigned i = Streams.Size(); |
446 | 449 | ||
@@ -579,7 +582,7 @@ Z7_COM7F_IMF(CMultiOutStream::SetSize(UInt64 newSize)) | |||
579 | else if (newSize < _restrict_Global) | 582 | else if (newSize < _restrict_Global) |
580 | _restrict_Global = newSize; | 583 | _restrict_Global = newSize; |
581 | 584 | ||
582 | PRF(printf("\n== SetSize, size =%u \n", (unsigned)newSize)); | 585 | PRF(printf("\n== CMultiOutStream::SetSize, size =%u \n", (unsigned)newSize)) |
583 | 586 | ||
584 | _length = newSize; | 587 | _length = newSize; |
585 | return Normalize_finalMode(false); | 588 | return Normalize_finalMode(false); |
@@ -596,6 +599,9 @@ Z7_COM7F_IMF(CMultiOutStream::Write(const void *data, UInt32 size, UInt32 *proce | |||
596 | if (size == 0) | 599 | if (size == 0) |
597 | return S_OK; | 600 | return S_OK; |
598 | 601 | ||
602 | PRF(printf("\n -- CMultiOutStream::Write() : _absPos = %6u, size =%6u \n", | ||
603 | (unsigned)_absPos, (unsigned)size)) | ||
604 | |||
599 | if (_absPos > _length) | 605 | if (_absPos > _length) |
600 | { | 606 | { |
601 | // it create data only up to _absPos. | 607 | // it create data only up to _absPos. |
@@ -648,7 +654,7 @@ Z7_COM7F_IMF(CMultiOutStream::Write(const void *data, UInt32 size, UInt32 *proce | |||
648 | CVolStream &s = Streams[_streamIndex]; | 654 | CVolStream &s = Streams[_streamIndex]; |
649 | 655 | ||
650 | PRF(printf("\n%d, == Write : Pos = %u, RealSize = %u size =%u \n", | 656 | PRF(printf("\n%d, == Write : Pos = %u, RealSize = %u size =%u \n", |
651 | _streamIndex, (unsigned)s.Pos, (unsigned)s.RealSize, size)); | 657 | _streamIndex, (unsigned)s.Pos, (unsigned)s.RealSize, size)) |
652 | 658 | ||
653 | if (!s.Stream) | 659 | if (!s.Stream) |
654 | { | 660 | { |
@@ -712,7 +718,7 @@ Z7_COM7F_IMF(CMultiOutStream::Write(const void *data, UInt32 size, UInt32 *proce | |||
712 | 718 | ||
713 | Z7_COM7F_IMF(CMultiOutStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)) | 719 | Z7_COM7F_IMF(CMultiOutStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)) |
714 | { | 720 | { |
715 | PRF(printf("\n-- Seek seekOrigin=%u Seek =%u\n", seekOrigin, (unsigned)offset)); | 721 | PRF(printf("\n-- CMultiOutStream::Seek seekOrigin=%u Seek =%u\n", seekOrigin, (unsigned)offset)) |
716 | 722 | ||
717 | switch (seekOrigin) | 723 | switch (seekOrigin) |
718 | { | 724 | { |
@@ -753,7 +759,7 @@ unsigned CMultiOutStream::GetStreamIndex_for_Offset(UInt64 offset, UInt64 &relOf | |||
753 | const UInt64 size = Sizes[last]; | 759 | const UInt64 size = Sizes[last]; |
754 | const UInt64 v = offset / size; | 760 | const UInt64 v = offset / size; |
755 | if (v >= ((UInt32)(Int32)-1) - last) | 761 | if (v >= ((UInt32)(Int32)-1) - last) |
756 | return (UInt32)(Int32)-1; // saturation | 762 | return (unsigned)(int)-1; // saturation |
757 | relOffset = offset - (unsigned)v * size; | 763 | relOffset = offset - (unsigned)v * size; |
758 | return last + (unsigned)(v); | 764 | return last + (unsigned)(v); |
759 | } | 765 | } |
@@ -765,7 +771,7 @@ Z7_COM7F_IMF(CMultiOutStream::SetRestriction(UInt64 begin, UInt64 end)) | |||
765 | 771 | ||
766 | // begin = end = 0; // for debug | 772 | // begin = end = 0; // for debug |
767 | 773 | ||
768 | PRF(printf("\n==================== CMultiOutStream::SetRestriction %u, %u\n", (unsigned)begin, (unsigned)end)); | 774 | PRF(printf("\n==================== CMultiOutStream::SetRestriction %u, %u\n", (unsigned)begin, (unsigned)end)) |
769 | if (begin > end) | 775 | if (begin > end) |
770 | { | 776 | { |
771 | // these value are FAILED values. | 777 | // these value are FAILED values. |