BUG: Several Borland fixes
This commit is contained in:
parent
bc447c7f92
commit
9e0633c910
|
@ -75,10 +75,12 @@ FOREACH(file
|
||||||
"stdio.h"
|
"stdio.h"
|
||||||
"string.h"
|
"string.h"
|
||||||
"strings.h"
|
"strings.h"
|
||||||
|
"sys/param.h"
|
||||||
"sys/types.h"
|
"sys/types.h"
|
||||||
"sys/stat.h"
|
"sys/stat.h"
|
||||||
"unistd.h"
|
"unistd.h"
|
||||||
"glob.h"
|
"glob.h"
|
||||||
|
"dirent.h"
|
||||||
)
|
)
|
||||||
CHECK_INCLUDE_FILE_CONCAT("${file}")
|
CHECK_INCLUDE_FILE_CONCAT("${file}")
|
||||||
ENDFOREACH(file)
|
ENDFOREACH(file)
|
||||||
|
@ -293,11 +295,11 @@ SET(libtar_SRC
|
||||||
# compat/strmode.c
|
# compat/strmode.c
|
||||||
# compat/strsep.c
|
# compat/strsep.c
|
||||||
)
|
)
|
||||||
IF(NOT UNIX)
|
IF(NOT HAVE_DIRENT_H)
|
||||||
SET(libtar_SRC
|
SET(libtar_SRC
|
||||||
${libtar_SRC}
|
${libtar_SRC}
|
||||||
filesystem.c filesystem.h)
|
filesystem.c filesystem.h)
|
||||||
ENDIF(NOT UNIX)
|
ENDIF(NOT HAVE_DIRENT_H)
|
||||||
|
|
||||||
IF(NOT HAVE_STRLCPY)
|
IF(NOT HAVE_STRLCPY)
|
||||||
SET(libtar_SRC ${libtar_SRC} compat/strlcpy.c)
|
SET(libtar_SRC ${libtar_SRC} compat/strlcpy.c)
|
||||||
|
|
|
@ -69,8 +69,10 @@ tar_append_file(TAR *t, char *realname, char *savename)
|
||||||
tar_ino_t *ti = NULL;
|
tar_ino_t *ti = NULL;
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
int i;
|
int i;
|
||||||
char path[TAR_MAXPATHLEN];
|
#else
|
||||||
|
size_t plen;
|
||||||
#endif
|
#endif
|
||||||
|
char path[TAR_MAXPATHLEN];
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("==> tar_append_file(TAR=0x%lx (\"%s\"), realname=\"%s\", "
|
printf("==> tar_append_file(TAR=0x%lx (\"%s\"), realname=\"%s\", "
|
||||||
|
@ -79,7 +81,14 @@ tar_append_file(TAR *t, char *realname, char *savename)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
if (stat(realname, &s) != 0)
|
strncpy(path, realname, sizeof(path)-1);
|
||||||
|
path[sizeof(path)-1] = 0;
|
||||||
|
plen = strlen(path);
|
||||||
|
if (path[plen-1] == '/' )
|
||||||
|
{
|
||||||
|
path[plen-1] = 0;
|
||||||
|
}
|
||||||
|
if (stat(path, &s) != 0)
|
||||||
#else
|
#else
|
||||||
if (lstat(realname, &s) != 0)
|
if (lstat(realname, &s) != 0)
|
||||||
#endif
|
#endif
|
||||||
|
@ -126,6 +135,7 @@ tar_append_file(TAR *t, char *realname, char *savename)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
libtar_hashptr_reset(&hp);
|
libtar_hashptr_reset(&hp);
|
||||||
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
if (libtar_hash_getkey(td->td_h, &hp, &(s.st_ino),
|
if (libtar_hash_getkey(td->td_h, &hp, &(s.st_ino),
|
||||||
(libtar_matchfunc_t)ino_match) != 0)
|
(libtar_matchfunc_t)ino_match) != 0)
|
||||||
{
|
{
|
||||||
|
@ -138,6 +148,7 @@ tar_append_file(TAR *t, char *realname, char *savename)
|
||||||
th_set_link(t, ti->ti_name);
|
th_set_link(t, ti->ti_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("+++ adding entry: device (0x%lx,0x%lx), inode %ld "
|
printf("+++ adding entry: device (0x%lx,0x%lx), inode %ld "
|
||||||
|
|
|
@ -36,6 +36,12 @@
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@
|
#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dirent.h> header file. */
|
||||||
|
#cmakedefine HAVE_DIRENT_H @HAVE_DIRENT_H@
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_PARAM_H @HAVE_SYS_PARAM_H@
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `minor_t'. */
|
/* Define to 1 if the system has the type `minor_t'. */
|
||||||
#cmakedefine HAVE_MINOR_T @HAVE_MINOR_T@
|
#cmakedefine HAVE_MINOR_T @HAVE_MINOR_T@
|
||||||
|
|
||||||
|
|
|
@ -156,12 +156,6 @@ th_set_device(TAR *t, dev_t device)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("th_set_device(): major = %d, minor = %d\n",
|
printf("th_set_device(): major = %d, minor = %d\n",
|
||||||
major(device), minor(device));
|
major(device), minor(device));
|
||||||
#endif
|
|
||||||
#ifndef major
|
|
||||||
# define major(dev) ((int)(((dev) >> 8) & 0xff))
|
|
||||||
#endif
|
|
||||||
#ifndef minor
|
|
||||||
# define minor(dev) ((int)((dev) & 0xff))
|
|
||||||
#endif
|
#endif
|
||||||
int_to_oct(major(device), t->th_buf.devmajor, 8);
|
int_to_oct(major(device), t->th_buf.devmajor, 8);
|
||||||
int_to_oct(minor(device), t->th_buf.devminor, 8);
|
int_to_oct(minor(device), t->th_buf.devminor, 8);
|
||||||
|
@ -209,7 +203,8 @@ th_set_mode(TAR *t, mode_t fmode)
|
||||||
fmode |= S_IFIFO;
|
fmode |= S_IFIFO;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int_to_oct(fmode, (t)->th_buf.mode, 8);
|
/* Looks like on windows the st_mode is longer than 8 characters. */
|
||||||
|
int_to_oct(fmode & 07777777, (t)->th_buf.mode, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,3 +14,10 @@
|
||||||
#include <libtar/compat.h>
|
#include <libtar/compat.h>
|
||||||
|
|
||||||
#include <libtar/libtar.h>
|
#include <libtar/libtar.h>
|
||||||
|
|
||||||
|
#ifndef major
|
||||||
|
# define major(dev) ((int)(((dev) >> 8) & 0xff))
|
||||||
|
#endif
|
||||||
|
#ifndef minor
|
||||||
|
# define minor(dev) ((int)((dev) & 0xff))
|
||||||
|
#endif
|
||||||
|
|
|
@ -110,8 +110,8 @@ th_print_long_ls(TAR *t)
|
||||||
if (TH_ISCHR(t) || TH_ISBLK(t))
|
if (TH_ISCHR(t) || TH_ISBLK(t))
|
||||||
printf(" %3d, %3d ", th_get_devmajor(t), th_get_devminor(t));
|
printf(" %3d, %3d ", th_get_devmajor(t), th_get_devminor(t));
|
||||||
else
|
else
|
||||||
printf("%9ld ", (long)th_get_size(t));
|
|
||||||
#endif
|
#endif
|
||||||
|
printf("%9ld ", (long)th_get_size(t));
|
||||||
|
|
||||||
mtime = th_get_mtime(t);
|
mtime = th_get_mtime(t);
|
||||||
mtm = localtime(&mtime);
|
mtm = localtime(&mtime);
|
||||||
|
|
|
@ -103,12 +103,24 @@ mkdirhier(char *path)
|
||||||
if (dst[0] != '\0')
|
if (dst[0] != '\0')
|
||||||
strcat(dst, "/");
|
strcat(dst, "/");
|
||||||
strcat(dst, dirp);
|
strcat(dst, dirp);
|
||||||
|
if (
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
if (mkdir(dst) == -1)
|
mkdir(dst) == -1
|
||||||
#else
|
#else
|
||||||
if (mkdir(dst, 0777) == -1)
|
mkdir(dst, 0777) == -1
|
||||||
#endif
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
/* There is a bug in the Borland Run time library which makes MKDIR
|
||||||
|
return EACCES when it should return EEXIST
|
||||||
|
if it is some other error besides directory exists
|
||||||
|
then return false */
|
||||||
|
if ( errno == EACCES)
|
||||||
|
{
|
||||||
|
errno = EEXIST;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,13 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <libtar/compat.h>
|
#include <libtar/compat.h>
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(HAVE_SYS_PARAM_H)
|
||||||
#include <libtarint/filesystem.h>
|
|
||||||
#else
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_DIRENT_H)
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#else
|
||||||
|
#include <libtarint/filesystem.h>
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -102,7 +104,8 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
|
||||||
{
|
{
|
||||||
char realpath[TAR_MAXPATHLEN];
|
char realpath[TAR_MAXPATHLEN];
|
||||||
char savepath[TAR_MAXPATHLEN];
|
char savepath[TAR_MAXPATHLEN];
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
size_t plen;
|
||||||
|
#if defined(HAVE_DIRENT_H)
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
#else
|
#else
|
||||||
|
@ -110,6 +113,14 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
|
||||||
kwDirectory *dp;
|
kwDirectory *dp;
|
||||||
#endif
|
#endif
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
strncpy(realpath, realdir, sizeof(realpath));
|
||||||
|
realpath[sizeof(realpath)-1] = 0;
|
||||||
|
plen = strlen(realpath);
|
||||||
|
if ( realpath[plen-1] == '/' )
|
||||||
|
{
|
||||||
|
realpath[plen-1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("==> tar_append_tree(0x%lx, \"%s\", \"%s\")\n",
|
printf("==> tar_append_tree(0x%lx, \"%s\", \"%s\")\n",
|
||||||
|
@ -123,10 +134,22 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
|
||||||
puts(" tar_append_tree(): done with tar_append_file()...");
|
puts(" tar_append_tree(): done with tar_append_file()...");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ( stat(realpath, &s) != 0 )
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
dp = kwOpenDir(realdir);
|
(s.st_mode & _S_IFDIR) == 0
|
||||||
#else
|
#else
|
||||||
|
!S_ISDIR(s.st_mode)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
return 0;
|
||||||
|
#if defined(HAVE_DIRENT_H)
|
||||||
dp = opendir(realdir);
|
dp = opendir(realdir);
|
||||||
|
#else
|
||||||
|
dp = kwOpenDir(realdir);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dp == NULL)
|
if (dp == NULL)
|
||||||
|
@ -135,10 +158,10 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(HAVE_DIRENT_H)
|
||||||
while ((dent = kwReadDir(dp)) != NULL)
|
|
||||||
#else
|
|
||||||
while ((dent = readdir(dp)) != NULL)
|
while ((dent = readdir(dp)) != NULL)
|
||||||
|
#else
|
||||||
|
while ((dent = kwReadDir(dp)) != NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (strcmp(dent->d_name, ".") == 0 ||
|
if (strcmp(dent->d_name, ".") == 0 ||
|
||||||
|
@ -171,10 +194,10 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(HAVE_DIRENT_H)
|
||||||
kwCloseDir(dp);
|
|
||||||
#else
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
|
#else
|
||||||
|
kwCloseDir(dp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue