[kaffe] CVS kaffe (dalibor): Added missing file from last checkin

Kaffe CVS cvs-commits at kaffe.org
Mon May 17 21:14:02 PDT 2004


PatchSet 4744 
Date: 2004/05/18 03:55:15
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Added missing file from last checkin

Members: 
	libraries/javalib/java/io/VMFile.java:INITIAL->1.1 

===================================================================
Checking out kaffe/libraries/javalib/java/io/VMFile.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/java/io/VMFile.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/java/io/VMFile.java	Tue May 18 03:59:20 2004
@@ -0,0 +1,194 @@
+/* VMFile.java -- Class for methods natively accessing files
+   Copyright (C) 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.classpath.Configuration;
+import gnu.java.io.PlatformHelper;
+
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+final class VMFile
+{
+	static boolean caseSensitive;
+	
+	static
+	{
+	  if (Configuration.INIT_LOAD_LIBRARY)
+		{
+		  System.loadLibrary("io");
+		}
+    
+		// FIXME: We support only caseSensitive filesystems currently.
+		caseSensitive = true;
+	}
+  
+  /*
+   * This native method does the actual work of getting the last file
+   * modification time.  It also does the existence check to avoid the
+   * overhead of a call to exists()
+   */
+  static native long lastModified(String path);
+
+  /*
+   * This native method sets the permissions to make the file read only.
+   */
+  static native boolean setReadOnly(String path);
+
+  /**
+   * This method is used to create a temporary file
+   */
+  static native boolean create(String path) throws IOException;
+
+  /*
+   * This native function actually produces the list of file in this
+   * directory
+   */
+  static native String[] list(String dirpath);
+
+  /*
+   * This native method actually performs the rename.
+   */
+  static native boolean renameTo(String targetpath, String destpath);
+
+  /*
+   * This native method actually determines the length of the file and
+   * handles the existence check
+   */
+  static native long length(String path);
+
+  /*
+   * This native method does the actual checking of file existence.
+   */
+  static native boolean exists(String path);
+
+  /*
+   * This native method handles the actual deleting of the file
+   */
+  static native boolean delete(String path);
+
+  /*
+   * This method does the actual setting of the modification time.
+   */
+  static native boolean setLastModified(String path, long time);
+
+  /*
+   * This native method actually creates the directory
+   */
+  static native boolean mkdir(String dirpath);
+
+  /*
+   * This native method does the actual check of whether or not a file
+   * is a plain file or not.  It also handles the existence check to
+   * eliminate the overhead of a call to exists()
+   */
+  static native boolean isFile(String path);
+
+  /**
+   * This native method checks file permissions for writing
+   */
+  static synchronized native boolean canWrite(String path);
+
+  /**
+   * This native method checks file permissions for reading
+   */
+  static synchronized native boolean canRead(String path);
+
+  /*
+   * This method does the actual check of whether or not a file is a
+   * directory or not.  It also handle the existence check to eliminate
+   * the overhead of a call to exists()
+   */
+  static native boolean isDirectory(String dirpath);
+
+  /**
+   * This method returns an array of filesystem roots.  Some operating systems
+   * have volume oriented filesystem.  This method provides a mechanism for
+   * determining which volumes exist.  GNU systems use a single hierarchical
+   * filesystem, so will have only one "/" filesystem root.
+   *
+   * @return An array of <code>File</code> objects for each filesystem root
+   * available.
+   *
+   * @since 1.2
+   */
+  static File[] listRoots()
+  {
+	File[] roots = new File[1];
+	roots[0] = new File("/");
+	return roots;
+  }
+
+  /**
+   * This method tests whether or not this file represents a "hidden" file.
+   * On GNU systems, a file is hidden if its name begins with a "."
+   * character.  Files with these names are traditionally not shown with
+   * directory listing tools.
+   *
+   * @return <code>true</code> if the file is hidden, <code>false</code>
+   * otherwise.
+   *
+   * @since 1.2
+   */
+  static boolean isHidden(String path)
+  {
+	// FIXME: this only works on UNIX
+	return getName(path).startsWith(".");
+  }
+
+  /**
+   * This method returns the name of the file.  This is everything in the
+   * complete path of the file after the last instance of the separator
+   * string.
+   *
+   * @return The file name
+   */
+  static String getName(String path)
+  {
+	int pos = PlatformHelper.lastIndexOfSeparator(path);
+	if (pos == -1)
+	  return path;
+	
+	if (PlatformHelper.endWithSeparator(path))
+	  return "";
+	
+	return path.substring(pos + File.separator.length());
+  }
+}




More information about the kaffe mailing list