mholt / archiver

Easily create & extract archives, and compress & decompress files of various formats
https://pkg.go.dev/github.com/mholt/archiver/v4
MIT License
4.37k stars 387 forks source link

RAR extract file information #420

Open DylanZhu2021 opened 2 months ago

DylanZhu2021 commented 2 months ago

Use the code as follow to get file information such as file mod tiinme in .rar:

f, err := os.Open(realpath)

if err != nil {
    return nil, err
}

rar := archiver.Rar{}

handleFun := func(ctx context.Context, f archiver.File) error {
    fmt.Println(f.ModTime())
}

err = rar.Extract(context.Background(), f, nil, handleFun)

the file time is null. However,the file such as zip,tar get right mod time.

Someone can tell me why. Thanks.

mholt commented 2 months ago

Can you provide an archive that exhibits this behavior? I don't have a rar file handy that does this.

DylanZhu2021 commented 2 months ago

Can you provide an archive that exhibits this behavior? I don't have a rar file handy that does this.

There is a test file for rar in test.zip, you can dearchive this and get the rar file. Thanks. test.zip