From 1bce51c9c8dfad148856ee997f26ed7d49011813 Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Sun, 6 Aug 2017 23:04:24 -0400 Subject: [PATCH] Add extra types to compressed filetype filter. This adds a few more common compressed filetypes to the is_compressed fuction. Notably, xz, and two common package file formats, deb and rpm. --- Vagrantfile | 3 +++ src/info/filetype.rs | 5 +++-- xtests/file-names-exts | 3 +++ xtests/file-names-exts-case | 3 +++ xtests/file-names-exts-ext | 3 +++ xtests/file-names-exts-ext-case | 3 +++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 443a9c5..d8cd185 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -168,6 +168,9 @@ Vagrant.configure(2) do |config| touch "#{test_dir}/file-names-exts/COMPRESSED.ZIP" touch "#{test_dir}/file-names-exts/compressed.tar.gz" touch "#{test_dir}/file-names-exts/compressed.tgz" + touch "#{test_dir}/file-names-exts/compressed.tar.xz" + touch "#{test_dir}/file-names-exts/compressed.txz" + touch "#{test_dir}/file-names-exts/compressed.deb" touch "#{test_dir}/file-names-exts/backup~" touch "#{test_dir}/file-names-exts/#SAVEFILE#" diff --git a/src/info/filetype.rs b/src/info/filetype.rs index 9719571..e608603 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -69,8 +69,9 @@ impl FileExtensions { pub fn is_compressed(&self, file: &File) -> bool { file.extension_is_one_of( &[ - "zip", "tar", "Z", "gz", "bz2", "a", "ar", "7z", - "iso", "dmg", "tc", "rar", "par", "tgz", + "zip", "tar", "Z", "z", "gz", "bz2", "a", "ar", "7z", + "iso", "dmg", "tc", "rar", "par", "tgz", "xz", "txz", + "lzma", "deb", "rpm" ]) } diff --git a/xtests/file-names-exts b/xtests/file-names-exts index 35f8ae3..3ed4d72 100644 --- a/xtests/file-names-exts +++ b/xtests/file-names-exts @@ -4,8 +4,11 @@ compiled.coffee compiled.js compiled.o +compressed.deb compressed.tar.gz +compressed.tar.xz compressed.tgz +compressed.txz COMPRESSED.ZIP crypto.asc crypto.signature diff --git a/xtests/file-names-exts-case b/xtests/file-names-exts-case index 27eb2cb..fb7c2b2 100644 --- a/xtests/file-names-exts-case +++ b/xtests/file-names-exts-case @@ -10,8 +10,11 @@ compiled.coffee compiled.js compiled.o +compressed.deb compressed.tar.gz +compressed.tar.xz compressed.tgz +compressed.txz crypto.asc crypto.signature document.pdf diff --git a/xtests/file-names-exts-ext b/xtests/file-names-exts-ext index fbdf712..18aaf6c 100644 --- a/xtests/file-names-exts-ext +++ b/xtests/file-names-exts-ext @@ -5,6 +5,7 @@ VIDEO.AVI compiled.class compiled.coffee +compressed.deb lossless.flac compressed.tar.gz compiled.js @@ -17,7 +18,9 @@ compiled.coffee image.svg compressed.tgz file.tmp +compressed.txz lossless.wav video.wmv DOCUMENT.XLSX +compressed.tar.xz COMPRESSED.ZIP diff --git a/xtests/file-names-exts-ext-case b/xtests/file-names-exts-ext-case index 5aa680a..45de922 100644 --- a/xtests/file-names-exts-ext-case +++ b/xtests/file-names-exts-ext-case @@ -5,6 +5,7 @@ VIDEO.AVI compiled.class compiled.coffee +compressed.deb lossless.flac compressed.tar.gz compiled.js @@ -17,7 +18,9 @@ compiled.coffee image.svg compressed.tgz file.tmp +compressed.txz lossless.wav video.wmv DOCUMENT.XLSX +compressed.tar.xz COMPRESSED.ZIP