You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by le...@apache.org on 2007/08/13 10:00:46 UTC
svn commit: r565262 -
/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c
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. */