Skip to content

Commit

Permalink
Merge pull request #100 from cafkafk/cafkdev-compressed-files
Browse files Browse the repository at this point in the history
feat(filetype): add compressed type
  • Loading branch information
cafkafk authored Jul 31, 2023
2 parents 023a7c3 + 29777c2 commit 36f83f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
50 changes: 32 additions & 18 deletions src/info/filetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl FileExtensions {
| "Gruntfile.coffee"
| "Gruntfile.js"
| "Justfile"
| "justfile"
| "Makefile"
| "makefile"
| "Makefile.in"
Expand Down Expand Up @@ -107,6 +108,7 @@ impl FileExtensions {
"pnm",
"ppm",
"ps",
"pxm",
"raw",
"stl",
"svg",
Expand Down Expand Up @@ -200,31 +202,40 @@ impl FileExtensions {

fn is_compressed(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"zip",
"tar",
"Z",
"z",
"gz",
"bz2",
"7z",
"a",
"ar",
"7z",
"iso",
"bz",
"bz2",
"bz3",
"cpio",
"deb",
"dmg",
"tc",
"rar",
"par",
"tgz",
"xz",
"txz",
"gz",
"iso",
"lz",
"tlz",
"lz4",
"lzh",
"lzma",
"deb",
"lzo",
"par",
"rar",
"rpm",
"tar",
"taz",
"tbz",
"tbz2",
"tc",
"tgz",
"tlz",
"txz",
"tz",
"tzo",
"xz",
"Z",
"z",
"zip",
"zst",
"lz4",
"cpio",
])
}

Expand Down Expand Up @@ -296,6 +307,9 @@ impl FileIcon for FileExtensions {
else if self.is_video(file) {
Some(Icons::Video.value())
}
else if self.is_compressed(file) {
Some(Icons::Compressed.value())
}
else {
None
}
Expand Down
8 changes: 5 additions & 3 deletions src/output/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ pub enum Icons {
Audio,
Image,
Video,
Compressed,
}

impl Icons {
pub fn value(self) -> char {
match self {
Self::Audio => '\u{f001}',
Self::Image => '\u{f1c5}',
Self::Video => '\u{f03d}',
Self::Audio => '\u{f001}', // 
Self::Image => '\u{f1c5}', // 
Self::Video => '\u{f03d}', // 
Self::Compressed => '\u{f410}', // 
}
}
}
Expand Down

0 comments on commit 36f83f7

Please sign in to comment.