16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.nio.fs;
27
28 /**
29 * Unix system and library calls.
30 */
31
32 class UnixNativeDispatcher {
33 protected UnixNativeDispatcher() { }
34
35 // returns a NativeBuffer containing the given path
36 private static NativeBuffer copyToNativeBuffer(UnixPath path) {
37 byte[] cstr = path.getByteArrayForSysCalls();
38 int size = cstr.length + 1;
39 NativeBuffer buffer = NativeBuffers.getNativeBufferFromCache(size);
40 if (buffer == null) {
41 buffer = NativeBuffers.allocNativeBuffer(size);
42 } else {
43 // buffer already contains the path
44 if (buffer.owner() == path)
45 return buffer;
46 }
47 NativeBuffers.copyCStringToNativeBuffer(cstr, buffer);
48 buffer.setOwner(path);
49 return buffer;
50 }
51
52 /**
53 * char *getcwd(char *buf, size_t size);
54 */
55 static native byte[] getcwd();
56
|
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.nio.fs;
27
28 /**
29 * Unix system and library calls.
30 */
31
32 class UnixNativeDispatcher {
33 protected UnixNativeDispatcher() { }
34
35 // returns a NativeBuffer containing the given path
36 static NativeBuffer copyToNativeBuffer(UnixPath path) {
37 byte[] cstr = path.getByteArrayForSysCalls();
38 int size = cstr.length + 1;
39 NativeBuffer buffer = NativeBuffers.getNativeBufferFromCache(size);
40 if (buffer == null) {
41 buffer = NativeBuffers.allocNativeBuffer(size);
42 } else {
43 // buffer already contains the path
44 if (buffer.owner() == path)
45 return buffer;
46 }
47 NativeBuffers.copyCStringToNativeBuffer(cstr, buffer);
48 buffer.setOwner(path);
49 return buffer;
50 }
51
52 /**
53 * char *getcwd(char *buf, size_t size);
54 */
55 static native byte[] getcwd();
56
|