You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ar...@apache.org on 2006/05/02 01:11:49 UTC

svn commit: r398726 [6/6] - in /incubator/harmony/enhanced/classlibadapter: ./ trunk/ trunk/bin/ trunk/modules/ trunk/modules/kernel/ trunk/modules/kernel/src/ trunk/modules/kernel/src/main/ trunk/modules/kernel/src/main/java/ trunk/modules/kernel/src/...

Added: incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java Mon May  1 16:11:39 2006
@@ -0,0 +1,1099 @@
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.nio;
+
+
+import com.ibm.platform.Endianness;
+
+/**
+ * A buffer of <code>byte</code>s.
+ * <p>
+ * A byte buffer can be created in either of the following ways:
+ * <ul>
+ * <li>{@link #allocate(int) Allocate} a new byte array and create a buffer
+ * based on it;</li>
+ * <li>{@link #allocateDirect(int) Allocate} a memory block and create a direct
+ * buffer based on it;</li>
+ * <li>{@link #wrap(byte[]) Wrap} an existing byte array to create a new
+ * buffer.</li>
+ * </ul>
+ * </p>
+ * 
+ */
+public abstract class ByteBuffer extends Buffer implements Comparable {
+
+	/**
+	 * Creates a byte buffer based on a new allocated byte array.
+	 * 
+	 * @param capacity
+	 *            The capacity of the new buffer
+	 * @return The created byte buffer
+	 * @throws IllegalArgumentException
+	 *             If <code>capacity</code> is less than zero
+	 */
+	public static ByteBuffer allocate(int capacity) {
+		if (capacity < 0) {
+			throw new IllegalArgumentException();
+		}
+		return BufferFactory.newByteBuffer(capacity);
+	}
+
+	/**
+	 * Creates a direct byte buffer based on a new allocated memory block.
+	 * 
+	 * @param capacity
+	 *            The capacity of the new buffer
+	 * @return The created byte buffer
+	 * @throws IllegalArgumentException
+	 *             If <code>capacity</code> is less than zero
+	 */
+	public static ByteBuffer allocateDirect(int capacity) {
+		if (capacity < 0) {
+			throw new IllegalArgumentException();
+		}
+		return BufferFactory.newDirectByteBuffer(capacity);
+	}
+
+	/**
+	 * Creates a new byte buffer by wrapping the given byte array.
+	 * <p>
+	 * Calling this method has the same effect as 
+	 * <code>wrap(array, 0, array.length)</code>.</p>
+	 * 
+	 * @param array     The byte array which the new buffer will be based on
+	 * @return The created byte buffer
+	 */
+	public static ByteBuffer wrap(byte[] array) {
+		return BufferFactory.newByteBuffer(array);
+	}
+
+	/**
+	 * Creates new a byte buffer by wrapping the given byte array.
+	 * <p>
+	 * The new buffer's position will be <code>start</code>, limit will be
+	 * <code>start + len</code>, capacity will be the length of the array.
+	 * </p>
+	 * 
+	 * @param array
+	 *            The byte array which the new buffer will be based on
+	 * @param start
+	 *            The start index, must be no less than zero and no greater than
+	 *            <code>array.length</code>
+	 * @param len
+	 *            The length, must be no less than zero and no greater than
+	 *            <code>array.length - start</code>
+	 * @return The created byte buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If either <code>start</code> or <code>len</code> is
+	 *                invalid
+	 */
+	public static ByteBuffer wrap(byte[] array, int start, int len) {
+        if ((start< 0 ) || (len < 0) || start+ len > array.length) {
+            throw new IndexOutOfBoundsException();
+        }
+
+		ByteBuffer buf = BufferFactory.newByteBuffer(array);
+		buf.position = start;
+		buf.limit = start + len;
+
+		return buf;
+	}
+
+	/**
+	 * The byte order of this buffer, default is <code>BIG_ENDIAN</code>.
+	 */
+	Endianness order = Endianness.BIG_ENDIAN;
+
+	/**
+	 * Constructs a <code>ByteBuffer</code> with given capacity.
+	 * 
+	 * @param capacity  The capacity of the buffer
+	 */
+	ByteBuffer(int capacity) {
+		super(capacity);
+	}
+
+	/**
+	 * Returns the byte array which this buffer is based on, if there's one.
+	 * 
+	 * @return The byte array which this buffer is based on
+	 * @exception ReadOnlyBufferException
+	 *                If this buffer is based on a readonly array
+	 * @exception UnsupportedOperationException
+	 *                If this buffer is not based on an array
+	 */
+	public final byte[] array() {
+		return protectedArray();
+	}
+
+	/**
+	 * Returns the offset of the byte array which this buffer is based on, if
+	 * there's one.
+	 * <p>
+	 * The offset is the index of the array corresponds to the zero position of
+	 * the buffer.
+	 * </p>
+	 * 
+	 * @return The offset of the byte array which this buffer is based on
+	 * @exception ReadOnlyBufferException
+	 *                If this buffer is based on a readonly array
+	 * @exception UnsupportedOperationException
+	 *                If this buffer is not based on an array
+	 */
+	public final int arrayOffset() {
+		return protectedArrayOffset();
+	}
+
+	/**
+	 * Returns a char buffer which is based on the remaining content of
+	 * this byte buffer.
+	 * <p>
+	 * The new buffer's position is zero, its limit and capacity is
+	 * the number of remaining bytes divided by two, and its mark is not set.
+	 * The new buffer's readonly property and byte order are same as this 
+	 * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A char buffer which is based on the content of
+	 * this byte buffer.
+	 */
+	public abstract CharBuffer asCharBuffer();
+
+	/**
+	 * Returns a double buffer which is based on the remaining content of
+	 * this byte buffer.
+	 * <p>
+	 * The new buffer's position is zero, its limit and capacity is
+	 * the number of remaining bytes divided by two, and its mark is not set.
+	 * The new buffer's readonly property and byte order are same as this 
+	 * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A double buffer which is based on the content of
+	 * this byte buffer.
+	 */
+	public abstract DoubleBuffer asDoubleBuffer();
+
+	/**
+	 * Returns a float buffer which is based on the remaining content of
+	 * this byte buffer.
+	 * <p>
+	 * The new buffer's position is zero, its limit and capacity is
+	 * the number of remaining bytes divided by two, and its mark is not set.
+	 * The new buffer's readonly property and byte order are same as this 
+	 * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A float buffer which is based on the content of
+	 * this byte buffer.
+	 */
+	public abstract FloatBuffer asFloatBuffer();
+
+	/**
+	 * Returns a int buffer which is based on the remaining content of
+	 * this byte buffer.
+	 * <p>
+	 * The new buffer's position is zero, its limit and capacity is
+	 * the number of remaining bytes divided by two, and its mark is not set.
+	 * The new buffer's readonly property and byte order are same as this 
+	 * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A int buffer which is based on the content of
+	 * this byte buffer.
+	 */
+	public abstract IntBuffer asIntBuffer();
+
+	/**
+	 * Returns a long buffer which is based on the remaining content of
+	 * this byte buffer.
+	 * <p>
+	 * The new buffer's position is zero, its limit and capacity is
+	 * the number of remaining bytes divided by two, and its mark is not set.
+	 * The new buffer's readonly property and byte order are same as this 
+	 * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A long buffer which is based on the content of
+	 * this byte buffer.
+	 */
+	public abstract LongBuffer asLongBuffer();
+
+	/**
+	 * Returns a readonly buffer that shares content with this buffer.
+	 * <p>
+	 * The returned buffer is guaranteed to be a new instance, even this 
+	 * buffer is readonly itself. The new buffer's position, limit, capacity
+	 * and mark are the same as this buffer.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * this buffer's change of content will be visible to the new buffer.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A readonly version of this buffer.
+	 */
+	public abstract ByteBuffer asReadOnlyBuffer();
+
+	/**
+	 * Returns a short buffer which is based on the remaining content of
+	 * this byte buffer.
+	 * <p>
+	 * The new buffer's position is zero, its limit and capacity is
+	 * the number of remaining bytes divided by two, and its mark is not set.
+	 * The new buffer's readonly property and byte order are same as this 
+	 * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A short buffer which is based on the content of
+	 * this byte buffer.
+	 */
+	public abstract ShortBuffer asShortBuffer();
+
+	/**
+	 * Compacts this byte buffer.
+	 * <p>
+	 * The remaining <code>byte</code>s will be moved to the head of the
+	 * buffer, staring from position zero. Then the position is set to
+	 * <code>remaining()</code>; the limit is set to capacity; the mark is
+	 * cleared.
+	 * </p>
+	 * 
+	 * @return This buffer
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer compact();
+
+	/**
+	 * Compare the remaining <code>byte</code>s of this buffer to another
+	 * byte buffer's remaining <code>byte</code>s.
+	 * 
+	 * @param other
+	 *            Another byte buffer
+	 * @return a negative value if this is less than <code>other</code>; 0 if
+	 *         this equals to <code>other</code>; a positive value if this is
+	 *         greater than <code>other</code>
+	 * @exception ClassCastException
+	 *                If <code>other</code> is not a byte buffer
+	 */
+	public int compareTo(Object other) {
+		ByteBuffer otherBuffer = (ByteBuffer) other;
+		int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
+				: otherBuffer.remaining();
+		int thisPos = position;
+		int otherPos = otherBuffer.position;
+		byte thisByte, otherByte;
+		while (compareRemaining > 0) {
+			thisByte = get(thisPos);
+			otherByte = otherBuffer.get(otherPos);
+			if (thisByte != otherByte) {
+				return thisByte < otherByte ? -1 : 1;
+			}
+			thisPos++;
+			otherPos++;
+			compareRemaining--;
+		}
+		return remaining() - otherBuffer.remaining();
+	}
+
+	/**
+	 * Returns a duplicated buffer that shares content with this buffer.
+	 * <p>
+	 * The duplicated buffer's position, limit, capacity and mark are the
+	 * same as this buffer. The duplicated buffer's readonly property and 
+	 * byte order are same as this buffer too.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A duplicated buffer that shares content with this buffer.
+	 */
+	public abstract ByteBuffer duplicate();
+
+	/**
+	 * Tests whether this byte buffer equals to another object.
+	 * <p>
+	 * If <code>other</code> is not a byte buffer, then false is returned.</p>
+	 * <p>
+	 * Two byte buffers are equals if, and only if, their remaining 
+	 * <code>byte</code>s are exactly the same. Position, limit, capacity and
+	 * mark are not considered.</p>
+	 * 
+	 * @param other the object to comapre against
+	 * @return Whether this byte buffer equals to another object.
+	 */
+	public boolean equals(Object other) {
+		if (!(other instanceof ByteBuffer)) {
+			return false;
+		}
+		ByteBuffer otherBuffer = (ByteBuffer) other;
+
+		if (remaining() != otherBuffer.remaining()) {
+			return false;
+		}
+
+		int myPosition = position;
+		int otherPosition = otherBuffer.position;
+		boolean equalSoFar = true;
+		while (equalSoFar && (myPosition < limit)) {
+			equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
+		}
+
+		return equalSoFar;
+	}
+
+	/**
+	 * Returns the byte at the current position and increase the position by 1.
+	 * 
+	 * @return The byte at the current position.
+	 * @exception BufferUnderflowException
+	 *                If the position is equal or greater than limit
+	 */
+	public abstract byte get();
+
+	/**
+	 * Reads <code>byte</code>s from the current position into the specified
+	 * byte array and increase the position by the number of <code>byte</code>s
+	 * read.
+	 * <p>
+	 * Calling this method has the same effect as
+	 * <code>get(dest, 0, dest.length)</code>.
+	 * </p>
+	 * 
+	 * @param dest
+	 *            The destination byte array
+	 * @return This buffer
+	 * @exception BufferUnderflowException
+	 *                if <code>dest.length</code> is greater than
+	 *                <code>remaining()</code>
+	 */
+	public ByteBuffer get(byte[] dest) {
+		return get(dest, 0, dest.length);
+	}
+
+	/**
+	 * Reads <code>byte</code>s from the current position into the specified
+	 * byte array, starting from the specified offset, and increase the position
+	 * by the number of <code>byte</code>s read.
+	 * 
+	 * @param dest
+	 *            The target byte array
+	 * @param off
+	 *            The offset of the byte array, must be no less than zero and no
+	 *            greater than <code>dest.length</code>
+	 * @param len
+	 *            The number of <code>byte</code>s to read, must be no less
+	 *            than zero and no greater than <code>dest.length - off</code>
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If either <code>off</code> or <code>len</code> is
+	 *                invalid
+	 * @exception BufferUnderflowException
+	 *                If <code>len</code> is greater than
+	 *                <code>remaining()</code>
+	 */
+	public ByteBuffer get(byte[] dest, int off, int len) {
+        if ((off < 0 ) || (len < 0) || off + len > dest.length) {
+            throw new IndexOutOfBoundsException();
+        }
+        
+		if (len > remaining()) {
+			throw new BufferUnderflowException();
+		}
+		for (int i = off; i < off + len; i++) {
+			dest[i] = get();
+		}
+		return this;
+	}
+
+	/**
+	 * Returns a byte at the specifed index, and the position is not changed.
+	 * 
+	 * @param index     The index, must be no less than zero and less than limit
+	 * @return A byte at the specifed index.
+	 * @exception IndexOutOfBoundsException If index is invalid
+	 */
+	public abstract byte get(int index);
+
+	/**
+	 * Returns the char at the current position and increase the position by 2.
+	 * <p>
+	 * The 2 bytes start from the current position are composed into a char
+	 * according to current byte order and returned. The position increases by
+	 * 2.
+	 * </p>
+	 * 
+	 * @return The char at the current position.
+	 * @exception BufferUnderflowException
+	 *                If the position is greater than <code>limit - 2</code>
+	 */
+	public abstract char getChar();
+
+	/**
+	 * Returns the char at the specified index.
+	 * <p>
+	 * The 2 bytes start from the specified index are composed into a char
+	 * according to current byte order and returned. The position is not
+	 * changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 2</code>
+	 * @return The char at the specified index.
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 */
+	public abstract char getChar(int index);
+
+	/**
+	 * Returns the double at the current position and increase the position by
+	 * 8.
+	 * <p>
+	 * The 8 bytes start from the current position are composed into a double
+	 * according to current byte order and returned. The position increases by
+	 * 8.
+	 * </p>
+	 * 
+	 * @return The double at the current position.
+	 * @exception BufferUnderflowException
+	 *                If the position is greater than <code>limit - 8</code>
+	 */
+	public abstract double getDouble();
+
+	/**
+	 * Returns the double at the specified index.
+	 * <p>
+	 * The 8 bytes start from the specified index are composed into a double
+	 * according to current byte order and returned. The position is not
+	 * changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 8</code>
+	 * @return The double at the specified index.
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 */
+	public abstract double getDouble(int index);
+
+	/**
+	 * Returns the float at the current position and increase the position by 4.
+	 * <p>
+	 * The 4 bytes start from the current position are composed into a float
+	 * according to current byte order and returned. The position increases by
+	 * 4.
+	 * </p>
+	 * 
+	 * @return The float at the current position.
+	 * @exception BufferUnderflowException
+	 *                If the position is greater than <code>limit - 4</code>
+	 */
+	public abstract float getFloat();
+
+	/**
+	 * Returns the float at the specified index.
+	 * <p>
+	 * The 4 bytes start from the specified index are composed into a float
+	 * according to current byte order and returned. The position is not
+	 * changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 4</code>
+	 * @return The float at the specified index.
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 */
+	public abstract float getFloat(int index);
+
+	/**
+	 * Returns the int at the current position and increase the position by 4. 
+	 * <p>
+	 * The 4 bytes start from the current position are composed into a int
+	 * according to current byte order and returned. 
+	 * The position increases by 4.</p>
+	 * 
+	 * @return The int at the current position.
+	 * @exception BufferUnderflowException If the position is greater than <code>limit - 4</code>
+	 */
+	public abstract int getInt();
+
+	/**
+	 * Returns the int at the specified index.
+	 * <p>
+	 * The 4 bytes start from the specified index are composed into a int
+	 * according to current byte order and returned. The position is not
+	 * changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 4</code>
+	 * @return The int at the specified index.
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 */
+	public abstract int getInt(int index);
+
+	/**
+	 * Returns the long at the current position and increase the position by 8.
+	 * <p>
+	 * The 8 bytes start from the current position are composed into a long
+	 * according to current byte order and returned. The position increases by
+	 * 8.
+	 * </p>
+	 * 
+	 * @return The long at the current position.
+	 * @exception BufferUnderflowException
+	 *                If the position is greater than <code>limit - 8</code>
+	 */
+	public abstract long getLong();
+
+	/**
+	 * Returns the long at the specified index.
+	 * <p>
+	 * The 8 bytes start from the specified index are composed into a long
+	 * according to current byte order and returned. The position is not
+	 * changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 8</code>
+	 * @return The long at the specified index.
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 */
+	public abstract long getLong(int index);
+
+	/**
+	 * Returns the short at the current position and increase the position by 2. 
+	 * <p>
+	 * The 2 bytes start from the current position are composed into a short
+	 * according to current byte order and returned. 
+	 * The position increases by 2.</p>
+	 * 
+	 * @return The short at the current position.
+	 * @exception BufferUnderflowException If the position is greater than <code>limit - 2</code>
+	 */
+	public abstract short getShort();
+
+	/**
+	 * Returns the short at the specified index.
+	 * <p>
+	 * The 2 bytes start from the specified index are composed into a short
+	 * according to current byte order and returned. The position is not
+	 * changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 2</code>
+	 * @return The short at the specified index.
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 */
+	public abstract short getShort(int index);
+
+	/**
+	 * Returns whether this buffer is based on a byte array and is read/write.
+	 * <p>
+	 * If this buffer is readonly, then false is returned.</p>
+	 * 
+	 * @return Whether this buffer is based on a byte array and is read/write.
+	 */
+	public final boolean hasArray() {
+		return protectedHasArray();
+	}
+
+	/**
+	 * Hash code is calculated from the remaining <code>byte</code>s.
+	 * <p>
+	 * Position, limit, capacity and mark don't affect the hash code.</p>
+	 * 
+	 * @return The hash code calculated from the remaining <code>byte</code>s.
+	 */
+	public int hashCode() {
+		int myPosition = position;
+		int hash = 0;
+		while (myPosition < limit) {
+			hash = hash + get(myPosition++);
+		}
+		return hash;
+	}
+
+	/**
+	 * Returns true if this buffer is direct.
+	 * <p>
+	 * A byte buffer is direct, if it is based on a byte buffer and the byte
+	 * buffer is direct.
+	 * </p>
+	 * 
+	 * @return True if this buffer is direct.
+	 */
+	public abstract boolean isDirect();
+
+	/**
+	 * Returns the byte order used by this buffer when converting 
+	 * <code>byte</code>s from/to other primitive types.
+	 * <p>
+	 * The default byte order of byte buffer is always BIG_ENDIAN.</p>
+	 * 
+	 * @return The byte order used by this buffer when converting 
+	 * <code>byte</code>s from/to other primitive types.
+	 */
+	public final ByteOrder order() {
+		return order == Endianness.BIG_ENDIAN ? ByteOrder.BIG_ENDIAN
+				: ByteOrder.LITTLE_ENDIAN;
+	}
+
+	/**
+	 * Sets the byte order of this buffer.
+	 * 
+	 * @param byteOrder     The byte order to set
+	 * @return This buffer
+	 */
+	public final ByteBuffer order(ByteOrder byteOrder) {
+		return orderImpl(byteOrder);
+	}
+
+	ByteBuffer orderImpl(ByteOrder byteOrder) {
+		if (byteOrder == null) {
+			throw new NullPointerException();
+		}
+		order = byteOrder == ByteOrder.BIG_ENDIAN ? Endianness.BIG_ENDIAN
+				: Endianness.LITTLE_ENDIAN;
+		return this;
+	}
+
+	/**
+	 * Child class implements this method to realize <code>array()</code>.
+	 * 
+	 * @return see <code>array()</code>
+	 */
+	abstract byte[] protectedArray();
+
+	/**
+	 * Child class implements this method to realize <code>arrayOffset()</code>.
+	 * 
+	 * @return see <code>arrayOffset()</code>
+	 */
+	abstract int protectedArrayOffset();
+
+	/**
+	 * Child class implements this method to realize <code>hasArray()</code>.
+	 * 
+	 * @return see <code>hasArray()</code>
+	 */
+	abstract boolean protectedHasArray();
+
+	/**
+	 * Writes the given byte to the current position and increase the position
+	 * by 1.
+	 * 
+	 * @param b
+	 *            The byte to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is equal or greater than limit
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer put(byte b);
+
+	/**
+	 * Writes <code>byte</code>s in the given byte array to the current
+	 * position and increase the position by the number of <code>byte</code>s
+	 * writtern.
+	 * <p>
+	 * Calling this method has the same effect as
+	 * <code>put(src, 0, src.length)</code>.
+	 * </p>
+	 * 
+	 * @param src
+	 *            The source byte array
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If <code>remaining()</code> is less than
+	 *                <code>src.length</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public final ByteBuffer put(byte[] src) {
+		return put(src, 0, src.length);
+	}
+
+	/**
+	 * Writes <code>byte</code>s in the given byte array, starting from the
+	 * specified offset, to the current position and increase the position by
+	 * the number of <code>byte</code>s writtern.
+	 * 
+	 * @param src
+	 *            The source byte array
+	 * @param off
+	 *            The offset of byte array, must be no less than zero and no
+	 *            greater than <code>src.length</code>
+	 * @param len
+	 *            The number of <code>byte</code>s to write, must be no less
+	 *            than zero and no greater than <code>src.length - off</code>
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If <code>remaining()</code> is less than
+	 *                <code>len</code>
+	 * @exception IndexOutOfBoundsException
+	 *                If either <code>off</code> or <code>len</code> is
+	 *                invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public ByteBuffer put(byte[] src, int off, int len) {
+        if ((off < 0 ) || (len < 0) || off + len > src.length) {
+            throw new IndexOutOfBoundsException();
+        }
+        
+		if (len > remaining()) {
+			throw new BufferOverflowException();
+		}
+		for (int i = off; i < off + len; i++) {
+			put(src[i]);
+		}
+		return this;
+	}
+
+	/**
+	 * Writes all the remaining <code>byte</code>s of the <code>src</code>
+	 * byte buffer to this buffer's current position, and increase both buffers'
+	 * position by the number of <code>byte</code>s copied.
+	 * 
+	 * @param src
+	 *            The source byte buffer
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If <code>src.remaining()</code> is greater than this
+	 *                buffer's <code>remaining()</code>
+	 * @exception IllegalArgumentException
+	 *                If <code>src</code> is this buffer
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public ByteBuffer put(ByteBuffer src) {
+		if (src == this) {
+			throw new IllegalArgumentException();
+		}
+		if (src.remaining() > remaining()) {
+			throw new BufferOverflowException();
+		}
+        byte[] contents = new byte[src.remaining()];
+        src.get(contents);
+        put(contents);
+		return this;
+	}
+
+	/**
+	 * Write a byte to the specified index of this buffer and the position is
+	 * not changed.
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and less than the limit
+	 * @param b
+	 *            The byte to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer put(int index, byte b);
+
+	/**
+	 * Writes the given char to the current position and increase the position
+	 * by 2.
+	 * <p>
+	 * The char is converted to bytes using the current byte order.
+	 * </p>
+	 * 
+	 * @param value
+	 *            The char to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is greater than <code>limit - 2</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putChar(char value);
+
+	/**
+	 * Write a char to the specified index of this buffer.
+	 * <p>
+	 * The char is converted to bytes using the current byte order. The posotion
+	 * is not changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 2</code>
+	 * @param value
+	 *            The char to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putChar(int index, char value);
+
+	/**
+	 * Writes the given double to the current position and increase the position
+	 * by 8.
+	 * <p>
+	 * The double is converted to bytes using the current byte order.
+	 * </p>
+	 * 
+	 * @param value
+	 *            The double to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is greater than <code>limit - 8</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putDouble(double value);
+
+	/**
+	 * Write a double to the specified index of this buffer.
+	 * <p>
+	 * The double is converted to bytes using the current byte order. The
+	 * posotion is not changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 8</code>
+	 * @param value
+	 *            The double to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putDouble(int index, double value);
+
+	/**
+	 * Writes the given float to the current position and increase the position
+	 * by 4.
+	 * <p>
+	 * The float is converted to bytes using the current byte order.
+	 * </p>
+	 * 
+	 * @param value
+	 *            The float to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is greater than <code>limit - 4</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putFloat(float value);
+
+	/**
+	 * Write a float to the specified index of this buffer.
+	 * <p>
+	 * The float is converted to bytes using the current byte order. The
+	 * posotion is not changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 4</code>
+	 * @param value
+	 *            The float to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putFloat(int index, float value);
+
+	/**
+	 * Writes the given int to the current position and increase the position by
+	 * 4.
+	 * <p>
+	 * The int is converted to bytes using the current byte order.
+	 * </p>
+	 * 
+	 * @param value
+	 *            The int to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is greater than <code>limit - 4</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putInt(int value);
+
+	/**
+	 * Write a int to the specified index of this buffer.
+	 * <p>
+	 * The int is converted to bytes using the current byte order. The posotion
+	 * is not changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 4</code>
+	 * @param value
+	 *            The int to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putInt(int index, int value);
+
+	/**
+	 * Writes the given long to the current position and increase the position
+	 * by 8.
+	 * <p>
+	 * The long is converted to bytes using the current byte order.
+	 * </p>
+	 * 
+	 * @param value
+	 *            The long to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is greater than <code>limit - 8</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putLong(long value);
+
+	/**
+	 * Write a long to the specified index of this buffer.
+	 * <p>
+	 * The long is converted to bytes using the current byte order. The position
+	 * is not changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 8</code>
+	 * @param value
+	 *            The long to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putLong(int index, long value);
+
+	/**
+	 * Writes the given short to the current position and increase the position
+	 * by 2.
+	 * <p>
+	 * The short is converted to bytes using the current byte order.
+	 * </p>
+	 * 
+	 * @param value
+	 *            The short to write
+	 * @return This buffer
+	 * @exception BufferOverflowException
+	 *                If position is greater than <code>limit - 2</code>
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putShort(short value);
+
+	/**
+	 * Write a short to the specified index of this buffer.
+	 * <p>
+	 * The short is converted to bytes using the current byte order. The
+	 * posotion is not changed.
+	 * </p>
+	 * 
+	 * @param index
+	 *            The index, must be no less than zero and equal or less than
+	 *            <code>limit - 2</code>
+	 * @param value
+	 *            The short to write
+	 * @return This buffer
+	 * @exception IndexOutOfBoundsException
+	 *                If <code>index</code> is invalid
+	 * @exception ReadOnlyBufferException
+	 *                If no changes may be made to the contents of this buffer
+	 */
+	public abstract ByteBuffer putShort(int index, short value);
+
+	/**
+	 * Returns a sliced buffer that shares content with this buffer.
+	 * <p>
+	 * The sliced buffer's capacity will be this buffer's 
+	 * <code>remaining()</code>, and its zero position will correspond to 
+	 * this buffer's current position. The new buffer's position will be
+	 * 0, limit will be its capacity, and its mark is unset. The new buffer's
+	 * readonly property and byte order are same as this buffer.</p>
+	 * <p>
+	 * The new buffer shares content with this buffer, which means
+	 * either buffer's change of content will be visible to the other.
+	 * The two buffer's position, limit and mark are independent.</p>
+	 * 
+	 * @return A sliced buffer that shares content with this buffer.
+	 */
+	public abstract ByteBuffer slice();
+
+	/**
+	 * Returns a string represents the state of this byte buffer.
+	 * 
+	 * @return A string represents the state of this byte buffer.
+	 */
+	public String toString() {
+		StringBuffer buf = new StringBuffer();
+		buf.append(getClass().getName());
+		buf.append(", status: capacity="); //$NON-NLS-1$
+		buf.append(capacity());
+		buf.append(" position="); //$NON-NLS-1$
+		buf.append(position());
+		buf.append(" limit="); //$NON-NLS-1$
+		buf.append(limit());
+		return buf.toString();
+	}
+}
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h Mon May  1 16:11:39 2006
@@ -0,0 +1,70 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_ibm_platform_OSFileSystem */
+
+#ifndef _Included_com_ibm_platform_OSFileSystem
+#define _Included_com_ibm_platform_OSFileSystem
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    fflushImpl
+ * Signature: (JZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_fflushImpl
+  (JNIEnv *, jobject, jlong, jboolean);
+
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    seekImpl
+ * Signature: (JJI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_seekImpl
+  (JNIEnv *, jobject, jlong, jlong, jint);
+
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    readImpl
+ * Signature: (J[B)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readImpl
+  (JNIEnv *, jobject, jlong, jbyteArray);
+
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    writeImpl
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSFileSystem_writeImpl
+  (JNIEnv *, jobject, jlong, jint);
+
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    closeImpl
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_closeImpl
+  (JNIEnv *, jobject, jlong);
+
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    truncateImpl
+ * Signature: (JJ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_truncateImpl
+  (JNIEnv *, jobject, jlong, jlong);
+
+/*
+ * Class:     com_ibm_platform_OSFileSystem
+ * Method:    openImpl
+ * Signature: ([BI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_openImpl
+  (JNIEnv *, jobject, jbyteArray, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/com_ibm_platform_OSFileSystem.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh Mon May  1 16:11:39 2006
@@ -0,0 +1,29 @@
+rm *.o
+rm *.lo
+rm *.dll
+rm *.la
+rm -r .libs
+rm *.a
+
+### below are libtool command lines that work fine.  But I use direct gcc command lines because it compiles faster
+### and also reduces confusion.
+#libtool --mode=compile gcc  -g -O -c -fpic  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm emptystub.c
+#libtool --mode=compile gcc  -g -O -c -fpic  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm fileos.c
+
+gcc  -g -O -c  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm emptystub.c
+gcc  -g -O -c  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm fileos.c
+gcc  -g -O -c  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm file.c
+gcc  -g -O -c  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm iohelp.c
+gcc  -g -O -c  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm helpers.c
+
+### below are various failed experiments that were run to get "ld" to work, keep for historical purposes
+#libtool --mode=compile gcc  -g -O -c -fpic  -DLINUX -D_REENTRANT -O1 -march=pentium3 -fno-exceptions -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include -I../luni -I../common -I../zlib -I../zip -I../fdlibm fileos.c
+#libtool --tag=CC --mode=link gcc -pedantic -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -Wstrict-prototypes -g -O2 -module -version-info 0:0:0  -o zzz_wjw.dll fileos.o
+#ld --dll --export-dynamic -call_shared -L/usr/lib --output-def out.def  --out-implib implib.def --enable-auto-import  -o hynio.dll fileos.o
+#libtool --mode=link gcc -module -o xxx.la  fileos.lo -rpath /usr/local/lib  -lm
+#libtool --mode=link gcc -g -o libzzz.la fileos.lo -rpath /usr/local/lib -lm
+#ld -Bshareable -o libzz.dll fileos.o  -lm
+#ld -Bshareable --export-dynamic -o libzz.a junkwjw.o fileos.o -lc
+
+### for some unknown reason, if emptystub.o is removed from the link, ld produces a dll that causes gdb to hang 
+ld -Bshareable --export-dynamic --enable-auto-image-base -o libOSFileSystem.a emptystub.o fileos.o file.o helpers.o iohelp.o -lc

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/doit.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c Mon May  1 16:11:39 2006
@@ -0,0 +1,10 @@
+
+
+int trashwjw(int xx)
+{
+    xx+=33;
+    return xx;
+}
+
+
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/emptystub.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c Mon May  1 16:11:39 2006
@@ -0,0 +1,573 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "iohelp.h"
+#include "jclglob.h"
+#include "helpers.h"
+#include "jclprots.h"
+#include "java_io_File.h"
+
+jboolean JNICALL
+Java_java_io_File_deleteFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  // toss PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = unlink (pathCopy);
+  return result == 0;
+}
+
+jboolean JNICALL
+Java_java_io_File_deleteDirImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = unlink(pathCopy);
+  return result == 0;
+}
+
+jobject JNICALL
+Java_java_io_File_listImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  struct dirEntry
+  {
+    char pathEntry[HyMaxPath];
+    struct dirEntry *next;
+  } *dirList, *currentEntry;
+
+  //PORT_ACCESS_FROM_ENV (env);
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  char filename[HyMaxPath];
+  I_32 result = 0, index;
+  I_32 numEntries = 0;
+  UDATA findhandle;
+  jarray answer = NULL;
+
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  if (length >= 1 && pathCopy[length - 1] != '\\'
+      && pathCopy[length - 1] != '/')
+    {
+      pathCopy[length] = jclSeparator;
+      length++;
+    }
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  printf("file.c:Java_java_io_File_listImpl()-1 is not fully implemented\n");
+  //findhandle = hyfile_findfirst (pathCopy, filename);
+  if (findhandle == (UDATA) - 1)
+    return NULL;
+
+  while (result > -1)
+    {
+      if (strcmp (".", filename) != 0 && (strcmp ("..", filename) != 0))
+        {
+          if (numEntries > 0)
+            {
+              currentEntry->next =
+                (struct dirEntry *) malloc(    sizeof (struct dirEntry));
+              currentEntry = currentEntry->next;
+            }
+          else
+            {
+              dirList =
+                (struct dirEntry *) malloc(sizeof (struct dirEntry));
+              currentEntry = dirList;
+            }
+          if (currentEntry == NULL)
+            {
+              printf("java.io.file.listImpl()-2 is not yet implemented");
+              //hyfile_findclose (findhandle);
+              //throwNewOutOfMemoryError (env, "");
+              goto cleanup;
+            }
+          strcpy (currentEntry->pathEntry, filename);
+          numEntries++;
+        }
+        //result = hyfile_findnext (findhandle, filename);
+        printf("file.c:java_io_File_listImpl()-3 is not fully implemented\n");
+    }
+  close(findhandle);
+
+  if (numEntries == 0)
+    return NULL;
+
+  answer = 0;
+    //(*env)->NewObjectArray (env, numEntries,
+      //                      JCL_CACHE_GET (env, CLS_array_of_byte), NULL);
+cleanup:
+  for (index = 0; index < numEntries; index++)
+    {
+      jbyteArray entrypath;
+      jsize entrylen = strlen (dirList->pathEntry);
+      currentEntry = dirList;
+      if (answer)
+        {
+          entrypath = (*env)->NewByteArray (env, entrylen);
+          (*env)->SetByteArrayRegion (env, entrypath, 0, entrylen,
+                                      (jbyte *) dirList->pathEntry);
+          (*env)->SetObjectArrayElement (env, answer, index, entrypath);
+          (*env)->DeleteLocalRef (env, entrypath);
+        }
+      dirList = dirList->next;
+      free(currentEntry);
+    }
+  return answer;
+}
+
+jboolean JNICALL
+Java_java_io_File_isDirectoryImpl (JNIEnv * env, jobject recv,
+                                   jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  //result = hyfile_attr (pathCopy);
+  struct stat buf;
+  result = stat(pathCopy, &buf);
+  if (result == -1) {
+      printf("file.c:Java_io_File_isDirectoryImpl() -- no such file\n");
+      return -1;
+  }
+  unsigned int isDir = (buf.st_mode & _IFDIR);
+  if (isDir)
+      return 1;
+  return 0;
+}
+
+jboolean JNICALL
+Java_java_io_File_existsImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = access(pathCopy, F_OK);
+  if (result == -1) {
+      printf("file.c:java_io_File_existsImpl() -- path not found\n");
+      return 0;
+  }
+  return 1;
+  //result = hyfile_attr (pathCopy);
+}
+
+jboolean JNICALL
+Java_java_io_File_isFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  struct stat buf;
+  result = stat(pathCopy, &buf);
+  if (result == -1) {
+      printf("file.c:java_io_File_isFileImpl() -- file does not exist");
+      return 0;
+  }
+  int is_file = buf.st_mode & _IFREG;
+  //result = hyfile_attr (pathCopy);
+  return is_file;
+}
+
+jlong JNICALL
+Java_java_io_File_lastModifiedImpl (JNIEnv * env, jobject recv,
+                                    jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_64 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  struct stat buf;
+  int xx = stat(pathCopy, &buf);
+    if (xx == -1) {
+        printf("file.c:java_io_File_lastModifledImpl() -- file does not exist");
+        return 0;
+    }
+  if (xx != 0) return 0;
+  return (jlong)buf.st_mtime * 1024;  // instead of 1000 to get around idiv problem
+  //result = hyfile_lastmod (pathCopy);
+}
+
+jlong JNICALL
+Java_java_io_File_lengthImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_64 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  struct stat buf;
+  int xx = stat(pathCopy, &buf);
+    if (xx == -1) {
+        printf("file.c:java_io_File_lengthImpl() -- file does not exist");
+        return 0;
+    }
+  //result = hyfile_length (pathCopy);
+  if (xx != 0)
+    {
+      return 0L;
+    }
+  return buf.st_size;
+}
+
+jboolean JNICALL
+Java_java_io_File_isAbsoluteImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  I_32 result = 0;
+  jsize length = (*env)->GetArrayLength (env, path);
+  jbyte *lpath = (jbyte *) ((*env)->GetPrimitiveArrayCritical (env, path, 0));
+
+  if (jclSeparator == '/' && length > 0)
+    {
+      result = (lpath[0] == jclSeparator);
+      goto release;
+    }
+  if (length > 1 && lpath[0] == '\\' && lpath[1] == '\\')
+    {
+      result = 1;
+      goto release;
+    }
+  if (length > 2)
+    {
+      if (isalpha (lpath[0]) && lpath[1] == ':'
+          && (lpath[2] == '\\' || lpath[2] == '/'))
+        result = 1;
+    }
+
+release:
+  /* Easier to release in one area than copy the code around */
+  (*env)->ReleasePrimitiveArrayCritical (env, path, lpath, JNI_ABORT);
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_mkdirImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  //result = hyfile_mkdir (pathCopy);
+  result = mkdir(pathCopy, 0777);
+  return (jboolean) (!result);
+}
+
+jboolean JNICALL
+Java_java_io_File_renameToImpl (JNIEnv * env, jobject recv,
+                                jbyteArray pathExist, jbyteArray pathNew)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length;
+  char pathExistCopy[HyMaxPath], pathNewCopy[HyMaxPath];
+  length = (*env)->GetArrayLength (env, pathExist);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, pathExist, 0, length, pathExistCopy));
+  pathExistCopy[length] = '\0';
+  length = (*env)->GetArrayLength (env, pathNew);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, pathNew, 0, length, pathNewCopy));
+  pathNewCopy[length] = '\0';
+  ioh_convertToPlatform (pathExistCopy);
+  ioh_convertToPlatform (pathNewCopy);
+  result = rename(pathExistCopy, pathNewCopy);
+  //result = hyfile_move (pathExistCopy, pathNewCopy);
+  return (jboolean) (!result);
+}
+
+jobject JNICALL
+Java_java_io_File_getCanonImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  /* This needs work.  Currently is does no more or less than VAJ-20 ST implementation
+   * but really should figure out '..', '.', and really resolve references.
+   */
+  jbyteArray answer;
+  jsize answerlen;
+  char pathCopy[HyMaxPath];
+  U_32 length = (U_32) (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  (*env)->GetByteArrayRegion (env, path, 0, length, pathCopy);
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+#if defined(WIN32)
+  //platformCanonicalPath (pathCopy);
+#endif
+
+  answerlen = strlen (pathCopy);
+  answer = (*env)->NewByteArray (env, answerlen);
+  (*env)->SetByteArrayRegion (env, answer, 0, answerlen, (jbyte *) pathCopy);
+  return answer;
+}
+
+jint JNICALL
+Java_java_io_File_newFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  IDATA portFD;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  printf("file.c:java_io_File_newFileImpl() is not implemented yet\n");
+  return 0;
+
+// hacked out of the way for now
+#if 0
+  /* First check to see if file already exists */
+  //result = hyfile_attr (pathCopy);
+  if (result == HyIsDir)
+    return 3;
+  if (result >= 0)
+    return 1;
+
+  /* Now create the file and close it */
+  //portFD =
+  //  hyfile_open (pathCopy, HyOpenCreate | HyOpenWrite | HyOpenTruncate, 0666);
+  if (portFD == -1)
+    return 2;
+  //hyfile_close (portFD);
+  return 0;
+#endif // hacked out of the way for now
+}
+
+jobject JNICALL
+Java_java_io_File_rootsImpl (JNIEnv * env, jclass clazz)
+{
+  char rootStrings[HyMaxPath], *rootCopy;
+  I_32 numRoots;
+  I_32 index = 0;
+  jarray answer;
+
+  printf("file.c:java_io_File_rootsImpl() is not implemented\n");
+  return 0;
+#if 0
+  // hacked out of the way for now
+   /**
+	 * It is the responsibility of #getPlatformRoots to return a char array
+	 * with volume names separated by null with a trailing extra null, so for
+	 * Unix it should be '\<null><null>' .
+	 */
+  //numRoots = getPlatformRoots (rootStrings);
+  if (numRoots == 0)
+    return NULL;
+  rootCopy = rootStrings;
+
+  answer = 0;
+    //(*env)->NewObjectArray (env, numRoots,
+      //                      JCL_CACHE_GET (env, CLS_array_of_byte), NULL);
+  if (!answer)
+    {
+      return NULL;
+    }
+  while (TRUE)
+    {
+      jbyteArray rootname;
+      jsize entrylen = strlen (rootCopy);
+      /* Have we hit the second null? */
+      if (entrylen == 0)
+        break;
+      rootname = (*env)->NewByteArray (env, entrylen);
+      (*env)->SetByteArrayRegion (env, rootname, 0, entrylen,
+                                  (jbyte *) rootCopy);
+      (*env)->SetObjectArrayElement (env, answer, index++, rootname);
+      (*env)->DeleteLocalRef (env, rootname);
+      rootCopy = rootCopy + entrylen + 1;
+    }
+  return answer;
+#endif  // hacked out of the way for now
+}
+
+jboolean JNICALL
+Java_java_io_File_isHiddenImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  printf("file.c:java_io_File_isHiddenImpl() is not implemented\n");
+  //ioh_convertToPlatform (pathCopy);
+  //result = getPlatformIsHidden (env, pathCopy);
+  return 0; /// result;
+}
+
+jboolean JNICALL
+Java_java_io_File_setLastModifiedImpl (JNIEnv * env, jobject recv,
+                                       jbyteArray path, jlong time)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  //ioh_convertToPlatform (pathCopy);
+
+  //result = setPlatformLastModified (env, pathCopy, (I_64) time);
+
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_setReadOnlyImpl (JNIEnv * env, jobject recv,
+                                   jbyteArray path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  //ioh_convertToPlatform (pathCopy);
+  printf("file.c:java_io_File_setReadOnlyImpl() is not implemented\n");
+  return 0; /// setPlatformReadOnly (env, pathCopy);
+}
+
+void JNICALL
+Java_java_io_File_oneTimeInitialization (JNIEnv * env, jclass clazz)
+{
+  jclass arrayClass = (*env)->FindClass (env, "[B");
+  if (arrayClass)
+    {
+      // NewWeakGlobalRef in not implemented in JCHEVM
+      //jobject globalRef = (*env)->NewWeakGlobalRef (env, arrayClass);
+      //if (globalRef)
+      //  JCL_CACHE_SET (env, CLS_array_of_byte, globalRef);
+    }
+  return;
+}
+
+jbyteArray JNICALL
+Java_java_io_File_properPathImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+    //printf("file.c:java_io_File_properPathImpl() is not fully implemented\n");
+  return path; // getPlatformPath (env, path);
+}
+
+jboolean JNICALL
+Java_java_io_File_isReadOnlyImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  //ioh_convertToPlatform (pathCopy);
+  //result = getPlatformIsReadOnly (env, pathCopy);
+  printf("file.c:java_io_File_isReadOnlyImpl() is not implemented\n");
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_isWriteOnlyImpl (JNIEnv * env, jobject recv,
+                                   jbyteArray path)
+{
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  //ioh_convertToPlatform (pathCopy);
+  //result = getPlatformIsWriteOnly (env, pathCopy);
+  printf("file.c:java_io_File_isWriteOnlyImpl() is not implemented\n");
+  return result;
+}
+
+jobject JNICALL
+Java_java_io_File_getLinkImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  jbyteArray answer;
+  jsize answerlen;
+  char pathCopy[HyMaxPath];
+  U_32 length = (U_32) (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  (*env)->GetByteArrayRegion (env, path, 0, length, pathCopy);
+  pathCopy[length] = '\0';
+  //ioh_convertToPlatform (pathCopy);
+  if ( 0) ////////platformReadLink (pathCopy))
+    {
+      answerlen = strlen (pathCopy);
+      answer = (*env)->NewByteArray (env, answerlen);
+      (*env)->SetByteArrayRegion (env, answer, 0, answerlen,
+                                  (jbyte *) pathCopy);
+    }
+  else
+    {
+      answer = path;
+    }
+  printf("file.c:java_io_File_getLinkImpl() is not implemented\n");
+  return answer;
+}
+
+jboolean JNICALL
+Java_java_io_File_isCaseSensitiveImpl (JNIEnv * env, jclass clazz)
+{
+/* Assume all other platforms ARE case sensitive and add to this list when they prove otherwise */
+#if (defined(WIN32))
+  return FALSE;
+#else
+  return TRUE;
+#endif
+
+}
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/file.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c Mon May  1 16:11:39 2006
@@ -0,0 +1,107 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include "iohelp.h"
+#include "jclglob.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "jni.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "com_ibm_platform_OSFileSystem.h"
+///////////////gnuclasspathadapter
+
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_fflushImpl
+  (JNIEnv *env, jobject obj1, jlong fileDescriptor, jboolean bool1)
+{
+    printf("Java_com_ibm_platform_OSFileSystem_fflushImpl not implemented\n"); //fflush(stdout);
+    return 0;
+}
+
+
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_seekImpl
+  (JNIEnv *env, jobject obj1, jlong fd, jlong offset, jint whence)
+{
+    jlong position = lseek(fd, 0L, SEEK_SET);
+    if (position == -1) {
+        printf("Java_com_ibm_platform_OSFileSystem_seekImpl failed --1\n");
+        return -1;
+    }
+    position = lseek(fd, offset, whence);
+    return position;
+}
+
+
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readImpl
+  (JNIEnv *env, jobject obj1, jlong fd, jbyteArray oneByteArray)
+{
+    unsigned char zz;
+    jboolean bb = 1;
+    int stat = read(fd, &zz, 1);
+///jbyte *(JNICALL *      GetByteArrayElements)(JNIEnv *env, jbyteArray array, jboolean *isCopy);
+    jbyte *theByte  = (*env)->GetByteArrayElements(env, oneByteArray, &bb);
+    theByte[0] = (jbyte)zz;
+    (*env)->ReleaseByteArrayElements(env, oneByteArray, theByte, 0);
+    return 0;
+}
+
+
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSFileSystem_writeImpl
+  (JNIEnv *env, jobject obj1, jlong fileDescriptor, jint theCharacterToBeWritten)
+{  
+    int xx = 0x000000ff & (int)theCharacterToBeWritten;
+    char cc = (char)xx;
+    int yy = (int)fileDescriptor;
+    write(yy, &cc, 1);
+}
+
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_closeImpl
+  (JNIEnv *env, jobject obj1, jlong fd)
+{
+    return (jint)close(fd);
+}
+
+
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_truncateImpl
+  (JNIEnv *env, jobject obj1, jlong long1, jlong long2)
+{
+    printf("Java_com_ibm_platform_OSFileSystem_truncateImpl not implemented\n");
+    return 0;
+}
+
+
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_openImpl
+  (JNIEnv *env, jobject obj1, jbyteArray ba1, jint int1)
+{
+    int fmode = O_CREAT|O_RDWR;
+    jboolean isCopy = 1;
+	
+    I_32 result;
+    char pathCopy[HyMaxPath];
+    jsize length = (*env)->GetArrayLength (env, ba1);
+    length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+    ((*env)->GetByteArrayRegion (env, ba1, 0, length, pathCopy));
+    pathCopy[length] = '\0';
+    ioh_convertToPlatform (pathCopy);
+
+    jlong fd = (jlong)open(pathCopy, fmode, 0755);
+
+    return fd;
+}
+
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/fileos.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c Mon May  1 16:11:39 2006
@@ -0,0 +1,213 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <utime.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <locale.h>
+
+#include <langinfo.h>
+
+#include <dirent.h>
+
+#include "helpers.h"
+#include "jclprots.h"
+#include "jclglob.h"
+
+int portCmp (const void **a, const void **b);
+
+/**
+ * It is the responsibility of #getPlatformRoots to return a char array
+ * with volume names separated by null with a trailing extra null, so for
+ * Unix it should be '\<null><null>' .
+ */
+I_32
+getPlatformRoots (char *rootStrings)
+{
+  rootStrings[0] = (char) '/';
+  rootStrings[1] = (char) NULL;
+  rootStrings[2] = (char) NULL;
+  return 1;
+}
+
+/**
+ * Answer 1 if the path is hidden, 0 otherwise even in fail cases.
+ */
+I_32
+getPlatformIsHidden (JNIEnv * env, char *path)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+
+  /* Answer true if the file exists and starts with a period */
+  I_32 length = strlen (path), index, existsResult;
+  //existsResult = hyfile_attr (path);
+  if (existsResult < 0)
+    return 0;
+
+  if (length == 0)
+    return 0;
+  for (index = length; index >= 0; index--)
+    {
+      if (path[index] == '.' && (index > 0 && path[index - 1] == '/'))
+        return 1;
+    }
+
+  return 0;
+}
+
+/**
+ * Answer 1 if the file time was updated, 0 otherwise even in fail cases.
+ */
+I_32
+setPlatformLastModified (JNIEnv * env, char *path, I_64 time)
+{
+
+  //PORT_ACCESS_FROM_ENV (env);
+  struct stat statbuf;
+  struct utimbuf timebuf;
+  if (stat (path, &statbuf))
+    return FALSE;
+  timebuf.actime = statbuf.st_atime;
+  timebuf.modtime = (time_t) (time/1024);  //// wjw cygwin's libc does not have __idiv3  --->  / 1000);
+  return utime (path, &timebuf) == 0;
+
+}
+
+/**
+ * Answer 1 if the path is now readOnly, 0 otherwise even in fail cases.
+ */
+I_32
+setPlatformReadOnly (JNIEnv * env, char *path)
+{
+  struct stat buffer;
+  mode_t mode;
+  if (stat (path, &buffer))
+    {
+      return 0;
+    }
+  mode = buffer.st_mode;
+  mode = mode & 07555;
+  return chmod (path, mode) == 0;
+
+}
+
+/**
+ * Answer 1 if the file length was set, 0 otherwise even in fail cases.
+ */
+I_32
+setPlatformFileLength (JNIEnv * env, IDATA descriptor, jlong newLength)
+{
+
+  return (ftruncate ((int) descriptor, newLength) == 0);
+
+}
+
+jbyteArray
+getPlatformPath (JNIEnv * env, jbyteArray path)
+{
+  return NULL;
+}
+
+void
+setPlatformBindOptions (JNIEnv * env, hysocket_t socketP)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  BOOLEAN value = TRUE;
+
+  //hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);
+}
+
+/**
+ * Answer 1 if the path is read-only, 0 otherwise even in fail cases.
+ */
+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;
+
+}
+
+/**
+ * Answer 1 if the path is write-only, 0 otherwise even in fail cases.
+ */
+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;
+
+}
+
+/* Resolve link if it is a symbolic link and put the result in link. */
+int
+platformReadLink (char *link)
+{
+
+  int size = readlink (link, link, HyMaxPath);
+  if (size <= 0)
+    return FALSE;
+  if (size >= HyMaxPath)
+    link[HyMaxPath - 1] = 0;
+  else
+    link[size] = 0;
+  return TRUE;
+
+}
+
+jstring
+getCustomTimeZoneInfo (JNIEnv * env, jintArray tzinfo,
+                       jbooleanArray isCustomTimeZone)
+{
+  return NULL;
+}
+
+void
+setDefaultServerSocketOptions (JNIEnv * env, hysocket_t socketP)
+{
+  //PORT_ACCESS_FROM_ENV (env);
+  BOOLEAN value = TRUE;
+
+  //hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);
+}
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/helpers.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c Mon May  1 16:11:39 2006
@@ -0,0 +1,80 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iohelp.h"
+#include "jclglob.h"
+
+void
+ioh_convertToPlatform (char *path)
+{
+  char *pathIndex;
+  int length = strlen (path);
+
+  /* Convert all separators to the same type */
+  pathIndex = path;
+  while (*pathIndex != '\0')
+    {
+      if ((*pathIndex == '\\' || *pathIndex == '/')
+          && (*pathIndex != jclSeparator))
+        *pathIndex = jclSeparator;
+      pathIndex++;
+    }
+
+  /* Remove duplicate separators */
+  if (jclSeparator == '/')
+    return;                     /* Do not do POSIX platforms */
+
+  /* Remove duplicate initial separators */
+  pathIndex = path;
+  while ((*pathIndex != '\0') && (*pathIndex == jclSeparator))
+    {
+      pathIndex++;
+    }
+
+  if ((pathIndex > path) && (length > (pathIndex - path))
+      && (*(pathIndex + 1) == ':'))
+    {
+      /* For Example '////c:/*' */
+      int newlen = length - (pathIndex - path);
+      memmove (path, pathIndex, newlen);
+      path[newlen] = '\0';
+    }
+  else
+    {
+      if ((pathIndex - path > 3) && (length > (pathIndex - path)))
+        {
+          /* For Example '////serverName/*' */
+          int newlen = length - (pathIndex - path) + 2;
+          memmove (path, pathIndex - 2, newlen);
+          path[newlen] = '\0';
+        }
+    }
+  /* This will have to handle extra \'s but currently doesn't */
+}
+
+/**
+  * Throw java.lang.OutOfMemoryError
+  */
+void
+throwNewOutOfMemoryError (JNIEnv * env, char *message)
+{
+  jclass exceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
+  if (0 == exceptionClass) { 
+    /* Just return if we can't load the exception class. */
+    return;
+    }
+  (*env)->ThrowNew(env, exceptionClass, message);
+}
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/iohelp.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h?rev=398726&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h (added)
+++ incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h Mon May  1 16:11:39 2006
@@ -0,0 +1,200 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class java_io_File */
+
+#ifndef _Included_java_io_File
+#define _Included_java_io_File
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef java_io_File_serialVersionUID
+#define java_io_File_serialVersionUID 301077366599181567i64
+/*
+ * Class:     java_io_File
+ * Method:    oneTimeInitialization
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_File_oneTimeInitialization
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     java_io_File
+ * Method:    rootsImpl
+ * Signature: ()[[B
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_io_File_rootsImpl
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     java_io_File
+ * Method:    isCaseSensitiveImpl
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isCaseSensitiveImpl
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     java_io_File
+ * Method:    deleteDirImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_deleteDirImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    deleteFileImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_deleteFileImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    existsImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_existsImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    getCanonImpl
+ * Signature: ([B)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_java_io_File_getCanonImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    isAbsoluteImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isAbsoluteImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    isDirectoryImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isDirectoryImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    isFileImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isFileImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    isHiddenImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isHiddenImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    isReadOnlyImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isReadOnlyImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    isWriteOnlyImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_isWriteOnlyImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    getLinkImpl
+ * Signature: ([B)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_java_io_File_getLinkImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    lastModifiedImpl
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_java_io_File_lastModifiedImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    setLastModifiedImpl
+ * Signature: ([BJ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_setLastModifiedImpl
+  (JNIEnv *, jobject, jbyteArray, jlong);
+
+/*
+ * Class:     java_io_File
+ * Method:    setReadOnlyImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_setReadOnlyImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    lengthImpl
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_java_io_File_lengthImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    listImpl
+ * Signature: ([B)[[B
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_io_File_listImpl
+  (JNIEnv *, jclass, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    mkdirImpl
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_mkdirImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    newFileImpl
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_java_io_File_newFileImpl
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    properPathImpl
+ * Signature: ([B)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_java_io_File_properPathImpl
+  (JNIEnv *, jclass, jbyteArray);
+
+/*
+ * Class:     java_io_File
+ * Method:    renameToImpl
+ * Signature: ([B[B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_java_io_File_renameToImpl
+  (JNIEnv *, jobject, jbyteArray, jbyteArray);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+

Propchange: incubator/harmony/enhanced/classlibadapter/trunk/native-src/linux.IA32/luni_gnuclasspathadapter/java_io_File.h
------------------------------------------------------------------------------
    svn:eol-style = native