summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-02-14 08:21:28 +0100
committerqkzk <qu3nt1n@gmail.com>2023-02-14 08:21:28 +0100
commit12dcc677a60c58e7f67a24d46607971f0a132460 (patch)
treef7d129239b49af42c5d8d7175dcabf219d806429
parent461b5c7aa8ee562e4a4d6f94e1be1d5a2b520e35 (diff)
rename compress.rs to decompress.rs
-rw-r--r--development.md13
-rw-r--r--src/compress.rs29
-rw-r--r--src/decompress.rs29
-rw-r--r--src/lib.rs1
-rw-r--r--src/opener.rs2
-rw-r--r--src/preview.rs2
6 files changed, 45 insertions, 31 deletions
diff --git a/development.md b/development.md
index c04bde43..6c00c569 100644
--- a/development.md
+++ b/development.md
@@ -380,6 +380,19 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [x] git root : cd to git root
- [x] tree: use the length of the screen to avoid parsing non displayed lines
- [x] navigate in marks
+ - [ ] compress flagged files
+
+ No encryption method provided
+
+ - [ ] choose compression method from a menu
+ - [ ] implement different kind of compression
+ - [ ] pick the right crates:
+ - zip (zip)
+ - tar:
+ - xz (xz ?)
+ - gzip (flate2 / flate3)
+ - bzip2 (lzw)
+ - 7z (sevenz-rust)
- [ ] Version 0.1.50 : safety & memory usage
diff --git a/src/compress.rs b/src/compress.rs
index 7ba85590..e69de29b 100644
--- a/src/compress.rs
+++ b/src/compress.rs
@@ -1,29 +0,0 @@
-use std::fs::File;
-use std::path::Path;
-
-use compress_tools::*;
-
-use crate::fm_error::{FmError, FmResult};
-
-/// Decompress a compressed file into its parent directory.
-/// It may fail an return a `FmError` if the file has no parent,
-/// which should be impossible.
-/// It used `compress_tools` which is a wrapper around `libarchive`.
-pub fn decompress(source: &Path) -> FmResult<()> {
- let parent = source
- .parent()
- .ok_or_else(|| FmError::custom("decompress", "source should have a parent"))?;
- let file = File::open(source)?;
- Ok(uncompress_archive(&file, parent, Ownership::Preserve)?)
-}
-
-/// Returns a list of compressed files within the archive.
-/// it may fail if the file can't be opened or if libarchive
-/// can't read it.
-pub fn list_files<P>(source: P) -> FmResult<Vec<String>>
-where
- P: AsRef<Path>,
-{
- let file = File::open(source)?;
- Ok(list_archive_files(file)?)
-}
diff --git a/src/decompress.rs b/src/decompress.rs
new file mode 100644
index 00000000..7ba85590
--- /dev/null
+++ b/src/decompress.rs
@@ -0,0 +1,29 @@
+use std::fs::File;
+use std::path::Path;
+
+use compress_tools::*;
+
+use crate::fm_error::{FmError, FmResult};
+
+/// Decompress a compressed file into its parent directory.
+/// It may fail an return a `FmError` if the file has no parent,
+/// which should be impossible.
+/// It used `compress_tools` which is a wrapper around `libarchive`.
+pub fn decompress(source: &Path) -> FmResult<()> {
+ let parent = source
+ .parent()
+ .ok_or_else(|| FmError::custom("decompress", "source should have a parent"))?;
+ let file = File::open(source)?;
+ Ok(uncompress_archive(&file, parent, Ownership::Preserve)?)
+}
+
+/// Returns a list of compressed files within the archive.
+/// it may fail if the file can't be opened or if libarchive
+/// can't read it.
+pub fn list_files<P>(source: P) -> FmResult<Vec<String>>
+where
+ P: AsRef<Path>,
+{
+ let file = File::open(source)?;
+ Ok(list_archive_files(file)?)
+}
diff --git a/src/lib.rs b/src/lib.rs
index a3d9fcf5..efa6502b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,6 +9,7 @@ pub mod constant_strings_paths;
pub mod content_window;
pub mod copy_move;
pub mod cryptsetup;
+pub mod decompress;
pub mod event_dispatch;
pub mod event_exec;
pub mod fileinfo;
diff --git a/src/opener.rs b/src/opener.rs
index 4424a3cb..5e218e14 100644
--- a/src/opener.rs
+++ b/src/opener.rs
@@ -6,11 +6,11 @@ use std::process::Command;
use log::info;
use serde_yaml;
-use crate::compress::decompress;
use crate::constant_strings_paths::{
DEFAULT_AUDIO_OPENER, DEFAULT_IMAGE_OPENER, DEFAULT_OFFICE_OPENER, DEFAULT_OPENER,
DEFAULT_READABLE_OPENER, DEFAULT_TEXT_OPENER, DEFAULT_VECTORIAL_OPENER, DEFAULT_VIDEO_OPENER,
};
+use crate::decompress::decompress;
use crate::fileinfo::extract_extension;
use crate::fm_error::{FmError, FmResult};
diff --git a/src/preview.rs b/src/preview.rs
index 8300dbb8..c6fdad52 100644
--- a/src/preview.rs
+++ b/src/preview.rs
@@ -16,8 +16,8 @@ use syntect::parsing::{SyntaxReference, SyntaxSet};
use tuikit::attr::{Attr, Color};
use users::UsersCache;
-use crate::compress::list_files;
use crate::config::Colors;
+use crate::decompress::list_files;
use crate::fileinfo::{FileInfo, FileKind};
use crate::filter::FilterKind;
use crate::fm_error::{FmError, FmResult};