commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r806100 - in /commons/sandbox/runtime/trunk/src/main/native/os: hpux/pgroup.c hpux/puser.c linux/pgroup.c linux/puser.c unix/dso.c unix/file.c unix/group.c unix/user.c win32/file.c
Date Thu, 20 Aug 2009 09:42:20 GMT
Author: mturk
Date: Thu Aug 20 09:42:20 2009
New Revision: 806100

URL: http://svn.apache.org/viewvc?rev=806100&view=rev
Log:
Use THROW macros instead repeating the code all over the place

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/puser.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c Thu Aug 20 09:42:20 2009
@@ -43,11 +43,7 @@
         errno = 0;
         gr = getgrent();
         if (gr == NULL && n == 0) {
-            if  (ACR_STATUS_IS_EACCES(ACR_GET_OS_ERROR()))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                   ACR_GET_OS_ERROR());
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         if (gr == NULL)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c Thu Aug 20 09:42:20 2009
@@ -43,11 +43,7 @@
         errno = 0;
         pw = getpwent();
         if (pw == NULL && n == 0) {
-            if  (ACR_STATUS_IS_EACCES(ACR_GET_OS_ERROR()))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                   ACR_GET_OS_ERROR());
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         if (pw == NULL)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c Thu Aug 20 09:42:20 2009
@@ -45,11 +45,7 @@
     while (1) {
         rc = getgrent_r(&grp, buffer, sizeof(buffer), &gr);
         if (rc && n == 0) {
-            if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                    ACR_FROM_OS_ERROR(rc));
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         if (rc || gr == NULL)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/puser.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/puser.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/puser.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/puser.c Thu Aug 20 09:42:20 2009
@@ -45,11 +45,7 @@
     while (1) {
         rc = getpwent_r(&usr, buffer, sizeof(buffer), &pw);
         if (rc && n == 0) {
-            if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                    ACR_FROM_OS_ERROR(rc));
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         if (rc || pw == NULL)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c Thu Aug 20 09:42:20 2009
@@ -53,7 +53,7 @@
     handle = dlopen(path, flags);
     if (handle == NULL) {
         rc = ACR_GET_OS_ERROR();
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EIO, dlerror());
         }
         ACR_SET_OS_ERROR(rc);
@@ -69,12 +69,8 @@
     int rv;
 
     rv = acr_ioh_close(dso);
-    if (rv  && !IS_INVALID_HANDLE(_E)) {
-        if (rv == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rv);
-    }
+
+    ACR_THROW_IO_IF_ERR(rv);
     return rv;
 }
 
@@ -91,7 +87,7 @@
         void *retval = dlsym(handle, symname);
         if (retval == NULL) {
             rc = ACR_GET_OS_ERROR();
-            if (!IS_INVALID_HANDLE(_E)) {
+            if (IS_VALID_HANDLE(_E)) {
                 ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EIO, dlerror());
             }
             ACR_SET_OS_ERROR(rc);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Thu Aug 20 09:42:20 2009
@@ -103,10 +103,7 @@
          * include the operating system you are using.
          */
 #endif
-        if (errno == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, errno);
+        ACR_THROW_IO_ERRNO();
     }
     return -1;
 }
@@ -126,7 +123,7 @@
 ACR_IO_EXPORT_DECLARE(jlong, File, inode0)(ACR_JNISTDARGS, jstring pathname)
 {
     jlong rv = 0;
-    int   ex = EINVAL;
+    int   ex = ACR_EINVAL;
 
     UNREFERENCED_O;
     WITH_CSTR(pathname) {
@@ -139,14 +136,7 @@
             ex = ACR_GET_OS_ERROR();
     } END_WITH_CSTR(pathname);
 
-    if (ex) {
-        if (ACR_STATUS_IS_EACCES(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        }
-        else if (!ACR_STATUS_IS_EEXIST(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-        }
-    }
+    ACR_THROW_IO_IF_ERR(ex);
     return rv;
 }
 
@@ -234,14 +224,7 @@
         }
     } END_WITH_CSTR(lnkname);
 
