Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Support for "long" file names #210

@Plecra

Description

@Plecra

(...and comments)

When reading a file, we need to have a way to handle file headers which contain text too long to fit in a stack array.

  1. Ignore them.
  • Though it'd solve the problem, we definitely don't want to silently discard files.
  1. Allocate a buffer to temporarily store the data
  • The user will often want to simply ignore text of this length, and copying the data anyway will be expensive.
  • We'd probably need to give the user a way to reuse whichever allocation method we use.
  1. Use a "streaming" API to construct metadata.
    I haven't found a good design for this yet. It's tricky to make the design intuitive without introducing regressions.
impl Metadata for Details {
    fn from_local_header(datetime: (u16. u16), stream: LocalHeaderStream) -> io::Result<(FinishedToken, Self)> {
        let (name, stream) = stream.into_textbuf()?;
        let (extra_field, finished) = stream.into_buffer()?;
        (finished, Self {
            datetime,
            name,
            extra_field,
            central_data: None,
        })
    }
}
const EXTENDED_TIMESTAMP_ID: u16 = 0x5455;
impl Metadata for ExtendedTimestamp {
    fn from_local_header(datetime: (u16, u16), stream: LocalHeaderStream) -> io::Result<{FinishedToken, Self}> {
        let (name, stream) = stream.into_textbuf()?;
        let (iter, mut token) = stream.fields();
        loop {
            let (id, data) = iter.next(token)?.map_err(|_| InvalidData.into())?;
            if id == EXTENDED_TIMESTAMP_ID {
                if data.next()? & 1 != 0 {
                    let modified = data.read_i32()?;
                    return Ok((iter.skip(data.skip()?)?, Self { modified, name }));
                }
            }
            token = data.skip();
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions