harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r565262 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c
Date Mon, 13 Aug 2007 08:00:46 GMT
Author: leoli
Date: Mon Aug 13 01:00:45 2007
New Revision: 565262

URL: http://svn.apache.org/viewvc?view=rev&rev=565262
Log:
Fix bug for getPlatformIsReadOnly/getPlatformIsWriteOnly on unix platforms.[root shall have
all permissions to read/write.]

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c?view=diff&rev=565262&r1=565261&r2=565262
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c Mon Aug
13 01:00:45 2007
@@ -142,20 +142,7 @@
 I_32
 getPlatformIsReadOnly (JNIEnv * env, char *path)
 {
-  I_32 result;
-  struct stat buffer;
-
-  result = stat (path, &buffer);
-  if (result == -1)
-    return 0;
-
-  if (buffer.st_uid == geteuid ())
-    return (buffer.st_mode & S_IWUSR) == 0;
-  else if (buffer.st_gid == getegid ())
-    return (buffer.st_mode & S_IWGRP) == 0;
-
-  return (buffer.st_mode & S_IWOTH) == 0;
-
+  return access(path, W_OK) !=0;
 }
 
 /**
@@ -164,20 +151,7 @@
 I_32
 getPlatformIsWriteOnly (JNIEnv * env, char *path)
 {
-  I_32 result;
-  struct stat buffer;
-
-  result = stat (path, &buffer);
-  if (result == -1)
-    return 0;
-
-  if (buffer.st_uid == geteuid ())
-    return (buffer.st_mode & S_IRUSR) == 0;
-  else if (buffer.st_gid == getegid ())
-    return (buffer.st_mode & S_IRGRP) == 0;
-
-  return (buffer.st_mode & S_IROTH) == 0;
-
+  return access(path, R_OK) !=0;
 }
 
 /* Resolve link if it is a symbolic link and put the result in link. */



Mime
View raw message