diff options
Diffstat (limited to '.pc/12_fix_compiler_warnings.diff/src')
-rw-r--r-- | .pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp | 585 | ||||
-rw-r--r-- | .pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c | 421 |
2 files changed, 0 insertions, 1006 deletions
diff --git a/.pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp b/.pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp deleted file mode 100644 index d801aaa..0000000 --- a/.pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp +++ /dev/null @@ -1,585 +0,0 @@ -/****************************************************************************** - * - * filemgr.cpp - implementation of class FileMgr used for pooling file - * handles - * - * $Id: filemgr.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#include <filemgr.h> -#include <utilstr.h> - -#include <dirent.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <stdio.h> -#include <string.h> -#include <swbuf.h> -#if !defined(__GNUC__) && !defined(_WIN32_WCE) -#include <io.h> -#include <direct.h> -#else -#include <unistd.h> -#endif - - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#ifndef S_IRGRP -#define S_IRGRP 0 -#endif - -#ifndef S_IROTH -#define S_IROTH 0 -#endif - -// Fix for VC6 -#ifndef S_IREAD -#ifdef _S_IREAD -#define S_IREAD _S_IREAD -#define S_IWRITE _S_IWRITE -#endif -#endif -// ----------- - -// ------- if we still don't have something -#ifndef S_IREAD -#define S_IREAD 0400 -#endif -#ifndef S_IWRITE -#define S_IWRITE 0200 -#endif -// ------- - - -SWORD_NAMESPACE_START - - -int FileMgr::CREAT = O_CREAT; -int FileMgr::APPEND = O_APPEND; -int FileMgr::TRUNC = O_TRUNC; -int FileMgr::RDONLY = O_RDONLY; -int FileMgr::RDWR = O_RDWR; -int FileMgr::WRONLY = O_WRONLY; -int FileMgr::IREAD = S_IREAD; -int FileMgr::IWRITE = S_IWRITE; - - -// ---------------- statics ----------------- -FileMgr *FileMgr::systemFileMgr = 0; - -class __staticsystemFileMgr { -public: - __staticsystemFileMgr() { } - ~__staticsystemFileMgr() { delete FileMgr::systemFileMgr; } -} _staticsystemFileMgr; - - -FileMgr *FileMgr::getSystemFileMgr() { - if (!systemFileMgr) - systemFileMgr = new FileMgr(); - - return systemFileMgr; -} - - -void FileMgr::setSystemFileMgr(FileMgr *newFileMgr) { - if (systemFileMgr) - delete systemFileMgr; - systemFileMgr = newFileMgr; -} - -// --------------- end statics -------------- - - -FileDesc::FileDesc(FileMgr *parent, const char *path, int mode, int perms, bool tryDowngrade) { - this->parent = parent; - this->path = 0; - stdstr(&this->path, path); - this->mode = mode; - this->perms = perms; - this->tryDowngrade = tryDowngrade; - offset = 0; - fd = -77; -} - - -FileDesc::~FileDesc() { - if (fd > 0) - close(fd); - - if (path) - delete [] path; -} - - -int FileDesc::getFd() { - if (fd == -77) - fd = parent->sysOpen(this); -// if ((fd < -1) && (fd != -77)) // kludge to hand ce -// return 777; - return fd; -} - - -long FileDesc::seek(long offset, int whence) { - return lseek(getFd(), offset, whence); -} - - -long FileDesc::read(void *buf, long count) { - return ::read(getFd(), buf, count); -} - - -long FileDesc::write(const void *buf, long count) { - return ::write(getFd(), buf, count); -} - - -FileMgr::FileMgr(int maxFiles) { - this->maxFiles = maxFiles; // must be at least 2 - files = 0; -} - - -FileMgr::~FileMgr() { - FileDesc *tmp; - - while(files) { - tmp = files->next; - delete files; - files = tmp; - } -} - - -FileDesc *FileMgr::open(const char *path, int mode, bool tryDowngrade) { - return open(path, mode, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH, tryDowngrade); -} - - -FileDesc *FileMgr::open(const char *path, int mode, int perms, bool tryDowngrade) { - FileDesc **tmp, *tmp2; - - for (tmp = &files; *tmp; tmp = &((*tmp)->next)) { - if ((*tmp)->fd < 0) // insert as first non-system_open file - break; - } - - tmp2 = new FileDesc(this, path, mode, perms, tryDowngrade); - tmp2->next = *tmp; - *tmp = tmp2; - - return tmp2; -} - - -void FileMgr::close(FileDesc *file) { - FileDesc **loop; - - for (loop = &files; *loop; loop = &((*loop)->next)) { - if (*loop == file) { - *loop = (*loop)->next; - delete file; - break; - } - } -} - - -int FileMgr::sysOpen(FileDesc *file) { - FileDesc **loop; - int openCount = 1; // because we are presently opening 1 file, and we need to be sure to close files to accomodate, if necessary - - for (loop = &files; *loop; loop = &((*loop)->next)) { - - if ((*loop)->fd > 0) { - if (++openCount > maxFiles) { - (*loop)->offset = lseek((*loop)->fd, 0, SEEK_CUR); - ::close((*loop)->fd); - (*loop)->fd = -77; - } - } - - if (*loop == file) { - if (*loop != files) { - *loop = (*loop)->next; - file->next = files; - files = file; - } - if ((!access(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) { // check for at least file exists / read access before we try to open - char tries = (((file->mode & O_RDWR) == O_RDWR) && (file->tryDowngrade)) ? 2 : 1; // try read/write if possible - for (int i = 0; i < tries; i++) { - if (i > 0) { - file->mode = (file->mode & ~O_RDWR); // remove write access - file->mode = (file->mode | O_RDONLY);// add read access - } - file->fd = ::open(file->path, file->mode|O_BINARY, file->perms); - - if (file->fd >= 0) - break; - } - - if (file->fd >= 0) - lseek(file->fd, file->offset, SEEK_SET); - } - else file->fd = -1; - if (!*loop) - break; - } - } - return file->fd; -} - - -// to truncate a file at its current position -// leaving byte at current possition intact -// deleting everything afterward. -signed char FileMgr::trunc(FileDesc *file) { - - static const char *writeTest = "x"; - long size = file->seek(1, SEEK_CUR); - if (size == 1) // was empty - size = 0; - char nibble [ 32767 ]; - bool writable = file->write(writeTest, 1); - int bytes = 0; - - if (writable) { - // get tmpfilename - char *buf = new char [ strlen(file->path) + 10 ]; - int i; - for (i = 0; i < 9999; i++) { - sprintf(buf, "%stmp%.4d", file->path, i); - if (!existsFile(buf)) - break; - } - if (i == 9999) - return -2; - - int fd = ::open(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - if (fd < 0) - return -3; - - file->seek(0, SEEK_SET); - while (size > 0) { - bytes = file->read(nibble, 32767); - bytes = (bytes < size)?bytes:size; - if (write(fd, nibble, bytes) != bytes) { break; } - size -= bytes; - } - if (size < 1) { - // zero out the file - ::close(file->fd); - file->fd = ::open(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - ::close(file->fd); - file->fd = -77; // force file open by filemgr - // copy tmp file back (dumb, but must preserve file permissions) - lseek(fd, 0, SEEK_SET); - do { - bytes = read(fd, nibble, 32767); - file->write(nibble, bytes); - } while (bytes == 32767); - } - - ::close(fd); - ::close(file->fd); - removeFile(buf); // remove our tmp file - file->fd = -77; // causes file to be swapped out forcing open on next call to getFd() - } - else { // put offset back and return failure - file->seek(-1, SEEK_CUR); - return -1; - } - return 0; -} - - -signed char FileMgr::existsFile(const char *ipath, const char *ifileName) -{ - int len = strlen(ipath) + ((ifileName)?strlen(ifileName):0) + 3; - char *ch; - char *path = new char [ len ]; - strcpy(path, ipath); - - if ((path[strlen(path)-1] == '\\') || (path[strlen(path)-1] == '/')) - path[strlen(path)-1] = 0; - - if (ifileName) { - ch = path + strlen(path); - sprintf(ch, "/%s", ifileName); - } - signed char retVal = !access(path, 04); - delete [] path; - return retVal; -} - - -signed char FileMgr::existsDir(const char *ipath, const char *idirName) -{ - char *ch; - int len = strlen(ipath) + ((idirName)?strlen(idirName):0) + 1; - if (idirName) - len += strlen(idirName); - char *path = new char [ len ]; - strcpy(path, ipath); - - if ((path[strlen(path)-1] == '\\') || (path[strlen(path)-1] == '/')) - path[strlen(path)-1] = 0; - - if (idirName) { - ch = path + strlen(path); - sprintf(ch, "/%s", idirName); - } - signed char retVal = !access(path, 04); - delete [] path; - return retVal; -} - - -int FileMgr::createParent(const char *pName) { - char *buf = new char [ strlen(pName) + 1 ]; - int retCode = 0; - - strcpy(buf, pName); - int end = strlen(buf) - 1; - while (end) { - if ((buf[end] == '/') || (buf[end] == '\\')) - break; - end--; - } - buf[end] = 0; - if (strlen(buf)>0) { - if (access(buf, 02)) { // not exists with write access? - if ((retCode = mkdir(buf -#ifndef WIN32 - , 0755 -#endif - ))) { - createParent(buf); - retCode = mkdir(buf -#ifndef WIN32 - , 0755 -#endif - ); - } - } - } - else retCode = -1; - delete [] buf; - return retCode; -} - - -int FileMgr::openFileReadOnly(const char *fName) { - int fd = ::open(fName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - return fd; -} - - -int FileMgr::createPathAndFile(const char *fName) { - int fd; - - fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - if (fd < 1) { - createParent(fName); - fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - } - return fd; -} - - -int FileMgr::copyFile(const char *sourceFile, const char *targetFile) { - int sfd, dfd, len; - char buf[4096]; - - if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1) - return -1; - if ((dfd = createPathAndFile(targetFile)) < 1) - return -1; - - do { - len = read(sfd, buf, 4096); - if (write(dfd, buf, len) != len) break; - } - while(len == 4096); - ::close(dfd); - ::close(sfd); - - return 0; -} - - -int FileMgr::removeFile(const char *fName) { - return ::remove(fName); -} - -char FileMgr::getLine(FileDesc *fDesc, SWBuf &line) { - int len; - bool more = true; - char chunk[255]; - - line = ""; - - // assert we have a valid file handle - if (fDesc->getFd() < 1) - return 0; - - while (more) { - more = false; - long index = fDesc->seek(0, SEEK_CUR); - len = fDesc->read(chunk, 254); - - // assert we have a readable file (not a directory) - if (len < 1) - break; - - int start = 0; - // clean up any preceding white space if we're at the beginning of line - if (!line.length()) { - for (;start < len; start++) { - if ((chunk[start] != 13) && (chunk[start] != ' ') && (chunk[start] != '\t')) - break; - } - } - - // find the end - int end; - for (end = start; ((end < (len-1)) && (chunk[end] != 10)); end++); - - if ((chunk[end] != 10) && (len == 254)) { - more = true; - } - index += (end + 1); - - // reposition to next valid place to read - fDesc->seek(index, SEEK_SET); - - // clean up any trailing junk on line if we're at the end - if (!more) { - for (; end > start; end--) { - if ((chunk[end] != 10) && (chunk[end] != 13) && (chunk[end] != ' ') && (chunk[end] != '\t')) { - if (chunk[end] == '\\') { - more = true; - end--; - } - break; - } - } - } - - int size = (end - start) + 1; - - if (size > 0) { - // line.appendFormatted("%.*s", size, chunk+start); - line.append(chunk+start, size); - } - } - return ((len > 0) || line.length()); -} - - -char FileMgr::isDirectory(const char *path) { - struct stat stats; - if (stat(path, &stats)) - return 0; - return ((stats.st_mode & S_IFDIR) == S_IFDIR); -} - - -int FileMgr::copyDir(const char *srcDir, const char *destDir) { - DIR *dir; - struct dirent *ent; - if ((dir = opendir(srcDir))) { - rewinddir(dir); - while ((ent = readdir(dir))) { - if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { - SWBuf srcPath = (SWBuf)srcDir + (SWBuf)"/" + ent->d_name; - SWBuf destPath = (SWBuf)destDir + (SWBuf)"/" + ent->d_name; - if (!isDirectory(srcPath.c_str())) { - copyFile(srcPath.c_str(), destPath.c_str()); - } - else { - copyDir(srcPath.c_str(), destPath.c_str()); - } - } - } - closedir(dir); - } - return 0; -} - - -int FileMgr::removeDir(const char *targetDir) { - DIR *dir = opendir(targetDir); - struct dirent *ent; - if (dir) { - rewinddir(dir); - while ((ent = readdir(dir))) { - if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { - SWBuf targetPath = (SWBuf)targetDir + (SWBuf)"/" + ent->d_name; - if (!isDirectory(targetPath.c_str())) { - FileMgr::removeFile(targetPath.c_str()); - } - else { - FileMgr::removeDir(targetPath.c_str()); - } - } - } - closedir(dir); - FileMgr::removeFile(targetDir); -/* - int status = FileMgr::removeFile(targetDir); - int stuff = errno; - char *err = strerror(errno); - int x = stuff; -*/ - } - return 0; -} - - -void FileMgr::flush() { - FileDesc **loop; - - for (loop = &files; *loop; loop = &((*loop)->next)) { - if ((*loop)->fd > 0) { - (*loop)->offset = lseek((*loop)->fd, 0, SEEK_CUR); - ::close((*loop)->fd); - (*loop)->fd = -77; - } - } -} - -long FileMgr::resourceConsumption() { - long count = 0; - FileDesc **loop; - for (loop = &files; *loop; loop = &((*loop)->next)) { - if ((*loop)->fd > 0) { - count++; - } - } - return count; -} - - -SWORD_NAMESPACE_END diff --git a/.pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c b/.pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c deleted file mode 100644 index a7b7164..0000000 --- a/.pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * untgz.c -- Display contents and/or extract file from - * a gzip'd TAR file - * written by "Pedro A. Aranda Guti\irrez" <paag@tid.es> - * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org> - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <errno.h> -#include <fcntl.h> -#ifdef unix -#include <unistd.h> -#include <sys/stat.h> -#include <sys/types.h> - -#else -# include <direct.h> -# include <io.h> -#endif - -#include "zlib.h" - -#ifdef WIN32 -# include <windows.h> -# ifndef F_OK -# define F_OK (0) -# endif -# ifdef _MSC_VER -# define mkdir(dirname,mode) _mkdir(dirname) -# define strdup(str) _strdup(str) -# define unlink(fn) _unlink(fn) -# define access(path,mode) _access(path,mode) -# else -# define mkdir(dirname,mode) _mkdir(dirname) -# endif -#else -# include <utime.h> -#endif - - -/* Values used in typeflag field. */ - -#define REGTYPE '0' /* regular file */ -#define AREGTYPE '\0' /* regular file */ -#define LNKTYPE '1' /* link */ -#define SYMTYPE '2' /* reserved */ -#define CHRTYPE '3' /* character special */ -#define BLKTYPE '4' /* block special */ -#define DIRTYPE '5' /* directory */ -#define FIFOTYPE '6' /* FIFO special */ -#define CONTTYPE '7' /* reserved */ - -#define BLOCKSIZE 512 - -struct tar_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ -}; - -union tar_buffer { - char buffer[BLOCKSIZE]; - struct tar_header header; -}; - -enum { TGZ_EXTRACT = 0, TGZ_LIST }; - -void TGZnotfound OF((const char *)); - -int getoct OF((char *, int)); -char *strtime OF((time_t *)); -int ExprMatch OF((char *,char *)); - -int makedir OF((char *)); -int matchname OF((int,int,char **,char *)); - -void error OF((const char *)); -int tar OF((gzFile, int, int, int, char **)); - -void help OF((int)); -int main OF((int, char **)); - -char *prog; - -/* This will give a benign warning */ - -static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", ".tar", NULL }; - -/* Return the real name of the TGZ archive */ -/* or NULL if it does not exist. */ - -/* error message for the filename */ - -void TGZnotfound OF((const char *fname)) -{ - int i; - - fprintf(stderr,"%s : couldn't find ",prog); - for (i=0;TGZprefix[i];i++) - fprintf(stderr,(TGZprefix[i+1]) ? "%s%s, " : "or %s%s\n", - fname, - TGZprefix[i]); - exit(1); -} - - -/* help functions */ - -int getoct(char *p,int width) -{ - int result = 0; - char c; - - while (width --) - { - c = *p++; - if (c == ' ') - continue; - if (c == 0) - break; - result = result * 8 + (c - '0'); - } - return result; -} - -char *strtime (time_t *t) -{ - struct tm *local; - static char result[32]; - - local = localtime(t); - sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", - local->tm_mday, local->tm_mon+1, local->tm_year+1900, - local->tm_hour, local->tm_min, local->tm_sec); - return result; -} - - -/* regular expression matching */ - -#define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) - -int ExprMatch(char *string,char *expr) -{ - while (1) - { - if (ISSPECIAL(*expr)) - { - if (*expr == '/') - { - if (*string != '\\' && *string != '/') - return 0; - string ++; expr++; - } - else if (*expr == '*') - { - if (*expr ++ == 0) - return 1; - while (*++string != *expr) - if (*string == 0) - return 0; - } - } - else - { - if (*string != *expr) - return 0; - if (*expr++ == 0) - return 1; - string++; - } - } -} - -/* recursive make directory */ -/* abort if you get an ENOENT errno somewhere in the middle */ -/* e.g. ignore error "mkdir on existing directory" */ -/* */ -/* return 1 if OK */ -/* 0 on error */ - -int makedir (char *newdir) -{ - char *buffer = strdup(newdir); - char *p; - int len = strlen(buffer); - - if (len <= 0) { - free(buffer); - return 0; - } - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mkdir(buffer, 0775) == 0) - { - free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) - { - fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); - free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - free(buffer); - return 1; -} - -int matchname (int arg,int argc,char **argv,char *fname) -{ - if (arg == argc) /* no arguments given (untgz tgzarchive) */ - return 1; - - while (arg < argc) - if (ExprMatch(fname,argv[arg++])) - return 1; - - return 0; /* ignore this for the moment being */ -} - - -/* Tar file list or extract */ - -int untar (gzFile in, const char *dest) { - union tar_buffer buffer; - int len; - int err; - int getheader = 1; - int remaining = 0; - FILE *outfile = NULL; - char fname[BLOCKSIZE]; - time_t tartime; - - while (1) { - len = gzread(in, &buffer, BLOCKSIZE); - if (len < 0) - error (gzerror(in, &err)); - /* - * Always expect complete blocks to process - * the tar information. - */ - if (len != BLOCKSIZE) - error("gzread: incomplete block read"); - - /* - * If we have to get a tar header - */ - if (getheader == 1) { - /* - * if we met the end of the tar - * or the end-of-tar block, - * we are done - */ - if ((len == 0) || (buffer.header.name[0]== 0)) break; - - tartime = (time_t)getoct(buffer.header.mtime,12); - strcpy(fname, dest); - if ((fname[strlen(fname)-1] != '/') && (fname[strlen(fname)-1] != '\\')) - strcat(fname, "/"); - strcat(fname, buffer.header.name); - - switch (buffer.header.typeflag) { - case DIRTYPE: - makedir(fname); - break; - case REGTYPE: - case AREGTYPE: - remaining = getoct(buffer.header.size,12); - if (remaining) { - outfile = fopen(fname,"wb"); - if (outfile == NULL) { - // try creating directory - char *p = strrchr(fname, '/'); - if (p != NULL) { - *p = '\0'; - makedir(fname); - *p = '/'; - outfile = fopen(fname,"wb"); - } - } -/* - fprintf(stderr, - "%s %s\n", - (outfile) ? "Extracting" : "Couldn't create", - fname); -*/ - } - else - outfile = NULL; - /* - * could have no contents - */ - getheader = (remaining) ? 0 : 1; - break; - default: - break; - } - } - else { - unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - - if (outfile != NULL) { - if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) { - fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); - fclose(outfile); - unlink(fname); - } - } - remaining -= bytes; - if (remaining == 0) { - getheader = 1; - if (outfile != NULL) { -#ifdef WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal; - SYSTEMTIME st; - struct tm localt; - - fclose(outfile); - - localt = *localtime(&tartime); - - hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, 0, NULL); - - st.wYear = (WORD)localt.tm_year+1900; - st.wMonth = (WORD)localt.tm_mon; - st.wDayOfWeek = (WORD)localt.tm_wday; - st.wDay = (WORD)localt.tm_mday; - st.wHour = (WORD)localt.tm_hour; - st.wMinute = (WORD)localt.tm_min; - st.wSecond = (WORD)localt.tm_sec; - st.wMilliseconds = 0; - SystemTimeToFileTime(&st,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,NULL,&ftm); - CloseHandle(hFile); - - outfile = NULL; -#else - struct utimbuf settime; - - settime.actime = settime.modtime = tartime; - - fclose(outfile); - outfile = NULL; - utime(fname,&settime); -#endif - } - } - } - } - return 0; -} - - -/* =========================================================== */ - -void help(int exitval) -{ - fprintf(stderr, - "untgz v 0.1\n" - " an sample application of zlib 1.0.4\n\n" - "Usage : untgz TGZfile to extract all files\n" - " untgz TGZfile fname ... to extract selected files\n" - " untgz -l TGZfile to list archive contents\n" - " untgz -h to display this help\n\n"); - exit(exitval); -} - -void error(const char *msg) -{ - fprintf(stderr, "%s: %s\n", prog, msg); -// exit(1); // don't exit on error -} - - -int untargz(int fd, const char *dest) { - gzFile f; - - f = gzdopen(fd, "rb"); - if (f == NULL) { - fprintf(stderr,"%s: Couldn't gzopen file\n", prog); - return 1; - } - - return untar(f, dest); -} |