-    if (ex) {
-        if (ACR_STATUS_IS_EACCES(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        }
-        else if (!ACR_STATUS_IS_EEXIST(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-        }
-    }
+    ACR_THROW_IO_IF_ERR(ex);
     return rv;
 }
 
@@ -326,13 +309,7 @@
     if (stat(fname, &info) == 0) {
         return ACR_UnixModeToPerms(info.st_mode);
     }
-    else if (_E) {
-        if (errno == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                               ACR_GET_OS_ERROR());
-    }
+    ACR_THROW_IO_ERRNO();
     return -1;
 }
 
@@ -342,13 +319,7 @@
     if (chmod(fname, ACR_UnixPermsToMode(prot)) == 0) {
         return 0;
     }
-    else if (_E) {
-        if (errno == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                               ACR_GET_OS_ERROR());
-    }
+    ACR_THROW_IO_ERRNO();
     return ACR_GET_OS_ERROR();
 }
 
@@ -397,15 +368,8 @@
             ex = 0;
     } END_WITH_CSTR(pathname);
 
-    if (ex) {
-        if  (ACR_STATUS_IS_EACCES(ex))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-        return JNI_FALSE;
-    }
-    else
-        return JNI_TRUE;
+    ACR_THROW_IO_IF_ERR(ex);
+    return ex == 0 ? JNI_TRUE : JNI_FALSE;
 }
 
 ACR_IO_EXPORT_DECLARE(jboolean, File, attrs0)(ACR_JNISTDARGS, jstring pathname,

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c Thu Aug 20 09:42:20 2009
@@ -104,13 +104,11 @@
 
     rc = getgrnam_r(name, &grb, buffer, sizeof(buffer), &gr);
     if (rc) {
-        if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc)))
-            return NULL;
-        else if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                ACR_FROM_OS_ERROR(rc));
+        rc = ACR_GET_OS_ERROR();
+        if (ACR_STATUS_IS_ENOENT(rc)) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
+        return NULL;
     }
     if (!gr)
         return NULL;
@@ -148,13 +146,11 @@
 
     rc = getgrgid_r(id, &grb, buffer, sizeof(buffer), &gr);
     if (rc) {
-        if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc)))
-            return NULL;
-        else if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                ACR_FROM_OS_ERROR(rc));
+        rc = ACR_GET_OS_ERROR();
+        if (ACR_STATUS_IS_ENOENT(rc)) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
+        return NULL;
     }
     if (!gr)
         return NULL;
@@ -256,13 +252,11 @@
 
     rc = getgrgid_r(gid, &grb, buffer, sizeof(buffer), &gr);
     if (rc) {
-        if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc)))
-            return NULL;
-        else if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                ACR_FROM_OS_ERROR(rc));
+        rc = ACR_GET_OS_ERROR();
+        if (ACR_STATUS_IS_ENOENT(rc)) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
+        return NULL;
     }
     if (!gr || !gr->gr_mem)
         return NULL;
@@ -284,3 +278,4 @@
     }
     return usrs;
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c Thu Aug 20 09:42:20 2009
@@ -119,13 +119,10 @@
 
     rc = getpwnam_r(name, &pwb, buffer, sizeof(buffer), &pw);
     if (rc) {
-        if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc)))
-            return NULL;
-        else if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                ACR_FROM_OS_ERROR(rc));
+        rc = ACR_GET_OS_ERROR();
+        if (ACR_STATUS_IS_ENOENT(rc)) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
         return NULL;
     }
     if (!pw)
@@ -169,13 +166,10 @@
 
     rc = getpwuid_r(id, &pwb, buffer, sizeof(buffer), &pw);
     if (rc) {
-        if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc)))
-            return NULL;
-        else if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                ACR_FROM_OS_ERROR(rc));
+        rc = ACR_GET_OS_ERROR();
+        if (ACR_STATUS_IS_ENOENT(rc)) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
         return NULL;
     }
     if (!pw)
