#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <sys/attr.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <locale.h>
#include "zopen.h"
exit (eval);
}
- if (cat == 1 && argc > 1)
- errx(1, "the -c option permits only a single file argument");
+ /*
+ * The UNIX standard requires that `uncompress -c` be able to have multiple file parameters given.
+ */
for (; *argv; ++argv)
switch(style) {
void
setfile(const char *name, struct stat *fs)
{
- static struct timeval tv[2];
+ struct attrlist ts_req = {};
+ struct {
+ struct timespec mtime;
+ struct timespec atime;
+ } set_ts;
fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
- TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
- TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
- if (utimes(name, tv))
- cwarn("utimes: %s", name);
+ ts_req.bitmapcount = ATTR_BIT_MAP_COUNT;
+ ts_req.commonattr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME;
+ set_ts.mtime = fs->st_mtimespec;
+ set_ts.atime = fs->st_atimespec;
+
+ if (setattrlist(name, &ts_req, &set_ts, sizeof(set_ts), 0))
+ cwarn("setattrlist: %s", name);
/*
* Changing the ownership probably won't succeed, unless we're root
permission(const char *fname)
{
int ch, first;
+ char resp[] = {'\0', '\0'};
if (!isatty(fileno(stderr)))
return (0);
(void)fprintf(stderr, "overwrite %s? ", fname);
+
+ /* Load user specified locale */
+ setlocale(LC_MESSAGES, "");
+
first = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
- return (first == 'y');
+
+ /* only care about first character */
+ resp[0] = first;
+
+ return (rpmatch(resp) == 1);
}
void
"usage: compress [-cfv] [-b bits] [file ...]\n");
else
(void)fprintf(stderr,
- "usage: uncompress [-cfv] [-b bits] [file ...]\n");
+ "usage: uncompress [-cfv] [file ...]\n");
exit(1);
}