1234567891011121314151617181920212223242526272829303132 |
- use os;
- use fs;
- use path;
- use memio;
- use fmt;
- use shlex;
- use a;
- use a::archives;
- fn extract(cfg: *const a::Config, archive_path: const str) void = {
- let path = match (os::realpath(archive_path)) {
- case let p: str => yield p;
- case let e: fs::error =>
- a::fatal(cfg, "failed to get realpath from '{}': {}", archive_path, fs::strerror(e));
- };
- a::create_out_dir(cfg);
- match (os::chdir(cfg.out_dir)) {
- case let e: fs::error =>
- a::fatal(cfg, "failed to change directrory to '{}': {}", cfg.out_dir, fs::strerror(e));
- case void => void;
- };
- if (cfg.dry_run) {
- fmt::print("cd ")!;
- shlex::quote(os::stdout, cfg.out_dir)!;
- fmt::print(" \\\n&& ")!;
- };
- archives::dryrun_or_exec(cfg.dry_run, CMD, if (cfg.verbose) "vx" else "x", path);
- };
|