diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2006-12-04 22:26:41 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2006-12-04 22:26:41 (GMT) |
commit | 3a32cec96923cf057aad00274b4a8ab7ad82a82f (patch) | |
tree | 304527c04dbad8b51ce2bccda1a434f424bf1a9a /Utilities/cmtar | |
parent | de8ffcaef492e23af57ed5489dd8a21fdd7ad5d8 (diff) | |
download | CMake-3a32cec96923cf057aad00274b4a8ab7ad82a82f.zip CMake-3a32cec96923cf057aad00274b4a8ab7ad82a82f.tar.gz CMake-3a32cec96923cf057aad00274b4a8ab7ad82a82f.tar.bz2 |
ENH: merge in changes for beos support
Diffstat (limited to 'Utilities/cmtar')
-rw-r--r-- | Utilities/cmtar/encode.c | 2 | ||||
-rw-r--r-- | Utilities/cmtar/extract.c | 20 | ||||
-rw-r--r-- | Utilities/cmtar/libtar.c | 9 | ||||
-rw-r--r-- | Utilities/cmtar/util.c | 7 |
4 files changed, 31 insertions, 7 deletions
diff --git a/Utilities/cmtar/encode.c b/Utilities/cmtar/encode.c index 3c8cb6a..1c75954 100644 --- a/Utilities/cmtar/encode.c +++ b/Utilities/cmtar/encode.c @@ -197,12 +197,14 @@ void th_set_mode(TAR *t, mode_t fmode) { #ifndef WIN32 +#ifndef __BEOS__ if (S_ISSOCK(fmode)) { fmode &= ~S_IFSOCK; fmode |= S_IFIFO; } #endif +#endif /* Looks like on windows the st_mode is longer than 8 characters. */ int_to_oct(fmode & 07777777, (t)->th_buf.mode, 8); } diff --git a/Utilities/cmtar/extract.c b/Utilities/cmtar/extract.c index cb1fab3..925f621 100644 --- a/Utilities/cmtar/extract.c +++ b/Utilities/cmtar/extract.c @@ -116,7 +116,7 @@ tar_set_file_perms(TAR *t, char *realname) return -1; } /* change permissions */ - if (!TH_ISSYM(t) && chmod(filename, mode) == -1) + if (!TH_ISSYM(t) && chmod(filename, mode & 07777) == -1) { #ifdef DEBUG perror("chmod()"); @@ -718,6 +718,7 @@ tar_extract_dir(TAR *t, char *realname) char *filename; char buf[T_BLOCKSIZE]; char *pathname = 0; + size_t len = 0; if (!TH_ISDIR(t)) { @@ -750,14 +751,23 @@ tar_extract_dir(TAR *t, char *realname) return -1; } + /* Strip trailing '/'...it confuses some Unixes (and BeOS)... */ + strncpy(buf, filename, sizeof(buf)-1); + buf[sizeof(buf)-1] = 0; + len = strlen(buf); + if ((len > 0) && (buf[len-1] == '/')) + { + buf[len-1] = '\0'; + } + #ifdef DEBUG printf(" ==> extracting: %s (mode %04o, directory)\n", filename, mode); #endif #ifdef WIN32 - if (mkdir(filename) == -1) + if (mkdir(buf) == -1) #else - if (mkdir(filename, mode) == -1) + if (mkdir(buf, mode & 07777) == -1) #endif { #ifdef __BORLANDC__ @@ -772,7 +782,7 @@ tar_extract_dir(TAR *t, char *realname) #endif if (errno == EEXIST) { - if (chmod(filename, mode) == -1) + if (chmod(filename, mode & 07777) == -1) { #ifdef DEBUG perror("chmod()"); @@ -860,7 +870,7 @@ tar_extract_fifo(TAR *t, char *realname) printf(" ==> extracting: %s (fifo)\n", filename); #endif #ifndef WIN32 - if (mkfifo(filename, mode) == -1) + if (mkfifo(filename, mode & 07777) == -1) #else (void)mode; #endif diff --git a/Utilities/cmtar/libtar.c b/Utilities/cmtar/libtar.c index 362c105..b19d043 100644 --- a/Utilities/cmtar/libtar.c +++ b/Utilities/cmtar/libtar.c @@ -99,8 +99,13 @@ static int libtar_gzopen(void* call_data, const char *pathname, return -1; } -#if !defined(_WIN32) || defined(__CYGWIN__) - if ((oflags & O_CREAT) && fchmod(fd, mode)) +#if defined(__BEOS__) && !defined(__ZETA__) // no fchmod on BeOS...do pathname instead. + if ((oflags & O_CREAT) && chmod(pathname, mode & 07777)) + { + return -1; + } +#elif !defined(_WIN32) || defined(__CYGWIN__) + if ((oflags & O_CREAT) && fchmod(fd, mode & 07777)) { return -1; } diff --git a/Utilities/cmtar/util.c b/Utilities/cmtar/util.c index 94cf544..550fb93 100644 --- a/Utilities/cmtar/util.c +++ b/Utilities/cmtar/util.c @@ -100,6 +100,13 @@ mkdirhier(char *path) if (*dirp == '\0') continue; + /* + * Don't try to build current or parent dir. It doesn't make sense anyhow, + * but it also returns EINVAL instead of EEXIST on BeOS! + */ + if ((strcmp(dirp, ".") == 0) || (strcmp(dirp, "..") == 0)) + continue; + if (dst[0] != '\0') strcat(dst, "/"); strcat(dst, dirp); |