문제

I need some way to determine if a file is compressed in some kind of extension ex:(rar, tar, tar.gz, etc.), it is using C/C++ languages under linux systems. I read something about stat and S_IFCMP, but I can't use it in linux, so, can you help me with some alternative?

도움이 되었습니까?

해결책

There is no bullet proof way to determine this. You can check the extension. If you don't trust the extension, then you have to look into the file and check for signatures.

You can find some of them here.

The call to stat will not tell you about individual files being compressed, as this flag means that the file system is compressed.

다른 팁

Each file format have its own signature. There is no generic way that can be applied to all compressed file formats like RAR,TAR,TAR.GZ. Signature for various file formats is avialable at: http://www.garykessler.net/library/file_sigs.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top