当前位置: 首页>>代码示例>>C++>>正文


C++ Marker::seek_to_marker方法代码示例

本文整理汇总了C++中Marker::seek_to_marker方法的典型用法代码示例。如果您正苦于以下问题:C++ Marker::seek_to_marker方法的具体用法?C++ Marker::seek_to_marker怎么用?C++ Marker::seek_to_marker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Marker的用法示例。


在下文中一共展示了Marker::seek_to_marker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_lib

    LibInfo read_lib(const fs::path& path)
    {
        std::fstream fs(path, std::ios::in | std::ios::binary | std::ios::ate);
        Checks::check_exit(VCPKG_LINE_INFO, fs.is_open(), "Could not open file %s for reading", path.generic_string());

        read_and_verify_archive_file_signature(fs);

        Marker marker;
        marker.set_to_current_pos(fs);

        // First Linker Member
        const ArchiveMemberHeader first_linker_member_header = ArchiveMemberHeader::read(fs);
        Checks::check_exit(VCPKG_LINE_INFO,
                           first_linker_member_header.name().substr(0, 2) == "/ ",
                           "Could not find proper first linker member");
        marker.advance_by(ArchiveMemberHeader::HEADER_SIZE + first_linker_member_header.member_size());
        marker.seek_to_marker(fs);

        const ArchiveMemberHeader second_linker_member_header = ArchiveMemberHeader::read(fs);
        Checks::check_exit(VCPKG_LINE_INFO,
                           second_linker_member_header.name().substr(0, 2) == "/ ",
                           "Could not find proper second linker member");
        // The first 4 bytes contains the number of archive members
        const auto archive_member_count = read_value_from_stream<uint32_t>(fs);
        const OffsetsArray offsets = OffsetsArray::read(fs, archive_member_count);
        marker.advance_by(ArchiveMemberHeader::HEADER_SIZE + second_linker_member_header.member_size());
        marker.seek_to_marker(fs);

        const bool has_longname_member_header = peek_value_from_stream<uint16_t>(fs) == 0x2F2F;
        if (has_longname_member_header)
        {
            const ArchiveMemberHeader longnames_member_header = ArchiveMemberHeader::read(fs);
            marker.advance_by(ArchiveMemberHeader::HEADER_SIZE + longnames_member_header.member_size());
            marker.seek_to_marker(fs);
        }

        std::set<MachineType> machine_types;
        // Next we have the obj and pseudo-object files
        for (const uint32_t offset : offsets.data)
        {
            marker.set_to_offset(offset + ArchiveMemberHeader::HEADER_SIZE); // Skip the header, no need to read it.
            marker.seek_to_marker(fs);
            const auto first_two_bytes = peek_value_from_stream<uint16_t>(fs);
            const bool is_import_header = to_machine_type(first_two_bytes) == MachineType::UNKNOWN;
            const MachineType machine =
                is_import_header ? ImportHeader::read(fs).machine_type() : CoffFileHeader::read(fs).machine_type();
            machine_types.insert(machine);
        }

        return {std::vector<MachineType>(machine_types.cbegin(), machine_types.cend())};
    }
开发者ID:danielvilas,项目名称:vcpkg,代码行数:51,代码来源:cofffilereader.cpp


注:本文中的Marker::seek_to_marker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。