Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

GRADLE-2149: Replace PosixWrapper usage by FallbackPOSIX & FallbackFi…

…leStat

- FallbackPOSIX used on Windows- and unknown- platform
- FallbackPOSIX#chmod() returns 0.
- FallbackPOSIX#symlink() returns 0.
- FallbackPOSIX#stat() returns FallbackFileStat
- Other FallbackPOSIX methods return UnsupportedOperationException
- FallbackFileStat#mode() returns FileSystem.DEFAULT_DIR_MODE for directories
- FallbackFileStat#mode() returns FileSystem.DEFAULT_FILE_MODE for files
- Other FallbackFileStat methods return UnsupportedOperationException
  • Loading branch information...
commit ec41b8b472016dba3c3ff6196fecf1c779cf376b 1 parent e2e0d10
Rene Groeschke authored March 29, 2012
441  subprojects/native/src/main/java/org/gradle/internal/nativeplatform/PosixWrapper.java
... ...
@@ -1,441 +0,0 @@
1  
-/*
2  
- * Copyright 2012 the original author or authors.
3  
- *
4  
- * Licensed under the Apache License, Version 2.0 (the "License");
5  
- * you may not use this file except in compliance with the License.
6  
- * You may obtain a copy of the License at
7  
- *
8  
- *      http://www.apache.org/licenses/LICENSE-2.0
9  
- *
10  
- * Unless required by applicable law or agreed to in writing, software
11  
- * distributed under the License is distributed on an "AS IS" BASIS,
12  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  
- * See the License for the specific language governing permissions and
14  
- * limitations under the License.
15  
- */
16  
-
17  
-package org.gradle.internal.nativeplatform;
18  
-
19  
-import org.gradle.internal.nativeplatform.filesystem.FileSystem;
20  
-import org.jruby.ext.posix.*;
21  
-
22  
-import java.io.FileDescriptor;
23  
-import java.io.IOException;
24  
-
25  
-/**
26  
- * Util class to wrap / modify results of calls to the {@link org.jruby.ext.posix.POSIXFactory#getPOSIX(org.jruby.ext.posix.POSIXHandler, boolean)}
27  
- * */
28  
-public class PosixWrapper {
29  
-
30  
-    public static POSIX wrap(POSIX posix) {
31  
-        if (posix instanceof JavaPOSIX) {
32  
-            return new ChmodDisabledFallbackPOSIX(posix);
33  
-        } else if (posix instanceof WindowsPOSIX) {
34  
-            return new FilePermissionFallbackPOSIX(posix);
35  
-        } else {
36  
-            return posix;
37  
-        }
38  
-    }
39  
-
40  
-    private static class ChmodDisabledFallbackPOSIX extends FilePermissionFallbackPOSIX {
41  
-
42  
-        public ChmodDisabledFallbackPOSIX(POSIX posix) {
43  
-            super(posix);
44  
-        }
45  
-
46  
-        public int chmod(String filename, int mode) {
47  
-            // short circuit this call to return incoming mode
48  
-            return mode;
49  
-        }
50  
-    }
51  
-
52  
-    private static class FilePermissionFallbackPOSIX extends DelegatePOSIX{
53  
-        public FilePermissionFallbackPOSIX(POSIX posix) {
54  
-            super(posix);
55  
-        }
56  
-
57  
-        public FileStat stat(String path) {
58  
-            return new FallbackFileStat(super.stat(path));
59  
-        }
60  
-    }
61  
-
62  
-    /**
63  
-     * a Plain DelegatePosix to keep own posix implementations "clean"
64  
-     * */
65  
-    private abstract static class DelegatePOSIX implements POSIX {
66  
-        private POSIX delegate;
67  
-
68  
-        public DelegatePOSIX(POSIX posix) {
69  
-            this.delegate = posix;
70  
-        }
71  
-
72  
-        public int chmod(String filename, int mode) {
73  
-            return delegate.chmod(filename, mode);
74  
-        }
75  
-
76  
-        public int chown(String filename, int user, int group) {
77  
-            return delegate.chown(filename, user, group);
78  
-        }
79  
-
80  
-        public int fork() {
81  
-            return delegate.fork();
82  
-        }
83  
-
84  
-        public FileStat fstat(FileDescriptor descriptor) {
85  
-            return delegate.fstat(descriptor);
86  
-        }
87  
-
88  
-        public int getegid() {
89  
-            return delegate.getegid();
90  
-        }
91  
-
92  
-        public int geteuid() {
93  
-            return delegate.geteuid();
94  
-        }
95  
-
96  
-        public int seteuid(int euid) {
97  
-            return delegate.seteuid(euid);
98  
-        }
99  
-
100  
-        public int getgid() {
101  
-            return delegate.getgid();
102  
-        }
103  
-
104  
-        public String getlogin() {
105  
-            return delegate.getlogin();
106  
-        }
107  
-
108  
-        public int getpgid() {
109  
-            return delegate.getpgid();
110  
-        }
111  
-
112  
-        public int getpgid(int pid) {
113  
-            return delegate.getpgid(pid);
114  
-        }
115  
-
116  
-        public int getpgrp() {
117  
-            return delegate.getpgrp();
118  
-        }
119  
-
120  
-        public int getpid() {
121  
-            return delegate.getpid();
122  
-        }
123  
-
124  
-        public int getppid() {
125  
-            return delegate.getppid();
126  
-        }
127  
-
128  
-        public int getpriority(int which, int who) {
129  
-            return delegate.getpriority(which, who);
130  
-        }
131  
-
132  
-        public Passwd getpwent() {
133  
-            return delegate.getpwent();
134  
-        }
135  
-
136  
-        public Passwd getpwuid(int which) {
137  
-            return delegate.getpwuid(which);
138  
-        }
139  
-
140  
-        public Passwd getpwnam(String which) {
141  
-            return delegate.getpwnam(which);
142  
-        }
143  
-
144  
-        public Group getgrgid(int which) {
145  
-            return delegate.getgrgid(which);
146  
-        }
147  
-
148  
-        public Group getgrnam(String which) {
149  
-            return delegate.getgrnam(which);
150  
-        }
151  
-
152  
-        public Group getgrent() {
153  
-            return delegate.getgrent();
154  
-        }
155  
-
156  
-        public int endgrent() {
157  
-            return delegate.endgrent();
158  
-        }
159  
-
160  
-        public int setgrent() {
161  
-            return delegate.setgrent();
162  
-        }
163  
-
164  
-        public int endpwent() {
165  
-            return delegate.endpwent();
166  
-        }
167  
-
168  
-        public int setpwent() {
169  
-            return delegate.setpwent();
170  
-        }
171  
-
172  
-        public int getuid() {
173  
-            return delegate.getuid();
174  
-        }
175  
-
176  
-        public boolean isatty(FileDescriptor descriptor) {
177  
-            return delegate.isatty(descriptor);
178  
-        }
179  
-
180  
-        public int kill(int pid, int signal) {
181  
-            return delegate.kill(pid, signal);
182  
-        }
183  
-
184  
-        public int lchmod(String filename, int mode) {
185  
-            return delegate.lchmod(filename, mode);
186  
-        }
187  
-
188  
-        public int lchown(String filename, int user, int group) {
189  
-            return delegate.lchown(filename, user, group);
190  
-        }
191  
-
192  
-        public int link(String oldpath, String newpath) {
193  
-            return delegate.link(oldpath, newpath);
194  
-        }
195  
-
196  
-        public FileStat lstat(String path) {
197  
-            return delegate.lstat(path);
198  
-        }
199  
-
200  
-        public int mkdir(String path, int mode) {
201  
-            return delegate.mkdir(path, mode);
202  
-        }
203  
-
204  
-        public String readlink(String path) throws IOException {
205  
-            return delegate.readlink(path);
206  
-        }
207  
-
208  
-        public int setsid() {
209  
-            return delegate.setsid();
210  
-        }
211  
-
212  
-        public int setgid(int gid) {
213  
-            return delegate.setgid(gid);
214  
-        }
215  
-
216  
-        public int setegid(int egid) {
217  
-            return delegate.setegid(egid);
218  
-        }
219  
-
220  
-        public int setpgid(int pid, int pgid) {
221  
-            return delegate.setpgid(pid, pgid);
222  
-        }
223  
-
224  
-        public int setpgrp(int pid, int pgrp) {
225  
-            return delegate.setpgrp(pid, pgrp);
226  
-        }
227  
-
228  
-        public int setpriority(int which, int who, int prio) {
229  
-            return delegate.setpriority(which, who, prio);
230  
-        }
231  
-
232  
-        public int setuid(int uid) {
233  
-            return delegate.setuid(uid);
234  
-        }
235  
-
236  
-        public FileStat stat(String path) {
237  
-            return new FallbackFileStat(delegate.stat(path));
238  
-        }
239  
-
240  
-        public int symlink(String oldpath, String newpath) {
241  
-            return delegate.symlink(oldpath, newpath);
242  
-        }
243  
-
244  
-        public int umask(int mask) {
245  
-            return delegate.umask(mask);
246  
-        }
247  
-
248  
-        public int utimes(String path, long[] atimeval, long[] mtimeval) {
249  
-            return delegate.utimes(path, atimeval, mtimeval);
250  
-        }
251  
-
252  
-        public int waitpid(int pid, int[] status, int flags) {
253  
-            return delegate.waitpid(pid, status, flags);
254  
-        }
255  
-
256  
-        public int wait(int[] status) {
257  
-            return delegate.wait(status);
258  
-        }
259  
-
260  
-        public int errno() {
261  
-            return delegate.errno();
262  
-        }
263  
-
264  
-        public void errno(int value) {
265  
-            delegate.errno(value);
266  
-        }
267  
-    }
268  
-
269  
-    /**
270  
-     * Calls to {@link #mode()} return 664 for files and 755 for directories.
271  
-     * Other method calls are delegated to delegate FileStat.
272  
-     * */
273  
-    private static class FallbackFileStat implements FileStat {
274  
-
275  
-        private FileStat delegate;
276  
-
277  
-        public FallbackFileStat(FileStat stat) {
278  
-            this.delegate = stat;
279  
-        }
280  
-
281  
-        public long atime() {
282  
-            return delegate.atime();
283  
-        }
284  
-
285  
-        public long blocks() {
286  
-            return delegate.blocks();
287  
-        }
288  
-
289  
-        public long blockSize() {
290  
-            return delegate.blockSize();
291  
-        }
292  
-
293  
-        public long ctime() {
294  
-            return delegate.ctime();
295  
-        }
296  
-
297  
-        public long dev() {
298  
-            return delegate.dev();
299  
-        }
300  
-
301  
-        public String ftype() {
302  
-            return delegate.ftype();
303  
-        }
304  
-
305  
-        public int gid() {
306  
-            return delegate.gid();
307  
-        }
308  
-
309  
-        public boolean groupMember(int gid) {
310  
-            return delegate.groupMember(gid);
311  
-        }
312  
-
313  
-        public long ino() {
314  
-            return delegate.ino();
315  
-        }
316  
-
317  
-        public boolean isBlockDev() {
318  
-            return delegate.isBlockDev();
319  
-        }
320  
-
321  
-        public boolean isCharDev() {
322  
-            return delegate.isCharDev();
323  
-        }
324  
-
325  
-        public boolean isDirectory() {
326  
-            return delegate.isDirectory();
327  
-        }
328  
-
329  
-        public boolean isEmpty() {
330  
-            return delegate.isEmpty();
331  
-        }
332  
-
333  
-        public boolean isExecutable() {
334  
-            return delegate.isExecutable();
335  
-        }
336  
-
337  
-        public boolean isExecutableReal() {
338  
-            return delegate.isExecutableReal();
339  
-        }
340  
-
341  
-        public boolean isFifo() {
342  
-            return delegate.isFifo();
343  
-        }
344  
-
345  
-        public boolean isFile() {
346  
-            return delegate.isFile();
347  
-        }
348  
-
349  
-        public boolean isGroupOwned() {
350  
-            return delegate.isGroupOwned();
351  
-        }
352  
-
353  
-        public boolean isIdentical(FileStat other) {
354  
-            return delegate.isIdentical(other);
355  
-        }
356  
-
357  
-        public boolean isNamedPipe() {
358  
-            return delegate.isNamedPipe();
359  
-        }
360  
-
361  
-        public boolean isOwned() {
362  
-            return delegate.isOwned();
363  
-        }
364  
-
365  
-        public boolean isROwned() {
366  
-            return delegate.isROwned();
367  
-        }
368  
-
369  
-        public boolean isReadable() {
370  
-            return delegate.isReadable();
371  
-        }
372  
-
373  
-        public boolean isReadableReal() {
374  
-            return delegate.isReadableReal();
375  
-        }
376  
-
377  
-        public boolean isWritable() {
378  
-            return delegate.isWritable();
379  
-        }
380  
-
381  
-        public boolean isWritableReal() {
382  
-            return delegate.isWritableReal();
383  
-        }
384  
-
385  
-        public boolean isSetgid() {
386  
-            return delegate.isSetgid();
387  
-        }
388  
-
389  
-        public boolean isSetuid() {
390  
-            return delegate.isSetuid();
391  
-        }
392  
-
393  
-        public boolean isSocket() {
394  
-            return delegate.isSocket();
395  
-        }
396  
-
397  
-        public boolean isSticky() {
398  
-            return delegate.isSticky();
399  
-        }
400  
-
401  
-        public boolean isSymlink() {
402  
-            return delegate.isSymlink();
403  
-        }
404  
-
405  
-        public int major(long dev) {
406  
-            return delegate.major(dev);
407  
-        }
408  
-
409  
-        public int minor(long dev) {
410  
-            return delegate.minor(dev);
411  
-        }
412  
-
413  
-        public int mode() {
414  
-            if(isDirectory()){
415  
-                return FileSystem.DEFAULT_DIR_MODE;
416  
-            }else{
417  
-                return FileSystem.DEFAULT_FILE_MODE;
418  
-            }
419  
-        }
420  
-
421  
-        public long mtime() {
422  
-            return delegate.mtime();
423  
-        }
424  
-
425  
-        public int nlink() {
426  
-            return delegate.nlink();
427  
-        }
428  
-
429  
-        public long rdev() {
430  
-            return delegate.rdev();
431  
-        }
432  
-
433  
-        public long st_size() {
434  
-            return delegate.st_size();
435  
-        }
436  
-
437  
-        public int uid() {
438  
-            return delegate.uid();
439  
-        }
440  
-    }
441  
-}
190  subprojects/native/src/main/java/org/gradle/internal/nativeplatform/filesystem/FallbackFileStat.java
... ...
@@ -0,0 +1,190 @@
  1
