 |
Changeset 3200
- Timestamp:
- 02/16/08 06:38:41
(7 months ago)
- Author:
- DRK
- Message:
This should clean up the warnings from core.Variant, io.archive.Zip, io.TempFile? and io.vfs.ZipFolder?. However, there are still two warnings in io.archive.Zip which do not give file or line numbers. I'll keep trying to track them down. Refs #919.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3196 |
r3200 |
|
| 431 | 431 | } |
|---|
| 432 | 432 | } |
|---|
| 433 | | assert(false); |
|---|
| 434 | 433 | } |
|---|
| 435 | 434 | |
|---|
| r3197 |
r3200 |
|
| 548 | 548 | long seek(long offset, Seek.Anchor anchor = Seek.Anchor.Begin) |
|---|
| 549 | 549 | { |
|---|
| 550 | | long result = lseek(handle, offset, anchor); |
|---|
| | 550 | assert( offset <= int.sizeof ); |
|---|
| | 551 | long result = lseek(handle, cast(int) offset, anchor); |
|---|
| 551 | 552 | if (result is -1) |
|---|
| 552 | 553 | error(); |
|---|
| r3185 |
r3200 |
|
| 130 | 130 | // Update lengths in data |
|---|
| 131 | 131 | Data data = this.data; |
|---|
| 132 | | data.file_name_length = file_name.length; |
|---|
| 133 | | data.extra_field_length = extra_field.length; |
|---|
| | 132 | data.file_name_length = cast(ushort) file_name.length; |
|---|
| | 133 | data.extra_field_length = cast(ushort) extra_field.length; |
|---|
| 134 | 134 | |
|---|
| 135 | 135 | // Do it |
|---|
| … | … | |
| 315 | 315 | // Update the lengths |
|---|
| 316 | 316 | Data data = *(this.data); |
|---|
| 317 | | data.file_name_length = file_name.length; |
|---|
| 318 | | data.extra_field_length = extra_field.length; |
|---|
| 319 | | data.file_comment_length = file_comment.length; |
|---|
| | 317 | data.file_name_length = cast(ushort) file_name.length; |
|---|
| | 318 | data.extra_field_length = cast(ushort) extra_field.length; |
|---|
| | 319 | data.file_comment_length = cast(ushort) file_comment.length; |
|---|
| 320 | 320 | |
|---|
| 321 | 321 | // Ok; let's do this! |
|---|
| … | … | |
| 426 | 426 | // Set up data block |
|---|
| 427 | 427 | Data data = this.data; |
|---|
| 428 | | data.file_comment_length = file_comment.length; |
|---|
| | 428 | data.file_comment_length = cast(ushort) file_comment.length; |
|---|
| 429 | 429 | |
|---|
| 430 | 430 | version( BigEndian ) swapAll(data); |
|---|
| … | … | |
| 494 | 494 | default: return Method.Unsupported; |
|---|
| 495 | 495 | } |
|---|
| | 496 | |
|---|
| | 497 | assert(false); |
|---|
| 496 | 498 | } |
|---|
| 497 | 499 | |
|---|
| … | … | |
| 505 | 507 | assert(false, "unsupported compression method"); |
|---|
| 506 | 508 | } |
|---|
| | 509 | |
|---|
| | 510 | assert(false); |
|---|
| 507 | 511 | } |
|---|
| 508 | 512 | |
|---|
| … | … | |
| 666 | 670 | case State.Done: |
|---|
| 667 | 671 | return false; |
|---|
| | 672 | |
|---|
| | 673 | default: |
|---|
| | 674 | assert(false); |
|---|
| 668 | 675 | } |
|---|
| | 676 | |
|---|
| | 677 | assert(false); |
|---|
| 669 | 678 | } |
|---|
| 670 | 679 | |
|---|
| … | … | |
| 796 | 805 | |
|---|
| 797 | 806 | auto used = header.map(cd_data[4..$]); |
|---|
| 798 | | cd_data = cd_data[4+used..$]; |
|---|
| | 807 | assert( used <= (size_t.max-4) ); |
|---|
| | 808 | cd_data = cd_data[4+cast(size_t)used..$]; |
|---|
| 799 | 809 | |
|---|
| 800 | 810 | // Update offset for next record |
|---|
| … | … | |
| 836 | 846 | |
|---|
| 837 | 847 | auto file_len = seeker.seek(0, IConduit.Seek.Anchor.End); |
|---|
| | 848 | assert( file_len <= size_t.max ); |
|---|
| 838 | 849 | |
|---|
| 839 | 850 | // We're going to need min(max_chunk_len, file_len) bytes. |
|---|
| 840 | | long chunk_len = max_chunk_len; |
|---|
| | 851 | size_t chunk_len = max_chunk_len; |
|---|
| 841 | 852 | if( file_len < max_chunk_len ) |
|---|
| 842 | | chunk_len = file_len; |
|---|
| | 853 | chunk_len = cast(size_t) file_len; |
|---|
| 843 | 854 | //Stderr.formatln(" . chunk_len = {}", chunk_len); |
|---|
| 844 | 855 | |
|---|
| 845 | 856 | // Seek back and read in the chunk. Don't forget to clean up after |
|---|
| 846 | 857 | // ourselves. |
|---|
| 847 | | seeker.seek(-chunk_len, IConduit.Seek.Anchor.End); |
|---|
| | 858 | seeker.seek(-cast(long)chunk_len, IConduit.Seek.Anchor.End); |
|---|
| 848 | 859 | auto chunk_offset = seeker.seek(0, IConduit.Seek.Anchor.Current); |
|---|
| 849 | 860 | //Stderr.formatln(" . chunk_offset = {}", chunk_offset); |
|---|
| … | … | |
| 860 | 871 | size_t eocd_loc = -1; |
|---|
| 861 | 872 | |
|---|
| 862 | | for( size_t i=chunk_len-18; i>=0; --i ) |
|---|
| 863 | | { |
|---|
| 864 | | if( *(cast(uint*)(chunk.ptr+i)) == eocd_magic ) |
|---|
| | 873 | if( chunk_len >= 18 ) |
|---|
| | 874 | for( size_t i=chunk_len-18; i>=0; --i ) |
|---|
| 865 | 875 | { |
|---|
| 866 | | // Found the bugger! Make sure we skip the signature (forgot |
|---|
| 867 | | // to do that originally; talk about weird errors :P) |
|---|
| 868 | | eocd_loc = i+4; |
|---|
| 869 | | break; |
|---|
| | 876 | if( *(cast(uint*)(chunk.ptr+i)) == eocd_magic ) |
|---|
| | 877 | { |
|---|
| | 878 | // Found the bugger! Make sure we skip the signature (forgot |
|---|
| | 879 | // to do that originally; talk about weird errors :P) |
|---|
| | 880 | eocd_loc = i+4; |
|---|
| | 881 | break; |
|---|
| | 882 | } |
|---|
| 870 | 883 | } |
|---|
| 871 | | } |
|---|
| 872 | 884 | |
|---|
| 873 | 885 | // If we didn't find it, then we'll assume that this is not a valid |
|---|
| … | … | |
| 1121 | 1133 | |
|---|
| 1122 | 1134 | { |
|---|
| | 1135 | assert( entries.length < ushort.max ); |
|---|
| | 1136 | assert( cd_len < uint.max ); |
|---|
| | 1137 | assert( cd_pos < uint.max ); |
|---|
| | 1138 | |
|---|
| 1123 | 1139 | EndOfCDRecord eocdr; |
|---|
| 1124 | 1140 | eocdr.data.central_directory_entries_on_this_disk = |
|---|
| 1125 | | entries.length; |
|---|
| 1126 | | eocdr.data.central_directory_entries_total = entries.length; |
|---|
| 1127 | | eocdr.data.size_of_central_directory = cd_len; |
|---|
| 1128 | | eocdr.data.offset_of_start_of_cd_from_starting_disk = cd_pos; |
|---|
| | 1141 | cast(ushort) entries.length; |
|---|
| | 1142 | eocdr.data.central_directory_entries_total = |
|---|
| | 1143 | cast(ushort) entries.length; |
|---|
| | 1144 | eocdr.data.size_of_central_directory = |
|---|
| | 1145 | cast(ushort) cd_len; |
|---|
| | 1146 | eocdr.data.offset_of_start_of_cd_from_starting_disk = |
|---|
| | 1147 | cast(ushort) cd_pos; |
|---|
| 1129 | 1148 | |
|---|
| 1130 | 1149 | write(output, EndOfCDRecord.signature); |
|---|
| … | … | |
| 1186 | 1205 | scope in_counter = new CounterInput(in_chain); |
|---|
| 1187 | 1206 | in_chain = in_counter; |
|---|
| 1188 | | scope(success) uncompressed_size = in_counter.count; |
|---|
| | 1207 | assert( in_counter.count <= typeof(uncompressed_size).max ); |
|---|
| | 1208 | scope(success) uncompressed_size = cast(uint) in_counter.count; |
|---|
| 1189 | 1209 | |
|---|
| 1190 | 1210 | // Count the number of bytes going out to the archive |
|---|
| 1191 | 1211 | scope out_counter = new CounterOutput(out_chain); |
|---|
| 1192 | 1212 | out_chain = out_counter; |
|---|
| 1193 | | scope(success) compressed_size = out_counter.count; |
|---|
| | 1213 | assert( out_counter.count <= typeof(compressed_size).max ); |
|---|
| | 1214 | scope(success) compressed_size = cast(uint) out_counter.count; |
|---|
| 1194 | 1215 | |
|---|
| 1195 | 1216 | // Add crc |
|---|
| … | … | |
| 1217 | 1238 | out_chain = compress; |
|---|
| 1218 | 1239 | break; |
|---|
| | 1240 | |
|---|
| | 1241 | default: |
|---|
| | 1242 | assert(false); |
|---|
| 1219 | 1243 | } |
|---|
| 1220 | 1244 | |
|---|
| … | … | |
| 1317 | 1341 | case 0: minver(10); break; |
|---|
| 1318 | 1342 | case 8: minver(20); break; |
|---|
| | 1343 | default: |
|---|
| | 1344 | assert(false); |
|---|
| 1319 | 1345 | } |
|---|
| 1320 | 1346 | |
|---|
| … | … | |
| 1350 | 1376 | |
|---|
| 1351 | 1377 | // Save the header |
|---|
| | 1378 | assert( header_pos <= int.max ); |
|---|
| 1352 | 1379 | Entry entry; |
|---|
| 1353 | 1380 | entry.data.fromLocal(header.data); |
|---|
| 1354 | 1381 | entry.filename = file_name; |
|---|
| 1355 | 1382 | entry.header_position = header_pos; |
|---|
| 1356 | | entry.data.relative_offset_of_local_header = header_pos; |
|---|
| | 1383 | entry.data.relative_offset_of_local_header = cast(int) header_pos; |
|---|
| 1357 | 1384 | entries ~= entry; |
|---|
| 1358 | 1385 | } |
|---|
| … | … | |
| 1382 | 1409 | uint size() |
|---|
| 1383 | 1410 | { |
|---|
| 1384 | | return header.data.uncompressed_size;; |
|---|
| | 1411 | return header.data.uncompressed_size; |
|---|
| 1385 | 1412 | } |
|---|
| 1386 | 1413 | |
|---|
| … | … | |
| 2230 | 2257 | |
|---|
| 2231 | 2258 | auto span = time.span; |
|---|
| 2232 | | dostime = |
|---|
| | 2259 | dostime = cast(ushort) ( |
|---|
| 2233 | 2260 | (span.seconds / 2) |
|---|
| 2234 | 2261 | | (span.minutes << 5) |
|---|
| 2235 | | | (span.hours << 11); |
|---|
| 2236 | | |
|---|
| 2237 | | dosdate = |
|---|
| | 2262 | | (span.hours << 11)); |
|---|
| | 2263 | |
|---|
| | 2264 | dosdate = cast(ushort) ( |
|---|
| 2238 | 2265 | (cal.getDayOfMonth(time)) |
|---|
| 2239 | 2266 | | (cal.getMonth(time) << 5) |
|---|
| 2240 | | |((cal.getYear(time) - 1980) << 9); |
|---|
| | 2267 | |((cal.getYear(time) - 1980) << 9)); |
|---|
| 2241 | 2268 | } |
|---|
| 2242 | 2269 | |
|---|
| … | … | |
| 2440 | 2467 | // Otherwise, make sure we don't try to read past the end of the slice |
|---|
| 2441 | 2468 | if( _position+dst.length > length ) |
|---|
| 2442 | | dst.length = length-_position; |
|---|
| | 2469 | dst.length = cast(size_t) (length-_position); |
|---|
| 2443 | 2470 | |
|---|
| 2444 | 2471 | // Seek source stream to the appropriate location. |
|---|
| … | … | |
| 2480 | 2507 | if( _position < 0 ) _position = 0; |
|---|
| 2481 | 2508 | break; |
|---|
| | 2509 | |
|---|
| | 2510 | default: |
|---|
| | 2511 | assert(false); |
|---|
| 2482 | 2512 | } |
|---|
| 2483 | 2513 | |
|---|
| … | … | |
| 2540 | 2570 | // Otherwise, make sure we don't try to read past the end of the slice |
|---|
| 2541 | 2571 | if( dst.length > _length ) |
|---|
| 2542 | | dst.length = _length; |
|---|
| | 2572 | dst.length = cast(size_t) _length; |
|---|
| 2543 | 2573 | |
|---|
| 2544 | 2574 | // Do the read |
|---|
| … | … | |
| 2619 | 2649 | // slice |
|---|
| 2620 | 2650 | if( _position+src.length > length ) |
|---|
| 2621 | | src.length = length-_position; |
|---|
| | 2651 | src.length = cast(size_t) (length-_position); |
|---|
| 2622 | 2652 | |
|---|
| 2623 | 2653 | // Seek source stream to the appropriate location. |
|---|
| … | … | |
| 2664 | 2694 | if( _position < 0 ) _position = 0; |
|---|
| 2665 | 2695 | break; |
|---|
| | 2696 | |
|---|
| | 2697 | default: |
|---|
| | 2698 | assert(false); |
|---|
| 2666 | 2699 | } |
|---|
| 2667 | 2700 | |
|---|
| r3195 |
r3200 |
|
| 113 | 113 | |
|---|
| 114 | 114 | else if( file.tempFile !is null ) |
|---|
| 115 | | return file.tempFile.length; |
|---|
| 116 | | |
|---|
| | 115 | { |
|---|
| | 116 | assert( file.tempFile.length >= 0 ); |
|---|
| | 117 | return cast(ulong) file.tempFile.length; |
|---|
| | 118 | } |
|---|
| 117 | 119 | else |
|---|
| 118 | 120 | return 0; |
|---|
| … | … | |
| 243 | 245 | break; |
|---|
| 244 | 246 | |
|---|
| 245 | | debug( ZipFolder ) |
|---|
| 246 | | { |
|---|
| 247 | 247 | default: |
|---|
| 248 | | Stderr.formatln( |
|---|
| | 248 | debug( ZipFolder ) Stderr.formatln( |
|---|
| 249 | 249 | "Entry.dispose_children: unknown type {}", |
|---|
| 250 | 250 | type); |
|---|
| 251 | 251 | assert(false); |
|---|
| 252 | | } |
|---|
| 253 | 252 | } |
|---|
| 254 | 253 | } |
|---|
| … | … | |
| 725 | 724 | } |
|---|
| 726 | 725 | while( true ); |
|---|
| | 726 | |
|---|
| | 727 | assert(false); |
|---|
| 727 | 728 | } |
|---|
| 728 | 729 | |
|---|
| … | … | |
| 989 | 990 | error("ZipFile.size: cannot reliably determine size of a " |
|---|
| 990 | 991 | "non-existent file"); |
|---|
| | 992 | |
|---|
| | 993 | assert(false); |
|---|
| 991 | 994 | } |
|---|
| 992 | 995 | |
|---|
| … | … | |
| 1138 | 1141 | error("ZipFile.input: cannot open non-existent file for input; " |
|---|
| 1139 | 1142 | "results would not be very useful"); |
|---|
| | 1143 | |
|---|
| | 1144 | assert(false); |
|---|
| 1140 | 1145 | } |
|---|
| 1141 | 1146 | |
|---|
| … | … | |
| 1306 | 1311 | ~ parent.fullname ~ "/" ~ name |
|---|
| 1307 | 1312 | ~ "\" does not exist"); |
|---|
| | 1313 | |
|---|
| | 1314 | assert(false); |
|---|
| 1308 | 1315 | } |
|---|
| 1309 | 1316 | } |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic