gzip keeps original file

8 visualizzazioni (ultimi 30 giorni)
Tom
Tom il 7 Apr 2011
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?

Risposte (5)

Paulo Silva
Paulo Silva il 7 Apr 2011
%your code goes here
%and after it's done do
delete('filename')

Tom
Tom il 7 Apr 2011
Thanks for the quick reply. My files are very valuable, so I would have to do a bit more checking to make sure the gzip completed successfully before deleting the original. I was hoping all that was built into the Matlab gzip, but maybe it isn't.
  3 Commenti
Jan
Jan il 8 Apr 2011
@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
Walter Roberson il 8 Apr 2011
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.

Accedi per commentare.


Andres
Andres il 29 Giu 2011
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
Daniel Shub il 29 Giu 2011
If you like the unix gzip, why not just use it directly ...
system(['gzip ', FileNameStr])

Tom K
Tom K il 30 Giu 2011
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.

Categorie

Scopri di più su File Compression in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by