@@ -271,11 +265,7 @@
         errno = 0;
         ut = getutxent();
         if (ut == NULL && n == 0) {
-            if  (ACR_STATUS_IS_EACCES(ACR_GET_OS_ERROR()))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR,
-                                   ACR_GET_OS_ERROR());
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         if (ut == NULL)
@@ -315,3 +305,4 @@
     ACR_TableFree(_E, THROW_FMARK, utbl);
     return usrs;
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=806100&r1=806099&r2=806100&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Thu Aug 20 09:42:20 2009
@@ -114,9 +114,9 @@
         }
         return type;
     }
-    else if (_E) {
+    else {
         /* Throw exception */
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_GET_OS_ERROR());
+        ACR_THROW_IO_ERRNO();
     }
     return -1;
 }
@@ -149,12 +149,8 @@
     }
     else
         ex = ACR_GET_OS_ERROR();
-    if (ex) {
-        rv = 0;
-        ACR_SET_OS_ERROR(ex);
-        if (!IS_INVALID_HANDLE(_E))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-    }
+
+    ACR_THROW_IO_IF_ERR(ex);
     return rv;
 }
 
@@ -195,12 +191,12 @@
         }
         if (ACR_HAVE_LATE_DLL_FUNC(CreateSymbolicLinkW)) {
             if (!CreateSymbolicLinkW(J2W(lnkname), J2W(target), dwFlags)) {
-                int err = ACR_GET_OS_ERROR();
-                if (ACR_STATUS_IS_EACCES(err)) {
+                int ex = ACR_GET_OS_ERROR();
+                if (ACR_STATUS_IS_EACCES(ex)) {
                     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
                 }
-                else if (!ACR_STATUS_IS_EEXIST(err)) {
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, err);
+                else if (!ACR_STATUS_IS_EEXIST(ex)) {
+                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
                 }
             }
             else
@@ -219,8 +215,13 @@
                 goto bailout;
             }
             if (!GetFullPathNameW(J2W(target), ACR_HBUFF_LEN,  fpath, NULL)) {
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                                   ACR_GET_OS_ERROR());
+                int ex = ACR_GET_OS_ERROR();
+                if (ACR_STATUS_IS_EACCES(ex)) {
+                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
+                }
+                else if (!ACR_STATUS_IS_EEXIST(ex)) {
+                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
+                }
                 goto bailout;
             }
             tlen = wcslen(fpath);
@@ -231,8 +232,7 @@
             RemoveDirectoryW(J2W(lnkname));
             if (!CreateDirectoryW(J2W(lnkname), NULL)) {
                 /* Failed to create link name directory */
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                                   ACR_GET_OS_ERROR());
+                ACR_THROW_IO_ERRNO();
                 goto bailout;
             }
             if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
{
@@ -253,8 +253,7 @@
                                 FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
                                 NULL);
             if (hlink == INVALID_HANDLE_VALUE) {
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                                   ACR_GET_OS_ERROR());
+                ACR_THROW_IO_ERRNO();
                 goto bailout;
             }
             rdb = (PREPARSE_DATA_BUFFER)mpb;
@@ -271,8 +270,7 @@
             if (!DeviceIoControl(hlink, FSCTL_SET_REPARSE_POINT,
                                  rdb, rdb->ReparseDataLength + 8,
                                  NULL, 0, &dlen, NULL)) {
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                                   ACR_GET_OS_ERROR());
+                ACR_THROW_IO_ERRNO();
             }
             else {
                 rc = JNI_TRUE;
@@ -282,7 +280,7 @@
         else {
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENOTIMPL, 0);
         }
-        bailout:
+bailout:
         if (mpb)
             free(mpb);
     } END_WITH_WSTR(lnkname);
@@ -303,12 +301,12 @@
         FS2BS(J2W(target));
         FS2BS(J2W(lnkname));
         if (!CreateHardLinkW(J2W(lnkname), J2W(target), NULL)) {
-            int err = ACR_GET_OS_ERROR();
-            if (ACR_STATUS_IS_EACCES(err)) {
+            int ex = ACR_GET_OS_ERROR();
+            if (ACR_STATUS_IS_EACCES(ex)) {
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             }
-            else if (!ACR_STATUS_IS_EEXIST(err)) {
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, err);
+            else if (!ACR_STATUS_IS_EEXIST(ex)) {
+                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
             }
         }
         else
@@ -403,9 +401,8 @@
         }
 
     } END_WITH_WSTR(lnkname);
