diff options
author | Allan K. Edwards <ake@apache.org> | 2004-09-22 18:21:30 +0000 |
---|---|---|
committer | Allan K. Edwards <ake@apache.org> | 2004-09-22 18:21:30 +0000 |
commit | 8ff8bda6cdf70bd798afa21f0301490972fd4447 (patch) | |
tree | 2965d9207677278e188ece443c7b6431eda6e446 /file_io | |
parent | 7a3171c8a45d1c73c305aeed40d56343ff39c6f4 (diff) | |
download | apr-8ff8bda6cdf70bd798afa21f0301490972fd4447.tar.gz |
WIN64: first in a series to get Windows IA64 builds clean, this serves pages
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@65340 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/win32/dir.c | 4 | ||||
-rw-r--r-- | file_io/win32/open.c | 4 | ||||
-rw-r--r-- | file_io/win32/readwrite.c | 51 |
3 files changed, 41 insertions, 18 deletions
diff --git a/file_io/win32/dir.c b/file_io/win32/dir.c index ab2d08047..19fe15e8c 100644 --- a/file_io/win32/dir.c +++ b/file_io/win32/dir.c @@ -49,7 +49,7 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, { apr_status_t rv; - int len = strlen(dirname); + apr_size_t len = strlen(dirname); (*new) = apr_pcalloc(pool, sizeof(apr_dir_t)); /* Leave room here to add and pop the '*' wildcard for FindFirstFile * and double-null terminate so we have one character to change. @@ -243,7 +243,7 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, #else char fspec[APR_PATH_MAX]; #endif - int dirlen = strlen(thedir->dirname); + apr_size_t dirlen = strlen(thedir->dirname); if (dirlen >= sizeof(fspec)) dirlen = sizeof(fspec) - 1; apr_cpystrn(fspec, thedir->dirname, sizeof(fspec)); diff --git a/file_io/win32/open.c b/file_io/win32/open.c index e937801f8..973cf3bf5 100644 --- a/file_io/win32/open.c +++ b/file_io/win32/open.c @@ -47,7 +47,7 @@ apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, * Note that the \\?\ form only works for local drive paths, and * \\?\UNC\ is needed UNC paths. */ - int srcremains = strlen(srcstr) + 1; + apr_size_t srcremains = strlen(srcstr) + 1; apr_wchar_t *t = retstr; apr_status_t rv; @@ -101,7 +101,7 @@ apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, * then transform \\'s back into /'s since the \\?\ form never * allows '/' path seperators, and APR always uses '/'s. */ - int srcremains = wcslen(srcstr) + 1; + apr_size_t srcremains = wcslen(srcstr) + 1; apr_status_t rv; char *t = retstr; if (srcstr[0] == L'\\' && srcstr[1] == L'\\' && diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c index b8a5e4be8..4062969b5 100644 --- a/file_io/win32/readwrite.c +++ b/file_io/win32/readwrite.c @@ -27,9 +27,10 @@ * read_with_timeout() * Uses async i/o to emulate unix non-blocking i/o with timeouts. */ -static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len, apr_size_t *nbytes) +static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len_in, apr_size_t *nbytes) { apr_status_t rv; + DWORD len = (DWORD)len_in; *nbytes = 0; /* Handle the zero timeout non-blocking case */ @@ -68,7 +69,8 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le file->pOverlapped->OffsetHigh = (DWORD)(file->filePtr >> 32); } - rv = ReadFile(file->filehand, buf, len, nbytes, file->pOverlapped); + *nbytes = 0; + rv = ReadFile(file->filehand, buf, len, (LPDWORD)nbytes, file->pOverlapped); if (!rv) { rv = apr_get_os_error(); @@ -85,7 +87,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le switch (rv) { case WAIT_OBJECT_0: GetOverlappedResult(file->filehand, file->pOverlapped, - nbytes, TRUE); + (LPDWORD)nbytes, TRUE); rv = APR_SUCCESS; break; case WAIT_TIMEOUT: @@ -286,7 +288,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a thefile->pOverlapped->Offset = (DWORD)thefile->filePtr; thefile->pOverlapped->OffsetHigh = (DWORD)(thefile->filePtr >> 32); } - rv = WriteFile(thefile->filehand, buf, *nbytes, &bwrote, + rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote, thefile->pOverlapped); if (thefile->append) { apr_file_unlock(thefile); @@ -294,7 +296,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a } } else { - rv = WriteFile(thefile->filehand, buf, *nbytes, &bwrote, + rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote, thefile->pOverlapped); } if (rv) { @@ -309,7 +311,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a rv = WaitForSingleObject(thefile->pOverlapped->hEvent, INFINITE); switch (rv) { case WAIT_OBJECT_0: - GetOverlappedResult(thefile->filehand, thefile->pOverlapped, nbytes, TRUE); + GetOverlappedResult(thefile->filehand, thefile->pOverlapped, (LPDWORD)nbytes, TRUE); rv = APR_SUCCESS; break; case WAIT_TIMEOUT: @@ -343,7 +345,7 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, { apr_status_t rv = APR_SUCCESS; apr_size_t i; - DWORD bwrote = 0; + apr_size_t bwrote = 0; char *buf; *nbytes = 0; @@ -361,7 +363,7 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) { - DWORD len = 1; + apr_size_t len = 1; return apr_file_write(thefile, &ch, &len); } @@ -375,7 +377,7 @@ APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) { apr_status_t rc; - int bread; + apr_size_t bread; bread = 1; rc = apr_file_read(thefile, ch, &bread); @@ -393,7 +395,7 @@ APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) { - DWORD len = strlen(str); + apr_size_t len = strlen(str); return apr_file_write(thefile, str, &len); } @@ -431,13 +433,34 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) { if (thefile->buffered) { - DWORD written = 0; + DWORD numbytes, written = 0; apr_status_t rc = 0; + char *buffer; + apr_size_t bytesleft; if (thefile->direction == 1 && thefile->bufpos) { - if (!WriteFile(thefile->filehand, thefile->buffer, thefile->bufpos, &written, NULL)) - rc = apr_get_os_error(); - thefile->filePtr += written; + buffer = thefile->buffer; + bytesleft = thefile->bufpos; + + do { + if (bytesleft > DWORD_MAX) { + numbytes = DWORD_MAX; + } + else { + numbytes = (DWORD)bytesleft; + } + + if (!WriteFile(thefile->filehand, buffer, numbytes, &written, NULL)) { + rc = apr_get_os_error(); + thefile->filePtr += written; + break; + } + + thefile->filePtr += written; + bytesleft -= written; + buffer += written; + + } while (bytesleft > 0); if (rc == 0) thefile->bufpos = 0; |