tjx666 / vscode-archive

compress/decompress for .zip, .vsix, .crx(v3), .asar, .tgz, .gzip, .br, .tar
https://marketplace.visualstudio.com/items?itemName=YuTengjing.vscode-archive
MIT License
17 stars 3 forks source link

Feature Request - Extract Files to Current Directory 提取文件到当前目录功能请求 #1

Open SYKoh opened 1 year ago

SYKoh commented 1 year ago

Issue Description/问题描述:

I have encountered a scenario where the file structure within some compressed files includes an additional folder. As a result, when I extract such files, a folder with the same name as the compressed file is created, and it contains the original folder structure from the compressed file.

如果压缩文件中的文件结构的根目录 是一个与压缩文件同名的文件夹。当我解压这样的文件时,会创建一个与压缩文件同名的文件夹,它包含了来自压缩文件的原始文件夹结构。

The results are as below:

结果如下:

.
├── file
│   └── file
│       └── TextFile.txt
└── file.zip

Feature Request/功能请求:

I would like to propose an enhancement to the plugin's file extraction behavior. Specifically, I suggest implementing a check to determine whether the file structure within the compressed file consists of a single file at the root level, sharing the same name as the compressed file. If such a scenario is detected, the plugin should extract the file directly to the current directory instead of creating an additional folder. On the other hand, if the file structure includes multiple files or folders, the plugin should continue creating a new folder and extracting the contents accordingly.

我建议对插件的文件解压行为进行增强。具体而言,我建议在解压缩过程中检查压缩文件内的文件结构是否只包含一个与压缩文件同名的文件位于根目录。如果检测到这种情况,插件应该直接将文件解压缩到当前目录,而不是创建额外的文件夹。另一方面,如果文件结构包含多个文件或文件夹,插件应该继续创建新的文件夹并相应地进行提取。

Or maybe adding a feature that allows extracting the files directly to the current directory instead of creating a new folder. 或者可以增加一个功能,允许直接将文件提取到当前目录,而不创建新的文件夹。

tjx666 commented 1 year ago

合理的做法是源文件是怎样的结构解压之后就应该是怎样的结构,不应该搞一些黑魔法,issue 先留着,如果别人也有同样的需求再考虑实现。