-    if (ex) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-    }
+
+    ACR_THROW_IO_IF_ERR(ex);
     return rv;
 }
 
@@ -495,7 +492,7 @@
 
 ACR_DECLARE(int) ACR_FileProtectionGet(JNIEnv *_E, wchar_t *fname)
 {
-    int protection = 0;
+    int rv = 0;
     PSID user = NULL, group = NULL;
     PACL dacl = NULL;
     PSECURITY_DESCRIPTOR ppsd = NULL;
@@ -511,36 +508,32 @@
                                NULL,
                                &ppsd);
     if (rc == ERROR_SUCCESS) {
-        rc = resolve_prot(user, group, dacl);
-        if (rc >= 0) {
+        rv = resolve_prot(user, group, dacl);
+        if (rv >= 0) {
             DWORD flags = GetFileAttributesW(fname);
             if (flags != 0xFFFFFFFF) {
                 if (flags & FILE_ATTRIBUTE_READONLY) {
                     /* Clear any WRITE attributes */
-                    rc &= ~ACR_FPROT_UWRITE;
-                    rc &= ~ACR_FPROT_GWRITE;
-                    rc &= ~ACR_FPROT_WWRITE;
+                    rv &= ~ACR_FPROT_UWRITE;
+                    rv &= ~ACR_FPROT_GWRITE;
+                    rv &= ~ACR_FPROT_WWRITE;
                 }
                 if (flags & FILE_ATTRIBUTE_HIDDEN) {
                     /* XXX: Hidden files are non-executable? */
-                    rc &= ~ACR_FPROT_UEXECUTE;
-                    rc &= ~ACR_FPROT_GEXECUTE;
-                    rc &= ~ACR_FPROT_WEXECUTE;
+                    rv &= ~ACR_FPROT_UEXECUTE;
+                    rv &= ~ACR_FPROT_GEXECUTE;
+                    rv &= ~ACR_FPROT_WEXECUTE;
                 }
             }
         }
     }
-    else if (_E) {
-        if  (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc)))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
-                               ACR_FROM_OS_ERROR(rc));
-        rc = -1;
+    else {
+        ACR_THROW_IO_ERRNO();
+        rv = -1;
     }
     if (ppsd)
         LocalFree((HLOCAL)ppsd);
-    return rc;
+    return rv;
 }
 
 static PACL update_prot(PSID user, PSID group, PACL dacl, int prot)
@@ -650,13 +643,7 @@
     return 0;
 
 failed:
-    rc = ACR_FROM_OS_ERROR(rc);
-    if (_E) {
-        if  (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     if (ppsd)
         LocalFree((HLOCAL)ppsd);
     if (eacl)
@@ -737,11 +724,7 @@
     if (rc == ERROR_SUCCESS)
         return JNI_TRUE;
     else {
-        rc = ACR_FROM_OS_ERROR(rc);
-        if  (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+        ACR_THROW_IO_ERRNO();
         return JNI_FALSE;
     }
 }
@@ -810,11 +793,7 @@
     if (rc == ERROR_SUCCESS)
         return JNI_TRUE;
     else {
-        rc = ACR_FROM_OS_ERROR(rc);
-        if  (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+        ACR_THROW_IO_ERRNO();
         return JNI_FALSE;
     }
 }
@@ -835,14 +814,7 @@
             ex = 0;
     } END_WITH_WSTR(pathname);
 
-    if (ex) {
-        if (ACR_STATUS_IS_EACCES(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        }
-        else if (!ACR_STATUS_IS_EEXIST(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-        }
-    }
+    ACR_THROW_IO_IF_ERR(ex);
     return rv;
 }
 
@@ -870,14 +842,7 @@
             ex = ACR_GET_OS_ERROR();
     } END_WITH_WSTR(pathname);
 
-    if (ex) {
-        if (ACR_STATUS_IS_EACCES(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        }
-        else if (!ACR_STATUS_IS_EEXIST(ex)) {
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
-        }
-    }
+    ACR_THROW_IO_IF_ERR(ex);
     return attr;
 }
 



Mime
View raw message