Comments (4)
These are all the functions I could find under Archive::
with the set_
prefix:
- tar::Archive::set_mask
- tar::Archive::set_overwrite
- tar::Archive::set_ignore_zeros
- tar::Archive::set_unpack_xattrs
- tar::Archive::set_preserve_mtime
- tar::Archive::set_preserve_ownerships
- tar::Archive::set_preserve_permissions
There's also a set_mode which might be the --acls
from ouch.
Tar.rs logic
It seems like the work flow of tar is:
Compress
- Make a
builder
objectwith a
Header::newgnu(),- this object uses builder.append(&mut
header)
to add files - that header will by default have
HeaderMode::Complete
to include everything like mod/access times and ownership- (although it could be modified by it's
setmetadata
method)TODO
does this include acls by default?
- (although it could be modified by it's
- this object uses builder.append(&mut
- Use
builder.append
to add files
Decompress
- Create an archive and set
- setunpackxattrs
- setpreservepermissions
- setpreserveownerships
- setacls
TODO
is there a way to set acls?
- Unpack the archive
Examples
-
Compressing
For Compressing the example in the
documentation
is something like:use tar::{Builder, Header}; let mut header = Header::new_gnu(); let mut data: &[u8] = &[1, 2, 3, 4]; let mut builder = Builder::new(Vec::new()); builder.append(&header, data).unwrap(); let data = builder.into_inner().unwrap();
We just need to ensure acls are pulled in.
-
Decompressing
This could then be decompressed with
unpack_archive
like so:pub fn unpack_archive(reader: Box<dyn Read>, output_folder: &Path, quiet: bool) -> crate::Result<usize> { assert!(output_folder.read_dir().expect("dir exists").count() == 0); let mut archive = tar::Archive::new(reader); // --xattrs archive.set_unpack_xattrs(true); // --preserver-permissions archive.set_preserve_permissions(); // --numeric-ownership archive.set_preserve_ownerships(); // --acls // TODO let mut files_unpacked = 0; for file in archive.entries()? { let mut file = file?; file.unpack_in(output_folder)?; } Ok(files_unpacked) }
Does that seem right?
from ouch.
I created an issue with tar-rs asking about acls:
Further resources:
from ouch.
If you could offer some guidance, I can try and put together a PR if you'd like?
Sorry for the late response. Unfortunately, I don't think I have the time to give guidance on how to approach this, but we could iterate on the solution in the PR review process.
You're right, Ouch
doesn't support --xattrs
atm.
I like your idea of having a -P/--preserve-all-permissions
flag that covers it all.
In the --help
message we also have to explain that these permissions apply for Tar but not for Zip archives 🤔, and state that CLS is not supported yet.
In conclusion, I approve this feature request and a PR (from you or someone else) would be welcomed for reviewing 👍.
from ouch.
Related Issues (20)
- Remove LZMA support
- Evaluate Profile-Guided Optimization (PGO) and LLVM BOLT
- Colored output for completed task HOT 1
- Add `list-formats` subcommand to show support-status of each format, with optional JSON output HOT 3
- Clarify that .sz refers to Google's Snappy format
- Supporting unrar introduces licensing issues
- The binary archives for the v0.5 release seem to actually be for a prerelease version HOT 3
- The "Dependencies" section of the README seems outdated. HOT 1
- Support for encrypted archives HOT 1
- publish to windows winget package manager HOT 2
- Add `iso` format HOT 3
- Support "zst" and "zstd" for ZStandard HOT 6
- progress indicator HOT 19
- Request: Add Depth Option to `--tree` for Listing Archive Contents HOT 2
- Run logging IO in a separate thread (improve multithread capabilities)
- Add symbol to represent the directory name HOT 1
- Large bz2 file decompressed incorrectly HOT 1
- Compressing a `.tar` file causes (maybe) undesirable double-wrapping
- Allow listing nested archives
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ouch.