gzip keeps original file

8 visualizaciones (últimos 30 días)
Tom
Tom el 7 de Abr. de 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?

Respuestas (5)

Paulo Silva
Paulo Silva el 7 de Abr. de 2011
%your code goes here
%and after it's done do
delete('filename')

Tom
Tom el 7 de Abr. de 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 comentarios
Jan
Jan el 8 de Abr. de 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 el 8 de Abr. de 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.

Iniciar sesión para comentar.


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

Tom K
Tom K el 30 de Jun. de 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.

Categorías

Más información sobre File Compression en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by