GUN tar for windows Practice

本文提供了一个使用QT编写的解压函数,适用于Windows和Linux系统,可以解压.tar.gz文件到指定目录。通过命令行操作gzip和tar完成解压缩过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

windows 下调用gzip.exe 和tar.exe解压*.tar.gz压缩包到指定目录

如:解压D:/test/1.tar.gz 到E:/test/下

1.切换到压缩包所在目录下

cd /d D:

 

2.调用gzip.exe解压.gz压缩文件

gzip /test/1.tar.gz

 

3.调用tar.exe解包.tar

tar xvf /test/1.tar -C //./E:/test/

 

下面是我自己用QT写的解压函数,windows 和 linux 都适用。

#include <QtCore/QCoreApplication>
#include <QFile>
#include <QProcess>
#include <QDebug>
typedef int BOOL;
#define RET_FAILED -1
#define RET_SUCCESS 0

BOOL Extract(QString fileName,QString dstPath)
{
    if(fileName.length()<8 || fileName.right(7)!=".tar.gz")
    {
        qDebug()<<"Extract error:unknown file format,mast be '.tar.gz'";
        return RET_FAILED;
    }
    if(dstPath.length() == 0)
    {
        return RET_FAILED;
    }
    int ret;
    QProcess p;
    fileName = fileName.replace("//","/");

    qDebug()<<"Extrating "<<fileName<<" to "<<dstPath<<" ...";
    if(fileName.at(1) == ':')
    {
        QString driveId = fileName.left(2);
        fileName = fileName.right(fileName.length()-2);
        p.execute("cd /d " + driveId);
    }
    qDebug()<<"start to ungzip "<<fileName<<" ...";
    ret = p.execute("gzip -d " + fileName);

    if(ret != 0)
    {
        qDebug()<<"gzip returns error code:"<<ret;
    }
    qDebug()<<"ungzip "<<fileName<<" success!";
    fileName = fileName.left(fileName.length()-3);
    if(dstPath.at(1) == ':')
    {
        dstPath = "//./" + dstPath;
    }
    qDebug()<<"start to untar "<<fileName<<" ...";
    p.execute("tar xvf " + fileName + " -C " + dstPath);
    if(ret != 0)
    {
        qDebug()<<"tar returns error code:"<<ret;
    }
    qDebug()<<"untar "<<fileName<<" success!";
    QFile::remove(fileName);

    return RET_SUCCESS;
}


windows中打包tar文件 GUN tar 和在unix中使用tar命令基本上一样的。可以使用tar --help得到帮助的详细信息。 ------------------------------------------- GNU `tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive. Usage: tar [OPTION]... [FILE]... If a long option shows an argument as mandatory, then it is mandatory for the equivalent short option also. Similarly for optional arguments. Main operation mode: -t, --list list the contents of an archive -x, --extract, --get extract files from an archive -c, --create create a new archive -d, --diff, --compare find differences between archive and file system -r, --append append files to the end of an archive -u, --update only append files newer than copy in archive -A, --catenate append tar files to an archive --concatenate same as -A --delete delete from the archive (not on mag tapes!) Operation modifiers: -W, --verify attempt to verify the archive after writing it --remove-files remove files after adding them to the archive -k, --keep-old-files don't overwrite existing files when extracting -U, --unlink-first remove each file prior to extracting over it --recursive-unlink empty hierarchies prior to extracting directory -S, --sparse handle sparse files efficiently -O, --to-stdout extract files to standard output -G, --incremental handle old GNU-format incremental backup -g, --listed-incremental handle new GNU-format incremental backup --ignore-failed-read do not exit with nonzero on unreadable files Handling of file attributes: --owner=NAME force NAME as owner for added files --group=NAME force NAME as group for added files --mode=CHANGES force (symbolic) mode CHANGES for added files --atime-preserve don't change acces
### 安装 GNU Radio 和 UHD 驱动程序于 Windows 系统 尽管 GNU Radio 主要支持 Linux 平台,但在 Windows 上也可以通过特定方法完成安装。以下是关于在 Windows 环境下安装 GNU Radio 的说明: #### 使用预编译二进制包 对于 Windows 用户来说,最简单的方法是从第三方提供的预编译版本下载并安装 GNU Radio 及其依赖项。推荐访问 [GNURadio.org](https://gnuradio.org/) 或其他可信资源站点获取适用于 Windows 的 GNU Radio 版本。 如果需要手动配置环境,则需注意以下几点: - **MinGW-w64 工具链**:为了使 GNU Radio 正常运行,可能需要 MinGW-w64 编译器工具链作为基础开发环境[^1]。 - **CMake 构建系统**:用于生成适合本地系统的 Makefile 文件或 Visual Studio 解决方案文件[^2]。 #### 手动构建过程概述 虽然不建议初学者尝试此方式,但如果确实有需求,可按照如下流程操作: 1. 下载最新版源代码压缩包; 2. 准备必要的依赖库(Boost, Python, PyQt5 等),这些通常可以从官方渠道获得; 3. 利用 CMake GUI 设置好目标路径以及其他选项后再点击“Configure”,接着再按“Generate”按钮创建对应的工程文件; 4. 接下来打开刚才产生的 .sln 文件,在 Microsoft Visual Studio 中加载它之后就可以开始编译整个项目了;最后记得执行 `sudo make install` 命令将最终产物部署至指定位置。 #### 测试已安装好的GNU Radio组件 一旦成功完成了上述任一途径中的所有步骤后,应当验证当前设置是否有效工作。具体做法包括但不限于输入下面几条指令来确认基本功能完好无损[^3]: ```bash gnuradio-config-info --version gnuradio-config-info --prefix gnuradio-config-info --enabled-components ``` 另外值得注意的是有关USRP设备的支持情况——即Universal Hardware Driver(UHD),这部分内容同样可以在参考资料里找到详细的指导信息[^4]。 ### 注意事项 由于跨平台兼容性的原因,在实际应用过程中可能会遇到各种意想不到的问题,因此强烈建议优先考虑基于虚拟机或者双引导的方式切换回Linux发行版来进行更深入的学习与实践。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值