summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2022-01-05 16:45:23 +0000
committerIvan Zhakov <ivan@apache.org>2022-01-05 16:45:23 +0000
commit6c1d0718899d50aead2f609048a99a5afd6def5a (patch)
treeffb79ea1d9da3dc6daf51b7d163eddf31d042953 /file_io
parenta62332b821478b2a814834dd249c6e84bd976521 (diff)
downloadapr-6c1d0718899d50aead2f609048a99a5afd6def5a.tar.gz
Remove Windows 95 compatibility code.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896719 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/win32/filestat.c55
-rw-r--r--file_io/win32/flock.c50
-rw-r--r--file_io/win32/open.c9
3 files changed, 36 insertions, 78 deletions
diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c
index 0ab8b2923..ce296af1f 100644
--- a/file_io/win32/filestat.c
+++ b/file_io/win32/filestat.c
@@ -675,42 +675,35 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname,
* to reliably translate char devices to the path '\\.\device'
* so go ask for the full path.
*/
- if (apr_os_level >= APR_WIN_NT)
+ apr_wchar_t tmpname[APR_FILE_MAX];
+ apr_wchar_t *tmpoff = NULL;
+ if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(apr_wchar_t),
+ tmpname, &tmpoff))
{
- apr_wchar_t tmpname[APR_FILE_MAX];
- apr_wchar_t *tmpoff = NULL;
- if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(apr_wchar_t),
- tmpname, &tmpoff))
- {
- if (!wcsncmp(tmpname, L"\\\\.\\", 4)) {
- if (tmpoff == tmpname + 4) {
- finfo->filetype = APR_CHR;
- }
- /* For WHATEVER reason, CHR devices such as \\.\con
- * or \\.\lpt1 *may*not* update tmpoff; in fact the
- * resulting tmpoff is set to NULL. Guard against
- * either case.
- *
- * This code is identical for wide and narrow chars...
- */
- else if (!tmpoff) {
- tmpoff = tmpname + 4;
- while (*tmpoff) {
- if (*tmpoff == '\\' || *tmpoff == '/') {
- break;
- }
- ++tmpoff;
- }
- if (!*tmpoff) {
- finfo->filetype = APR_CHR;
+ if (!wcsncmp(tmpname, L"\\\\.\\", 4)) {
+ if (tmpoff == tmpname + 4) {
+ finfo->filetype = APR_CHR;
+ }
+ /* For WHATEVER reason, CHR devices such as \\.\con
+ * or \\.\lpt1 *may*not* update tmpoff; in fact the
+ * resulting tmpoff is set to NULL. Guard against
+ * either case.
+ *
+ * This code is identical for wide and narrow chars...
+ */
+ else if (!tmpoff) {
+ tmpoff = tmpname + 4;
+ while (*tmpoff) {
+ if (*tmpoff == '\\' || *tmpoff == '/') {
+ break;
}
+ ++tmpoff;
+ }
+ if (!*tmpoff) {
+ finfo->filetype = APR_CHR;
}
}
}
- else {
- finfo->valid &= ~APR_FINFO_TYPE;
- }
-
}
else {
finfo->valid &= ~APR_FINFO_TYPE;
diff --git a/file_io/win32/flock.c b/file_io/win32/flock.c
index 708099a91..f314bdccb 100644
--- a/file_io/win32/flock.c
+++ b/file_io/win32/flock.c
@@ -24,35 +24,11 @@ APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type)
flags = ((type & APR_FLOCK_NONBLOCK) ? LOCKFILE_FAIL_IMMEDIATELY : 0)
+ (((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED)
? 0 : LOCKFILE_EXCLUSIVE_LOCK);
- if (apr_os_level >= APR_WIN_NT) {
- /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
- OVERLAPPED offset;
- memset (&offset, 0, sizeof(offset));
- if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
- return apr_get_os_error();
- }
- else {
- /* On Win9x, LockFile() never blocks. Hack in a crufty poll.
- *
- * Note that this hack exposes threads to being unserviced forever,
- * in the situation that the given lock has low availability.
- * When implemented in the kernel, LockFile will typically use
- * FIFO or round robin distribution to ensure all threads get
- * one crack at the lock; but in this case we can't emulate that.
- *
- * However Win9x are barely maintainable anyways, if the user does
- * choose to build to them, this is the best we can do.
- */
- while (!LockFile(thefile->filehand, 0, 0, len, 0)) {
- DWORD err = GetLastError();
- if ((err == ERROR_LOCK_VIOLATION) && !(type & APR_FLOCK_NONBLOCK))
- {
- Sleep(500); /* pause for a half second */
- continue; /* ... and then poll again */
- }
- return APR_FROM_OS_ERROR(err);
- }
- }
+ /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+ OVERLAPPED offset;
+ memset (&offset, 0, sizeof(offset));
+ if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
+ return apr_get_os_error();
return APR_SUCCESS;
}
@@ -61,17 +37,11 @@ APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile)
{
DWORD len = 0xffffffff;
- if (apr_os_level >= APR_WIN_NT) {
- /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
- OVERLAPPED offset;
- memset (&offset, 0, sizeof(offset));
- if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
- return apr_get_os_error();
- }
- else {
- if (!UnlockFile(thefile->filehand, 0, 0, len, 0))
- return apr_get_os_error();
- }
+ /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+ OVERLAPPED offset;
+ memset (&offset, 0, sizeof(offset));
+ if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
+ return apr_get_os_error();
return APR_SUCCESS;
}
diff --git a/file_io/win32/open.c b/file_io/win32/open.c
index f36fa5ddf..3181d668e 100644
--- a/file_io/win32/open.c
+++ b/file_io/win32/open.c
@@ -268,7 +268,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname,
DWORD oflags = 0;
DWORD createflags = 0;
DWORD attributes = 0;
- DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
apr_status_t rv;
apr_wchar_t wfname[APR_PATH_MAX];
@@ -286,9 +286,6 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname,
oflags |= FILE_WRITE_ATTRIBUTES;
}
- if (apr_os_level >= APR_WIN_NT)
- sharemode |= FILE_SHARE_DELETE;
-
if (flag & APR_FOPEN_CREATE) {
if (flag & APR_FOPEN_EXCL) {
/* only create new if file does not already exist */
@@ -329,9 +326,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname,
*/
if (!(flag & (APR_FOPEN_READ | APR_FOPEN_WRITE))) {
if (flag & APR_OPENINFO) {
- if (apr_os_level >= APR_WIN_NT) {
- attributes |= FILE_FLAG_BACKUP_SEMANTICS;
- }
+ attributes |= FILE_FLAG_BACKUP_SEMANTICS;
}
else {
return APR_EACCES;