gzip keeps original file
显示 更早的评论
I just noticed the default behavior of the Matlab gzip command is to keep the original uncompressed file. Is there a way to have it behave more like the unix gzip(1) command, that is, remove the original file after commpressing?
回答(5 个)
Paulo Silva
2011-4-7
%your code goes here
%and after it's done do
delete('filename')
Tom
2011-4-7
0 个投票
3 个评论
Walter Roberson
2011-4-7
The MATLAB gzip routine is provided as a .m file; you could modify it for your purposes. The routine uses Java to do the actual work.
Jan
2011-4-8
@Tom: If you are in fear, that the original files are deleted by accident, use RECYCLE to enable the usage of the recycle bin for DELETE.
Walter Roberson
2011-4-8
One of the things I would want to check on is whether you can be guaranteed that by the time the write stream close returns, that the file has been completely dispatched to the operating system to write and that there was enough disk space to write. Better, that the write did succeed (e.g., no bad blocks.) Even then if your files happened to be over NFS I would want stricter conditions, as I have observed in the past that the local system believed (with good reason) that the file had been completely written, but that there were errors on the server side.
Andres
2011-6-29
0 个投票
Hello guys, did someone find a solution for the check? I am currently searching for a way to test the integrity of zipped files via Matlab-GZIP.
Daniel Shub
2011-6-29
If you like the unix gzip, why not just use it directly ...
system(['gzip ', FileNameStr])
Tom K
2011-6-30
0 个投票
Thanks for everyone's comments. My original question came up in the context of a program I'm writing that does a file gunzip, reads the file, then gzip's file again. I use the fact that Matlab's gunzip also keeps the original compressed file, and write the uncompressed file to a temp dir and read it into Matlab from there. My original file, gzipped in unix, remains as it was, so no need for checking, and no extra clutter in the original dir. Good enough for me.
Sounds like if you want a gzip with consistency checks, the unix gzip is the way to go.
类别
在 帮助中心 和 File Exchange 中查找有关 File Compression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!