17 #if !defined(ON_ARCHIVE_INC_) 18 #define ON_ARCHIVE_INC_ 34 static FILE* Open(
const wchar_t* filename,
const wchar_t* mode );
47 static FILE* Open(
const char* filename,
const char* mode );
60 static int Close( FILE* fp );
72 static ON__INT64 CurrentPosition( FILE* fp );
82 static bool SeekFromCurrentPosition( FILE* fp, ON__INT64 offset );
92 static bool SeekFromStart( FILE* fp, ON__INT64 offset );
102 static bool SeekFromEnd( FILE* fp, ON__INT64 offset );
116 static bool Seek( FILE* fp, ON__INT64 offset,
int orgin );
131 static ON__UINT64 Read( FILE* fp, ON__UINT64 count,
void* buffer );
146 static ON__UINT64 Write( FILE* fp, ON__UINT64 count,
const void* buffer );
157 static bool Flush( FILE* fp );
179 static bool GetFileInformation(
181 ON__UINT64* file_size,
182 ON__UINT64* file_create_time,
183 ON__UINT64* file_last_modified_time
238 const wchar_t* FirstFile(
239 const wchar_t* directory_name,
240 const wchar_t* file_name_filter
243 const wchar_t* FirstFile(
244 const char* directory_name,
245 const char* file_name_filter
254 const wchar_t* NextFile();
256 const wchar_t* CurrentFileName()
const;
258 ON__UINT64 CurrentFileSize()
const;
264 bool CurrentFileIsDirectory()
const;
272 bool CurrentFileIsHidden()
const;
274 bool GetCurrentFullPathFileName(
ON_wString& filename )
const;
280 ON__UINT64 CurrentFileCreateTime()
const;
286 ON__UINT64 CurrentFileLastModifiedTime()
const;
292 ON__UINT64 CurrentFileLastAccessTime()
const;
298 ON__UINT64 Count()
const;
305 #if defined(ON_COMPILER_MSC) 306 ON__UINT32 m_file_attributes_mask;
308 WIN32_FIND_DATA m_fd;
313 struct dirent m_dirent;
314 char m_dirent_name_buffer[NAME_MAX+1];
317 wchar_t m_current_name[1024];
318 ON__UINT64 m_current_file_attributes;
319 ON__UINT64 m_current_file_size;
320 ON__UINT64 m_current_file_create_time;
321 ON__UINT64 m_current_last_modified_time;
322 ON__UINT64 m_current_last_access_time;
332 typedef void (*ON_Buffer_ErrorHandler)(
class ON_Buffer*);
357 void EmergencyDestroy();
378 ON__UINT64 Size()
const;
386 ON__UINT32 CRC32( ON__UINT32 current_remainder )
const;
398 ON__UINT64 CurrentPosition()
const;
409 ON__UINT64 Write( ON__UINT64 size,
const void* buffer );
430 ON__UINT64 Read( ON__UINT64 size,
void* buffer );
434 seek_from_beginning_of_file = 0,
435 seek_from_current_position = 1,
436 seek_from_end_of_file = 2
475 bool SeekFromStart( ON__INT64 offset );
490 bool SeekFromCurrentPosition( ON__INT64 offset );
505 bool SeekFromEnd( ON__INT64 offset );
518 bool ChangeSize( ON__UINT64 buffer_size );
537 bool IsValid(
const ON_TextLog* text_log )
const;
545 ON__UINT32 LastError()
const;
547 void ClearLastError();
549 ON_Buffer_ErrorHandler ErrorHandler()
const;
551 void SetErrorHandler(ON_Buffer_ErrorHandler error_handler);
593 bool Compress(
ON_Buffer& compressed_buffer )
const;
621 bool Uncompress(
ON_Buffer& uncompressed_buffer )
const;
625 ON__UINT64 m_buffer_size;
626 ON__UINT64 m_current_position;
628 struct ON_BUFFER_SEGMENT* m_first_segment;
629 struct ON_BUFFER_SEGMENT* m_last_segment;
630 struct ON_BUFFER_SEGMENT* m_current_segment;
631 bool SetCurrentSegment(
bool);
634 ON_MEMORY_POOL* m_heap;
635 ON_Buffer_ErrorHandler m_error_handler;
637 ON__UINT32 m_last_error;
638 unsigned char m_reserved[12];
656 class ON_ObjectAttributes;
683 ON__UINT64 Length()
const;
700 bool ON_IsLongChunkTypecode(ON__UINT32 typecode);
702 bool ON_IsShortChunkTypecode(ON__UINT32 typecode);
704 #if defined(ON_DLL_TEMPLATE) 708 #pragma warning( push ) 709 #pragma warning( disable : 4231 ) 712 #pragma warning( pop ) 738 size_t CurrentPosition(
741 bool SeekFromCurrentPosition(
749 bool AtEnd()
const = 0;
751 bool BigSeekFromStart( ON__UINT64 offset );
752 bool BigSeekForward( ON__UINT64 offset );
753 bool BigSeekBackward( ON__UINT64 offset );
754 bool BigSeekFromCurrentPosition( ON__INT64 offset );
766 bool ToggleByteOrder(
774 const char* TypecodeName(
unsigned int tcode );
777 char* ON_TypecodeParse(
unsigned int tcode,
char* typecode_name,
size_t max_length );
779 bool ReadMode()
const;
780 bool WriteMode()
const;
788 ON::endian Endian()
const;
790 int BadCRCCount()
const;
792 bool ReadByte(
size_t,
void* );
794 bool WriteByte(
size_t,
const void* );
806 ON__UINT64 ReadBuffer( ON__UINT64 sizeof_buffer,
void* buffer );
820 bool EnableCRCCalculation(
bool bEnable );
847 bool ReadCompressedBufferSize(
size_t* sizeof__outbuffer );
870 bool ReadCompressedBuffer(
871 size_t sizeof__outbuffer,
885 bool WriteCompressedBuffer(
886 size_t sizeof__inbuffer,
890 bool ReadBool(
bool* );
970 bool ReadBigSize(
size_t* );
972 bool ReadBigTime( time_t* );
1034 bool ReadTime(
struct tm& );
1048 ON_DEPRECATED
bool ReadStringSize(
1049 size_t* str_array_count
1061 bool ReadStringUTF8ElementCount(
1062 size_t* string_utf8_element_count
1074 bool ReadStringUTF16ElementCount(
1075 size_t* string_utf16_element_count
1093 size_t str_array_count,
1111 size_t str_array_count,
1112 unsigned char* str_array
1129 size_t str_array_count,
1130 unsigned short* str_array
1137 bool ReadComponentIndex( ON_COMPONENT_INDEX& );
1173 bool WriteBool(
bool );
1181 const unsigned char*
1196 const unsigned short*
1241 const unsigned long*
1253 bool WriteBigSize(
size_t );
1255 bool WriteBigTime( time_t );
1300 bool WriteLine(
const ON_Line&);
1302 bool WriteArc(
const ON_Arc&);
1308 bool WriteUuid(
const ON_UUID& );
1316 bool WriteTime(
const struct tm& );
1359 const unsigned char* sUTF8
1381 const unsigned short* sUTF16
1384 bool WriteString(
const ON_String& sUTF8 );
1388 bool WriteComponentIndex(
const ON_COMPONENT_INDEX& );
1424 bool WriteArray(
int count,
const class ON_Layer* );
1425 bool WriteArray(
int count,
const class ON_Layer*
const* );
1479 bool EnableSave3dmRenderMeshes( ON_BOOL32 =
true );
1480 bool Save3dmRenderMeshes()
const;
1482 bool EnableSave3dmAnalysisMeshes( ON_BOOL32 =
true );
1483 bool Save3dmAnalysisMeshes()
const;
1485 bool EnableSaveUserData( ON_BOOL32 =
true );
1486 bool SaveUserData()
const;
1496 static int CurrentArchiveVersion();
1521 bool Write3dmStartSection(
1523 const char* sStartSectionComment
1533 bool Read3dmStartSection(
1541 bool Write3dmProperties(
1544 bool Read3dmProperties(
1551 bool Write3dmSettings(
1554 bool Read3dmSettings(
1561 bool BeginWrite3dmBitmapTable();
1562 bool Write3dmBitmap(
const ON_Bitmap& );
1563 bool EndWrite3dmBitmapTable();
1565 bool BeginRead3dmBitmapTable();
1570 bool EndRead3dmBitmapTable();
1575 bool BeginWrite3dmTextureMappingTable();
1577 bool EndWrite3dmTextureMappingTable();
1579 bool BeginRead3dmTextureMappingTable();
1580 int Read3dmTextureMapping(
1583 bool EndRead3dmTextureMappingTable();
1588 bool BeginWrite3dmMaterialTable();
1590 bool EndWrite3dmMaterialTable();
1592 bool BeginRead3dmMaterialTable();
1593 int Read3dmMaterial(
1596 bool EndRead3dmMaterialTable();
1601 bool BeginWrite3dmLinetypeTable();
1603 bool EndWrite3dmLinetypeTable();
1605 bool BeginRead3dmLinetypeTable();
1607 bool EndRead3dmLinetypeTable();
1612 bool BeginWrite3dmLayerTable();
1613 bool Write3dmLayer(
const ON_Layer& );
1614 bool EndWrite3dmLayerTable();
1616 bool BeginRead3dmLayerTable();
1620 bool EndRead3dmLayerTable();
1625 bool BeginWrite3dmGroupTable();
1626 bool Write3dmGroup(
const ON_Group& );
1627 bool EndWrite3dmGroupTable();
1629 bool BeginRead3dmGroupTable();
1670 bool EndRead3dmGroupTable();
1676 bool BeginWrite3dmFontTable();
1677 bool Write3dmFont(
const ON_Font& );
1678 bool EndWrite3dmFontTable();
1680 bool BeginRead3dmFontTable();
1721 bool EndRead3dmFontTable();
1727 bool BeginWrite3dmDimStyleTable();
1729 bool EndWrite3dmDimStyleTable();
1731 bool BeginRead3dmDimStyleTable();
1769 int Read3dmDimStyle(
1773 bool EndRead3dmDimStyleTable();
1779 bool BeginWrite3dmLightTable();
1780 bool Write3dmLight(
const ON_Light&,
1783 bool EndWrite3dmLightTable();
1785 bool BeginRead3dmLightTable();
1793 bool EndRead3dmLightTable();
1799 bool BeginWrite3dmHatchPatternTable();
1801 bool EndWrite3dmHatchPatternTable();
1803 bool BeginRead3dmHatchPatternTable();
1805 bool EndRead3dmHatchPatternTable();
1810 bool BeginWrite3dmInstanceDefinitionTable();
1812 bool EndWrite3dmInstanceDefinitionTable();
1814 bool BeginRead3dmInstanceDefinitionTable();
1850 int Read3dmInstanceDefinition(
1854 bool EndRead3dmInstanceDefinitionTable();
1859 bool BeginWrite3dmObjectTable();
1860 bool Write3dmObject(
1864 bool EndWrite3dmObjectTable();
1866 bool BeginRead3dmObjectTable();
1876 bool EndRead3dmObjectTable();
1881 bool BeginWrite3dmHistoryRecordTable();
1882 bool Write3dmHistoryRecord(
1885 bool EndWrite3dmHistoryRecordTable();
1887 bool BeginRead3dmHistoryRecordTable();
1895 int Read3dmHistoryRecord(
1898 bool EndRead3dmHistoryRecordTable();
1934 bool BeginWrite3dmUserTable(
1937 int goo_3dm_version,
1938 int goo_opennurbs_version
1941 bool EndWrite3dmUserTable();
1964 bool Write3dmAnonymousUserTableRecord(
1966 int goo_3dm_version,
1967 int goo_opennurbs_version,
1972 ON_DEPRECATED
bool BeginWrite3dmUserTable(
const ON_UUID& );
1975 ON_DEPRECATED
bool Write3dmAnonymousUserTable(
const ON_3dmGoo& );
1994 bool BeginRead3dmUserTable(
1996 bool* bLastSavedAsGoo,
1997 int* archive_3dm_version,
1998 int* archive_opennurbs_version
2009 bool Read3dmAnonymousUserTable(
2010 int archive_3dm_version,
2011 int archive_opennurbs_version,
2015 bool EndRead3dmUserTable();
2018 ON_DEPRECATED
bool BeginRead3dmUserTable(
2023 ON_DEPRECATED
bool Read3dmAnonymousUserTable(
ON_3dmGoo& );
2041 bool Write3dmEndMark();
2056 bool Read3dmEndMark(
2080 bool BeginWrite3dmChunk(
2085 bool BeginWrite3dmBigChunk(
2086 ON__UINT32 typecode,
2103 bool BeginWrite3dmChunk(
2111 bool EndWrite3dmChunk();
2116 ON_DEPRECATED
bool BeginRead3dmChunk(
2123 bool BeginRead3dmBigChunk(
2140 bool BeginRead3dmChunk(
2141 unsigned int expected_tcode,
2155 bool EndRead3dmChunk();
2156 bool EndRead3dmChunk(
bool bSupressPartiallyReadChunkWarning);
2184 bool BeginWriteDictionary(
2186 unsigned int version,
2187 const wchar_t* dictionary_name
2205 bool EndWriteDictionary();
2223 bool BeginWriteDictionaryEntry(
2225 const wchar_t* entry_name
2227 bool EndWriteDictionaryEntry();
2229 bool BeginReadDictionary(
2231 unsigned int* version,
2234 bool EndReadDictionary();
2248 int BeginReadDictionaryEntry(
2252 bool EndReadDictionaryEntry();
2257 ON_DEPRECATED
bool PeekAt3dmChunkType(
2262 bool PeekAt3dmBigChunkType(
2263 ON__UINT32* typecode,
2264 ON__INT64* big_value
2267 bool Seek3dmChunkFromStart(
2275 bool Seek3dmChunkFromCurrentPosition(
2290 bool Write3dmChunkVersion(
2294 bool Read3dmChunkVersion(
2309 bool WriteObjectUserData(
const ON_Object&
object );
2321 bool ReadObjectUserData(
ON_Object&
object );
2339 int Archive3dmVersion()
const;
2361 int ArchiveOpenNURBSVersion()
const;
2379 size_t ArchiveStartOffset()
const;
2383 no_active_table = 0,
2429 bool FindTableInDamagedArchive(
2430 unsigned int tcode_table,
2431 unsigned int tcode_record,
2454 int recursion_depth = 0
2466 size_t Read(
size_t,
void* ) = 0;
2475 size_t Write(
size_t,
const void* ) = 0;
2498 int LoadUserDataApplication(
2502 bool SetArchive3dmVersion(
int);
2506 bool WriteInt8(
size_t,
const ON__INT8* );
2507 bool ReadInt8(
size_t, ON__INT8* );
2510 bool WriteInt16(
size_t,
const ON__INT16* );
2511 bool ReadInt16(
size_t, ON__INT16* );
2514 bool WriteInt32(
size_t,
const ON__INT32* );
2515 bool ReadInt32(
size_t, ON__INT32* );
2518 bool WriteInt64(
size_t,
const ON__INT64* );
2519 bool ReadInt64(
size_t, ON__INT64* );
2521 bool BeginWrite3dmTable(
2524 bool EndWrite3dmTable(
2527 bool BeginRead3dmTable(
2530 bool EndRead3dmTable(
2543 int Read3dmV1Object(
2553 bool Read3dmV1AttributesOrMaterial(
2558 class ON__3dmV1_XDATA* = 0
2561 int Read3dmV1LayerIndex(
const char* )
const;
2576 ON::archive_mode Mode()
const;
2577 void UpdateCRC(
size_t,
const void* );
2581 int m_3dm_v1_layer_index;
2582 int m_3dm_v1_material_index;
2602 unsigned int m_error_message_mask;
2604 unsigned int ErrorMessageMask()
const;
2616 bool MaskReadError( ON__UINT64 sizeof_request, ON__UINT64 sizeof_read )
const;
2631 int m_3dm_opennurbs_version;
2637 size_t m_3dm_start_section_offset;
2641 table_type TableTypeFromTypecode(
unsigned int );
2646 bool PushBigChunk( ON__UINT32 typecode, ON__INT64 value );
2648 bool WriteChunkTypecode( ON__UINT32 );
2649 bool ReadChunkTypecode( ON__UINT32* );
2650 bool WriteChunkValue( ON__UINT32 typecode, ON__INT64 );
2651 bool WriteChunkLength( ON__UINT64 );
2652 bool ReadChunkValue( ON__UINT32 typecode, ON__INT64* value64 );
2653 bool FindMisplacedTable(
2654 ON__UINT64 filelength,
2655 const ON__UINT32 table_tocde,
2656 const ON__UINT32 table_record_record,
2658 const ON__UINT64 min_length_data
2661 bool ReadObjectUserDataAnonymousChunk(
2662 const ON__UINT64 length_TCODE_ANONYMOUS_CHUNK,
2663 const int archive_3dm_version,
2664 const int archive_opennurbs_version,
2668 size_t SizeofChunkLength()
const;
2671 bool WriteEOFSizeOfFile( ON__UINT64 );
2672 bool ReadEOFSizeOfFile( ON__UINT64* );
2676 int m_bad_CRC_count;
2686 sizeof_x_buffer = 16384
2688 unsigned char buffer[sizeof_x_buffer];
2693 size_t WriteDeflate(
2701 bool CompressionInit();
2702 void CompressionEnd();
2707 ON::endian m_endian;
2709 ON::archive_mode m_mode;
2712 bool m_bSaveUserData;
2713 bool m_bSavePreviewImage;
2714 bool m_bEmbedTextureBitmaps;
2715 bool m_bSaveRenderMeshes;
2716 bool m_bSaveAnalysisMeshes;
2723 struct ON__3dmV1LayerIndex* m_V1_layer_list;
2772 size_t CurrentPosition()
const;
2773 bool SeekFromCurrentPosition(
int);
2774 bool SeekFromStart(
size_t);
2778 bool SeekFromEnd(
int );
2788 void EnableMemoryBuffer(
2793 size_t Read(
size_t,
void* );
2794 size_t Write(
size_t,
const void* );
2807 size_t m_memory_buffer_capacity;
2808 size_t m_memory_buffer_size;
2809 size_t m_memory_buffer_ptr;
2810 unsigned char* m_memory_buffer;
2856 size_t CurrentPosition()
const;
2857 bool SeekFromCurrentPosition(
int);
2858 bool SeekFromStart(
size_t);
2861 bool SeekFromEnd( ON__INT64 );
2864 size_t Read(
size_t,
void* );
2865 size_t Write(
size_t,
const void* );
2903 size_t sizeof_buffer,
2906 int archive_3dm_version,
2907 int archive_opennurbs_version
2916 size_t SizeOfBuffer()
const;
2922 const void* Buffer()
const;
2925 size_t CurrentPosition()
const;
2926 bool SeekFromCurrentPosition(
int);
2927 bool SeekFromStart(
size_t);
2932 size_t Read(
size_t,
void* );
2933 size_t Write(
size_t,
const void* );
2938 const unsigned char* m_buffer;
2939 size_t m_sizeof_buffer;
2940 size_t m_buffer_position;
2941 ON__INT_PTR m_reserved1;
2942 ON__INT_PTR m_reserved2;
2943 ON__INT_PTR m_reserved3;
2944 ON__INT_PTR m_reserved4;
2975 size_t initial_sizeof_buffer,
2976 size_t max_sizeof_buffer,
2977 int archive_3dm_version,
2978 int archive_opennurbs_version
2987 size_t SizeOfArchive()
const;
2993 size_t SizeOfBuffer()
const;
3004 const void* Buffer()
const;
3013 void* HarvestBuffer();
3016 size_t CurrentPosition()
const;
3017 bool SeekFromCurrentPosition(
int);
3018 bool SeekFromStart(
size_t);
3023 size_t Read(
size_t,
void* );
3024 size_t Write(
size_t,
const void* );
3028 void AllocBuffer(
size_t);
3030 unsigned char* m_buffer;
3031 size_t m_sizeof_buffer;
3032 const size_t m_max_sizeof_buffer;
3033 size_t m_sizeof_archive;
3034 size_t m_buffer_position;
3035 ON__INT_PTR m_reserved1;
3036 ON__INT_PTR m_reserved2;
3037 ON__INT_PTR m_reserved3;
3038 ON__INT_PTR m_reserved4;
3077 bool ON_WriteOneObjectArchive(