+/*
  2
+ * Copyright 2012 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.gradle.internal.nativeplatform.filesystem;
  18
+
  19
+import org.jruby.ext.posix.FileStat;
  20
+
  21
+import java.io.File;
  22
+
  23
+public class FallbackFileStat implements FileStat {
  24
+
  25
+    private final File file;
  26
+
  27
+    public FallbackFileStat(String path) {
  28
+        this.file = new File(path);
  29
+    }
  30
+
  31
+    public long atime() {
  32
+        throw new UnsupportedOperationException("Operation atime() is not supported.");
  33
+    }
  34
+
  35
+    public long blocks() {
  36
+        throw new UnsupportedOperationException("Operation blocks is not supported.");
  37
+    }
  38
+
  39
+    public long blockSize() {
  40
+        throw new UnsupportedOperationException("Operation blockSize() is not supported.");
  41
+    }
  42
+
  43
+    public long ctime() {
  44
+        throw new UnsupportedOperationException("Operation ctime() is not supported.");
  45
+    }
  46
+
  47
+    public long dev() {
  48
+        throw new UnsupportedOperationException("Operation dev() is not supported.");
  49
+    }
  50
+
  51
+    public String ftype() {
  52
+        throw new UnsupportedOperationException("Operation ftype() is not supported.");
  53
+    }
  54
+
  55
+    public int gid() {
  56
+        throw new UnsupportedOperationException("Operation gid() is not supported.");
  57
+    }
  58
+
  59
+    public boolean groupMember(int gid) {
  60
+        throw new UnsupportedOperationException("Operation groupMember() is not supported.");
  61
+    }
  62
+
  63
+    public long ino() {
  64
+        throw new UnsupportedOperationException("Operation ino() is not supported.");
  65
+    }
  66
+
  67
+    public boolean isBlockDev() {
  68
+        throw new UnsupportedOperationException("Operation isBlockDev() is not supported.");
  69
+    }
  70
+
  71
+    public boolean isCharDev() {
  72
+        throw new UnsupportedOperationException("Operation isCharDev() is not supported.");
  73
+    }
  74
+
  75
+    public boolean isDirectory() {
  76
+        return file.isDirectory();
  77
+    }
  78
+
  79
+    public boolean isEmpty() {
  80
+        throw new UnsupportedOperationException("Operation isEmpty() is not supported.");
  81
+    }
  82
+
  83
+    public boolean isExecutable() {
  84
+        throw new UnsupportedOperationException("Operation isExecutable() is not supported.");
  85
+    }
  86
+
  87
+    public boolean isExecutableReal() {
  88
+        throw new UnsupportedOperationException("Operation isExecutableReal() is not supported.");
  89
+    }
  90
+
  91
+    public boolean isFifo() {
  92
+        throw new UnsupportedOperationException("Operation isFifo() is not supported.");
  93
+    }
  94
+
  95
+    public boolean isFile() {
  96
+        return file.isFile();
  97
+    }
  98
+
  99
+    public boolean isGroupOwned() {
  100
+        throw new UnsupportedOperationException("Operation isGroupOwned() is not supported.");
  101
+    }
  102
+
  103
+    public boolean isIdentical(FileStat other) {
  104
+        throw new UnsupportedOperationException("Operation isIdentical() is not supported.");
  105
+    }
  106
+
  107
+    public boolean isNamedPipe() {
  108
+        throw new UnsupportedOperationException("Operation isNamedPipe() is not supported.");
  109
+    }
  110
+
  111
+    public boolean isOwned() {
  112
+        throw new UnsupportedOperationException("Operation isOwned() is not supported.");
  113
+    }
  114
+
  115
+    public boolean isROwned() {
  116
+        throw new UnsupportedOperationException("Operation isROwned() is not supported.");
  117
+    }
  118
+
  119
+    public boolean isReadable() {
  120
+        throw new UnsupportedOperationException("Operation isReadable() is not supported.");
  121
+    }
  122
+
  123
+    public boolean isReadableReal() {
  124
+        throw new UnsupportedOperationException("Operation isReadableReal() is not supported.");
  125
+    }
  126
+
  127
+    public boolean isWritable() {
  128
+        throw new UnsupportedOperationException("Operation isWritable() is not supported.");
  129
+    }
  130
+
  131
+    public boolean isWritableReal() {
  132
+        throw new UnsupportedOperationException("Operation isWritableReal() is not supported.");
  133
+    }
  134
+
  135
+    public boolean isSetgid() {
  136
+        throw new UnsupportedOperationException("Operation isSetgid() is not supported.");
  137
+    }
  138
+
  139
+    public boolean isSetuid() {
  140
+        throw new UnsupportedOperationException("Operation isSetuid() is not supported.");
  141
+    }
  142
+
  143
+    public boolean isSocket() {
  144
+        throw new UnsupportedOperationException("Operation isSocket() is not supported.");
  145
+    }
  146
+
  147
+    public boolean isSticky() {
  148
+        throw new UnsupportedOperationException("Operation isSticky() is not supported.");
  149
+    }
  150
+
  151
+    public boolean isSymlink() {
  152
+        throw new UnsupportedOperationException("Operation isSymlink() is not supported.");
  153
+    }
  154
+
  155
+    public int major(long dev) {
  156
+        throw new UnsupportedOperationException("Operation major() is not supported.");
  157
+    }
  158
+
  159
+    public int minor(long dev) {
  160
+        throw new UnsupportedOperationException("Operation minor() is not supported.");
  161
+    }
  162
+
  163
+    public int mode() {
  164
+        if (isDirectory()) {
  165
+            return FileSystem.DEFAULT_DIR_MODE;
  166
+        } else {
  167
+            return FileSystem.DEFAULT_FILE_MODE;
  168
+        }
  169
+    }
  170
+
  171
+    public long mtime() {
  172
+        throw new UnsupportedOperationException("Operation mtime() is not supported.");
  173
+    }
  174
+
  175
+    public int nlink() {
  176
+        throw new UnsupportedOperationException("Operation nlink() is not supported.");
  177
+    }
  178
+
  179
+    public long rdev() {
  180
+        throw new UnsupportedOperationException("Operation rdev() is not supported.");
  181
+    }
  182
+
  183
+    public long st_size() {
  184
+        throw new UnsupportedOperationException("Operation st_size() is not supported.");
  185
+    }
  186
+
  187
+    public int uid() {
  188
+        throw new UnsupportedOperationException("Operation uid() is not supported.");
  189
+    }
  190
+}
224  subprojects/native/src/main/java/org/gradle/internal/nativeplatform/filesystem/FallbackPOSIX.java
... ...
@@ -0,0 +1,224 @@
  1
+/*
  2
+ * Copyright 2012 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.gradle.internal.nativeplatform.filesystem;
  18
+
  19
+import org.jruby.ext.posix.FileStat;
  20
+import org.jruby.ext.posix.Group;
  21
+import org.jruby.ext.posix.POSIX;
  22
+import org.jruby.ext.posix.Passwd;
  23
+
  24
+import java.io.FileDescriptor;
  25
+import java.io.IOException;
  26
+
  27
+public class FallbackPOSIX implements POSIX {
  28
+
  29
+    public int chmod(String filename, int mode) {
  30
+        return 0;
  31
+    }
  32
+
  33
+    public int chown(String filename, int user, int group) {
  34
+        throw new UnsupportedOperationException("This operation is not supported.");
  35
+    }
  36
+
  37
+    public int fork() {
  38
+        throw new UnsupportedOperationException("This operation is not supported.");
  39
+    }
  40
+
  41
+    public FileStat fstat(FileDescriptor descriptor) {
  42
+        throw new UnsupportedOperationException("This operation is not supported.");
  43
+    }
  44
+
  45
+    public int getegid() {
  46
+        throw new UnsupportedOperationException("This operation is not supported.");
  47
+    }
  48
+
  49
+    public int geteuid() {
  50
+        throw new UnsupportedOperationException("This operation is not supported.");
  51
+    }
  52
+
  53
+    public int seteuid(int euid) {
  54
+        throw new UnsupportedOperationException("This operation is not supported.");
  55
+    }
  56
+
  57
+    public int getgid() {
  58
+        throw new UnsupportedOperationException("This operation is not supported.");
  59
+    }
  60
+
  61
+    public String getlogin() {
  62
+        throw new UnsupportedOperationException("This operation is not supported.");
  63
+    }
  64
+
  65
+    public int getpgid() {
  66
+        throw new UnsupportedOperationException("This operation is not supported.");
  67
+    }
  68
+
  69
+    public int getpgid(int pid) {
  70
+        throw new UnsupportedOperationException("This operation is not supported.");
  71
+    }
  72
+
  73
+    public int getpgrp() {
  74
+        throw new UnsupportedOperationException("This operation is not supported.");
  75
+    }
  76
+
  77
+    public int getpid() {
  78
+        throw new UnsupportedOperationException("This operation is not supported.");
  79
+    }
  80
+
  81
+    public int getppid() {
  82
+        throw new UnsupportedOperationException("This operation is not supported.");
  83
+    }
  84
+
  85
+    public int getpriority(int which, int who) {
  86
+        throw new UnsupportedOperationException("This operation is not supported.");
  87
+    }
  88
+
  89
+    public Passwd getpwent() {
  90
+        throw new UnsupportedOperationException("This operation is not supported.");
  91
+    }
  92
+
  93
+    public Passwd getpwuid(int which) {
  94
+        throw new UnsupportedOperationException("This operation is not supported.");
  95
+    }
  96
+
  97
+    public Passwd getpwnam(String which) {
  98
+        throw new UnsupportedOperationException("This operation is not supported.");
  99
+    }
  100
+
  101
+    public Group getgrgid(int which) {
  102
+        throw new UnsupportedOperationException("This operation is not supported.");
  103
+    }
  104
+
  105
+    public Group getgrnam(String which) {
  106
+        throw new UnsupportedOperationException("This operation is not supported.");
  107
+    }
  108
+
  109
+    public Group getgrent() {
  110
+        throw new UnsupportedOperationException("This operation is not supported.");
  111
+    }
  112
+
  113
+    public int endgrent() {
  114
+        throw new UnsupportedOperationException("This operation is not supported.");
  115
+    }
  116
+
  117
+    public int setgrent() {
  118
+        throw new UnsupportedOperationException("This operation is not supported.");
  119
+    }
  120
+
  121
+    public int endpwent() {
  122
+        throw new UnsupportedOperationException("This operation is not supported.");
  123
+    }
  124
+
  125
+    public int setpwent() {
  126
+        throw new UnsupportedOperationException("This operation is not supported.");
  127
+    }
  128
+
  129
+    public int getuid() {
  130
+        throw new UnsupportedOperationException("This operation is not supported.");
  131
+    }
  132
+
  133
+    public boolean isatty(FileDescriptor descriptor) {
  134
+        throw new UnsupportedOperationException("This operation is not supported.");
  135
+    }
  136
+
  137
+    public int kill(int pid, int signal) {
  138
+        throw new UnsupportedOperationException("This operation is not supported.");
  139
+    }
  140
+
  141
+    public int lchmod(String filename, int mode) {
  142
+        throw new UnsupportedOperationException("This operation is not supported.");
  143
+    }
  144
+
  145
+    public int lchown(String filename, int user, int group) {
  146
+        throw new UnsupportedOperationException("This operation is not supported.");
  147
+    }
  148
+
  149
+    public int link(String oldpath, String newpath) {
  150
+        throw new UnsupportedOperationException("This operation is not supported.");
  151
+    }
  152
+
  153
+    public FileStat lstat(String path) {
  154
+        throw new UnsupportedOperationException("This operation is not supported.");
  155
+    }
  156
+
  157
+    public int mkdir(String path, int mode) {
  158
+        throw new UnsupportedOperationException("This operation is not supported.");
  159
+    }
  160
+
  161
+    public String readlink(String path) throws IOException {
  162
+        throw new UnsupportedOperationException("This operation is not supported.");
  163
+    }
  164
+
  165
+    public int setsid() {
  166
+        throw new UnsupportedOperationException("This operation is not supported.");
  167
+    }
  168
+
  169
+    public int setgid(int gid) {
  170
+        throw new UnsupportedOperationException("This operation is not supported.");
  171
+    }
  172
+
  173
+    public int setegid(int egid) {
  174
+        throw new UnsupportedOperationException("This operation is not supported.");
  175
+    }
  176
+
  177
+    public int setpgid(int pid, int pgid) {
  178
+        throw new UnsupportedOperationException("This operation is not supported.");
  179
+    }
  180
+
  181
+    public int setpgrp(int pid, int pgrp) {
  182
+        throw new UnsupportedOperationException("This operation is not supported.");
  183
+    }
  184
+
  185
+    public int setpriority(int which, int who, int prio) {
  186
+        throw new UnsupportedOperationException("This operation is not supported.");
  187
+    }
  188
+
  189
+    public int setuid(int uid) {
  190
+        throw new UnsupportedOperationException("This operation is not supported.");
  191
+    }
  192
+
  193
+    public FileStat stat(String path) {
  194
+        return new FallbackFileStat(path);
  195
+    }
  196
+
  197
+    public int symlink(String oldpath, String newpath) {
  198
+        return 0;
  199
+    }
  200
+
  201
+    public int umask(int mask) {
  202
+        throw new UnsupportedOperationException("This operation is not supported.");
  203
+    }
  204
+
  205
+    public int utimes(String path, long[] atimeval, long[] mtimeval) {
  206
+        throw new UnsupportedOperationException("This operation is not supported.");
  207
+    }
  208
+
  209
+    public int waitpid(int pid, int[] status, int flags) {
  210
+        throw new UnsupportedOperationException("This operation is not supported.");
  211
+    }
  212
+
  213
+    public int wait(int[] status) {
  214
+        throw new UnsupportedOperationException("This operation is not supported.");
  215
+    }
  216
+
  217
+    public int errno() {
  218
+        throw new UnsupportedOperationException("This operation is not supported.");
  219
+    }
  220
+
  221
+    public void errno(int value) {
  222
+        throw new UnsupportedOperationException("This operation is not supported.");
  223
+    }
  224
+}
16  subprojects/native/src/main/java/org/gradle/internal/nativeplatform/filesystem/PosixUtil.java
@@ -16,21 +16,29 @@
16 16
 
17 17
 package org.gradle.internal.nativeplatform.filesystem;
18 18
 
19  
-import org.jruby.ext.posix.POSIX;
20  
-import org.jruby.ext.posix.POSIXFactory;
21  
-import org.jruby.ext.posix.POSIXHandler;
  19
+import org.jruby.ext.posix.*;
22 20
 
23 21
 import java.io.File;
24 22
 import java.io.InputStream;
25 23
 import java.io.PrintStream;
26 24
 
27 25
 public class PosixUtil {
28  
-    private static final POSIX POSIX = PosixWrapper.wrap(POSIXFactory.getPOSIX(new POSIXHandlerImpl(), true));
  26
+    private static final POSIX POSIX = FallbackAwarePosixFactory.getPOSIX();
29 27
 
30 28
     public static POSIX current() {
31 29
         return POSIX;
32 30
     }
33 31
 
  32
+    private static class FallbackAwarePosixFactory{
  33
+        public static POSIX getPOSIX() {
  34
+            POSIX posix = POSIXFactory.getPOSIX(new POSIXHandlerImpl(), true);
  35
+            if(posix instanceof JavaPOSIX || posix instanceof WindowsPOSIX){
  36
+                return new FallbackPOSIX();
  37
+            }
  38
+            return posix;
  39
+        }
  40
+    }
  41
+
34 42
     private static class POSIXHandlerImpl implements POSIXHandler {
35 43
         public void error(POSIX.ERRORS error, String message) {
36 44
             throw new UnsupportedOperationException(error + " - " + message);
440  subprojects/native/src/main/java/org/gradle/internal/nativeplatform/filesystem/PosixWrapper.java
... ...
@@ -1,440 +0,0 @@
1  
-/*
2  
- * Copyright 2012 the original author or authors.
3  
- *
4  
- * Licensed under the Apache License, Version 2.0 (the "License");
5  
- * you may not use this file except in compliance with the License.
6  
- * You may obtain a copy of the License at
7  
- *
8  
- *      http://www.apache.org/licenses/LICENSE-2.0
9  
- *
10  
- * Unless required by applicable law or agreed to in writing, software
11  
- * distributed under the License is distributed on an "AS IS" BASIS,
12  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  
- * See the License for the specific language governing permissions and
14  
- * limitations under the License.
15  
- */
16  
-
17  
-package org.gradle.internal.nativeplatform.filesystem;
18  
-
19  
-import org.jruby.ext.posix.*;
20  
-
21  
-import java.io.FileDescriptor;
22  
-import java.io.IOException;
23  
-
24  
-/**
25  
- * Util class to wrap / modify results of calls to the {@link org.jruby.ext.posix.POSIXFactory#getPOSIX(org.jruby.ext.posix.POSIXHandler, boolean)}
26  
- * */
27  
-public class PosixWrapper {
28  
-
29  
-    public static POSIX wrap(POSIX posix) {
30  
-        if (posix instanceof JavaPOSIX) {
31  
-            return new ChmodDisabledFallbackPOSIX(posix);
32  
-        } else if (posix instanceof WindowsPOSIX) {
33  
-            return new FilePermissionFallbackPOSIX(posix);
34  
-        } else {
35  
-            return posix;
36  
-        }
37  
-    }
38  
-
39  
-    private static class ChmodDisabledFallbackPOSIX extends FilePermissionFallbackPOSIX {
40  
-
41  
-        public ChmodDisabledFallbackPOSIX(POSIX posix) {
42  
-            super(posix);
43  
-        }
44  
-
45  
-        public int chmod(String filename, int mode) {
46  
-            // short circuit this call to return incoming mode
47  
-            return mode;
48  
-        }
49  
-    }
50  
-
51  
-    private static class FilePermissionFallbackPOSIX extends DelegatePOSIX{
52  
-        public FilePermissionFallbackPOSIX(POSIX posix) {
53  
-            super(posix);
54  
-        }
55  
-
56  
-        public FileStat stat(String path) {
57  
-            return new FallbackFileStat(super.stat(path));
58  
-        }
59  
-    }
60  
-
61  
-    /**
62  
-     * a Plain DelegatePosix to keep own posix implementations "clean"