summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibarchive/libarchive/archive_windows.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmlibarchive/libarchive/archive_windows.c')
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_windows.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.c b/Utilities/cmlibarchive/libarchive/archive_windows.c
index 51860ac..8f5d566 100644
--- a/Utilities/cmlibarchive/libarchive/archive_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_windows.c
@@ -152,6 +152,11 @@ __la_win_permissive_name_w(const wchar_t *wname)
l = GetFullPathNameW(wname, 0, NULL, NULL);
if (l == 0)
return (NULL);
+ /* NOTE: GetFullPathNameW has a bug that if the length of the file
+ * name is just one that return imcomplete buffer size. Thus, we
+ * have to add three to the size to allocate a sufficient buffer
+ * size for the full-pathname of the file name. */
+ l += 3;
wnp = malloc(l * sizeof(wchar_t));
if (wnp == NULL)
return (NULL);
@@ -246,27 +251,6 @@ la_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
return (handle);
}
-/*
- * This fcntl is limited implementation.
- */
-int
-__la_fcntl(int fd, int cmd, int val)
-{
- HANDLE handle;
-
- handle = (HANDLE)_get_osfhandle(fd);
- if (GetFileType(handle) == FILE_TYPE_PIPE) {
- if (cmd == F_SETFL && val == 0) {
- DWORD mode = PIPE_WAIT;
- if (SetNamedPipeHandleState(
- handle, &mode, NULL, NULL) != 0)
- return (0);
- }
- }
- errno = EINVAL;
- return (-1);
-}
-
#if defined(__LA_LSEEK_NEEDED)
__int64
__la_lseek(int fd, __int64 offset, int whence)
@@ -419,22 +403,6 @@ __la_read(int fd, void *buf, size_t nbytes)
if (nbytes == 0)
return (0);
handle = (HANDLE)_get_osfhandle(fd);
- if (GetFileType(handle) == FILE_TYPE_PIPE) {
- DWORD sta;
- if (GetNamedPipeHandleState(
- handle, &sta, NULL, NULL, NULL, NULL, 0) != 0 &&
- (sta & PIPE_NOWAIT) == 0) {
- DWORD avail = -1;
- int cnt = 3;
-
- while (PeekNamedPipe(
- handle, NULL, 0, NULL, &avail, NULL) != 0 &&
- avail == 0 && --cnt)
- Sleep(100);
- if (avail == 0)
- return (0);
- }
- }
r = ReadFile(handle, buf, (uint32_t)nbytes,
&bytes_read, NULL);
if (r == 0) {