transfire / gmail.com wrote: > Using Archive::Tar:Minitar, is there any way to quickly check if a file > is a tar file or not? To answer my own question, sadly, "no": Magic bytes None. However, identification of tar files is not limited to looking at the file extension. Each tar archive entry header also stores a checksum on itself. Thus, reading the first 512 bytes of a potential tar file, creating that checksum and comparing it to the stored checksum will tell if the file really is in tar format. That's too complex for efficent checking. OTOH, Luckly gzips are easy to identify. Not tested but basically: class File # Is a file a gzip file? def self.gzip?( file ) File.open(file,'rb') { |f| return false unless f.getc == 0x1f return false unless f.getc == 0x8b } end end Might be worth adding to Zlib (assuming it'snot already there --I didn't see it). T.