Skip to content

Commit

Permalink
implement source file deletion and the --keep flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lloyd committed Feb 5, 2009
1 parent 249b8a5 commit 98c850f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PROJECT(easylzma)

SET (EASYLZMA_MAJOR 0)
SET (EASYLZMA_MINOR 0)
SET (EASYLZMA_MICRO 2)
SET (EASYLZMA_MICRO 3)

SET (EASYLZMA_DIST_NAME
"easylzma-${EASYLZMA_MAJOR}.${EASYLZMA_MINOR}.${EASYLZMA_MICRO}")
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.0.3
* lloyd implement source file deletion and the --keep flag

0.0.2
* lloyd fix dynamic libraries on osx 10.4
* lloyd README updated with supported platforms and more accurate
Expand Down
4 changes: 2 additions & 2 deletions elzma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../${EASYLZMA_DIST_NAME}/bin)
# create some directories
FILE(MAKE_DIRECTORY ${binDir})

SET (SRCS elzma.c)
SET (HDRS )
SET (SRCS elzma.c util.c)
SET (HDRS util.h)

# use the library we built
INCLUDE_DIRECTORIES(
Expand Down
15 changes: 14 additions & 1 deletion elzma/elzma.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "easylzma/compress.h"
#include "easylzma/decompress.h"
#include "util.h"

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -198,6 +199,7 @@ doCompress(int argc, char ** argv)
/* now attempt to open input and ouput files */
/* XXX: stdin/stdout support */
if (0 != openFiles(ifname, &inFile, ofname, &outFile, overwrite)) {
deleteFile(ofname);
return 1;
}

Expand All @@ -208,6 +210,7 @@ doCompress(int argc, char ** argv)
{
fprintf(stderr, "error seeking input file (%s) - zero length?\n",
ifname);
deleteFile(ofname);
return 1;
}

Expand All @@ -222,6 +225,7 @@ doCompress(int argc, char ** argv)
hand = elzma_compress_alloc();
if (hand == NULL) {
fprintf(stderr, "couldn't allocate compression object\n");
deleteFile(ofname);
return 1;
}

Expand All @@ -231,6 +235,7 @@ doCompress(int argc, char ** argv)
{
fprintf(stderr, "couldn't configure compression with "
"provided parameters\n");
deleteFile(ofname);
return 1;
}

Expand All @@ -239,6 +244,7 @@ doCompress(int argc, char ** argv)
elzmaWriteFunc, (void *) outFile))
{
fprintf(stderr, "error compressing\n");
deleteFile(ofname);
return 1;
}

Expand All @@ -248,6 +254,8 @@ doCompress(int argc, char ** argv)
fclose(outFile);
free(ofname);

if (!keep) deleteFile(ifname);

return 0;
}

Expand Down Expand Up @@ -352,12 +360,14 @@ doDecompress(int argc, char ** argv)
/* now attempt to open input and ouput files */
/* XXX: stdin/stdout support */
if (0 != openFiles(ifname, &inFile, ofname, &outFile, overwrite)) {
deleteFile(ofname);
return 1;
}

hand = elzma_decompress_alloc();
if (hand == NULL) {
fprintf(stderr, "couldn't allocate decompression object\n");
deleteFile(ofname);
return 1;
}

Expand All @@ -366,12 +376,15 @@ doDecompress(int argc, char ** argv)
elzmaWriteFunc, (void *) outFile))
{
fprintf(stderr, "error decompressing\n");
deleteFile(ofname);
return 1;
}

elzma_decompress_free(&hand);

return 1;
if (!keep) deleteFile(ifname);

return 0;
}

int
Expand Down

0 comments on commit 98c850f

Please sign in to comment.