创建 zip 而不记录根路径;以编程方式
认为 我想压缩这个目录 〔c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/〕
我希望输出目录是 〔c:/Users/xah/xx2/〕
(我当前的目录可以是任何地方。我在 elisp 程序中调用 zip) 所以我这样做
zip -r c:/Users/xah/xx2/build-util.zip c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/
然后 zip 会像这样记录完整路径
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/ (stored 0%)
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/.svn/ (stored 0%)
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/.svn/all-wcprops (deflated 56%)
...
我希望路径只是以 build-util 开头。
注意:我在程序(elisp)中调用 zip,但我不能或不想使用任何环境变量的概念。
这可以通过一些 zip 参数实现吗?
suppose
i want to zip this dir
〔c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/〕
and my i want the output dir to be
〔c:/Users/xah/xx2/〕
(my current dir could be anywhere. I'm calling zip in a elisp program)
so i do
zip -r c:/Users/xah/xx2/build-util.zip c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/
then zip will record the full path like this
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/ (stored 0%)
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/.svn/ (stored 0%)
adding: Users/xah/ErgoEmacs_Source/ergoemacs/build-util/.svn/all-wcprops (deflated 56%)
...
i want the paths to simply start with build-util.
note: i'm calling zip in a program (elisp) and i cant or don't want to use any concept of envirenment variable.
Is this possible with some zip parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
奇怪的是,您最好的选择可能是使用 Java JDK 中的 jar。
jar -cMf c:/Users/xah/xx2/build-util.zip -C c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/ .
“-M”告诉 jar 不要创建清单文件,-C 告诉它在开始压缩文件之前更改目录。我所依据的文档在这里:
http://download.oracle.com/javase/tutorial/deployment/jar /build.html
Oddly enough, your best option may be to use jar from the Java JDK.
jar -cMf c:/Users/xah/xx2/build-util.zip -C c:/Users/xah/ErgoEmacs_Source/ergoemacs/build-util/ .
the "-M" tells jar not to create a manifest file and the -C tells it to change directories before beginning zipping files up. The documentation I based this off of is here:
http://download.oracle.com/javase/tutorial/deployment/jar/build.html
我最喜欢的 bash 函数之一是 Pushd,它保存您当前所在的目录并将您移动到您指定的目录。倒数函数是 popd,它会将您移回到 Pushd 之前所在的目录。
例如,
我认为你最终会得到你想要的。
One of my favorite bash functions is pushd, it saves the dirrectory you are currently in and moves you to the directory you specify. The reciprocal function is popd, it moves you back to the directory you were in before pushd.
For example you do
I think you wind up with what you want.