문제

I'm new to binary files, My binary file is written in a length indicator way and I want to know if there is a way I can update it (writing to it) without overwriting it (shifting the text)? And how deleting can be done (deleting with shifting backwards)?

도움이 되었습니까?

해결책

You can't to that. If you want to delete a piece of data in your file, you will need to re-write the remainder of the file.

pseudo-code:

- Open original file for read
- Open temp file for write
- While data in original file
    - If original file data is needed
        - Write data to temp file
- Delete original file
- Rename temp file to original file name
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top