Fulcrum
V2EX  ›  问与答

设定一个自己的文件格式,怎么多内容进行分割?

  •  
  •   Fulcrum · May 10, 2019 · 1992 views
    This topic created in 2569 days ago, the information mentioned may be changed or developed.

    是这样子,我想设定一个文件格式,去除头文件以外,后面是多个文件二进制组成,用标志位把他们分割.
    因为是手机上的,大小是不受限的,担心 OOM,如果用逐行读取,如果刚好标志位在换行处,怎么对标志位进行切割呢?
    有个想法,第一行以后,读取时,保留前后二行可行吗

    4 replies    2019-05-10 20:31:42 +08:00
    xupefei
        1
    xupefei  
       May 10, 2019 via iPhone
    二进制文件怎么按行读取?

    你需要的是不是在文件头的偏移表?
    Fulcrum
        2
    Fulcrum  
    OP
       May 10, 2019
    @xupefei 没咋接触过这个,我试下,谢谢老哥
    thedrwu
        3
    thedrwu  
       May 10, 2019 via Android
    弄到带 buffer 的 IO API 上,或者 mmap 到内存里,然后逐字节处理。
    Imr
        4
    Imr  
       May 10, 2019 via iPhone
    我想到了 binwalk
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1231 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 278ms · UTC 23:52 · PVG 07:52 · LAX 16:52 · JFK 19:52
    ♥ Do have faith in what you're doing.