Merge branch 'master' into cppcheck-test

pull/42/head
Christian Krause 9 years ago
commit 8cfd6bb9e7

@ -24,7 +24,7 @@ PKG_CHECK_MODULES(LIBARCHIVE, libarchive)
PKG_CHECK_MODULES(LZMA, liblzma)
# Checks for header files.
AC_CHECK_HEADERS([stdint.h stdlib.h string.h unistd.h])
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
# add when travis has autoconf 2.69+ AC_CHECK_HEADER_STDBOOL

@ -3,6 +3,8 @@
#endif
#include "pixz.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <getopt.h>
@ -130,12 +132,33 @@ int main(int argc, char **argv) {
usage("Unknown suffix");
}
}
if (ipath && !(gInFile = fopen(ipath, "r")))
die("Can't open input file");
if (opath && !(gOutFile = fopen(opath, "w")))
die("Can't open output file");
die("can not open input file: %s: %s", ipath, strerror(errno));
if (opath) {
if (gInFile == stdin) {
// can't read permissions of original file, because we read from stdin,
// using umask permissions
if (!(gOutFile = fopen(opath, "w")))
die("can not open output file: %s: %s", opath, strerror(errno));
} else {
// read permissions of original file,
// use them to create / open output file
struct stat input_stat;
int output_fd;
stat(ipath, &input_stat);
if ((output_fd = open(opath, O_CREAT | O_WRONLY, input_stat.st_mode)) == -1)
die("can not open output file: %s: %s", opath, strerror(errno));
if (!(gOutFile = fdopen(output_fd, "w")))
die("can not open output file: %s: %s", opath, strerror(errno));
}
}
switch (op) {
case OP_WRITE:
if (isatty(fileno(gOutFile)) == 1)

@ -1,4 +1,5 @@
TESTS = \
compress-file-permissions.sh \
cppcheck-src.sh \
single-file-round-trip.sh \
xz-compatibility-c-option.sh

@ -0,0 +1,13 @@
#!/bin/bash
PIXZ=../src/pixz
INPUT=$(mktemp)
trap "rm -f $INPUT $INPUT.xz" EXIT
chmod 600 $INPUT
echo foo > $INPUT
$PIXZ $INPUT
[[ $(stat -c "%a" $INPUT.xz) = 600 ]]
Loading…
Cancel
Save