]> source.dussan.org Git - jgit.git/commitdiff
Use java.nio.file consistently in FS 90/56390/3
authorMatthias Sohn <matthias.sohn@sap.com>
Mon, 21 Sep 2015 23:17:18 +0000 (01:17 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 27 Sep 2015 20:24:06 +0000 (22:24 +0200)
Since 4.0 we require Java 7 so there is no longer a need to override the
following methods in FS_POSIX, FS_Win32, FS_Win32_Cygwin
- lastModified()
- setLastModified()
- length()
- isSymlink()
- exists()
- isDirectory()
- isFile()
- isHidden()
Hence implement these methods in FS and remove overrides in subclasses.

Change-Id: I5dbde6ec806c66c86ac542978918361461021294
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java

index e2bed1873a894369792c90f5c36118ff11727e39..34bbb415baf989a2ed341a9adc2d903eeab98bb8 100644 (file)
@@ -286,7 +286,6 @@ funnyRefname=funny refname
 gcFailed=Garbage collection failed.
 gitmodulesNotFound=.gitmodules not found in tree.
 headRequiredToStash=HEAD required to stash local changes
-hiddenFilesStartWithDot=Hiding only allowed for names that start with a period
 hoursAgo={0} hours ago
 hugeIndexesAreNotSupportedByJgitYet=Huge indexes are not supported by jgit, yet
 hunkBelongsToAnotherFile=Hunk belongs to another file
index d6cf6e6a7f13ebe351f706e81513d15998570489..9067e829549b75fd06e183d4e95fbf02be3bf69f 100644 (file)
@@ -345,7 +345,6 @@ public class JGitText extends TranslationBundle {
        /***/ public String gcFailed;
        /***/ public String gitmodulesNotFound;
        /***/ public String headRequiredToStash;
-       /***/ public String hiddenFilesStartWithDot;
        /***/ public String hoursAgo;
        /***/ public String hugeIndexesAreNotSupportedByJgitYet;
        /***/ public String hunkBelongsToAnotherFile;
index 4d34394ba059d972d12e46fdb46e2a36a00f5312..e5219b2a9205eea413477b451c2a546fb4330f00 100644 (file)
@@ -247,7 +247,7 @@ public abstract class FS {
         * @since 3.0
         */
        public long lastModified(File f) throws IOException {
-               return f.lastModified();
+               return FileUtils.lastModified(f);
        }
 
        /**
@@ -260,7 +260,7 @@ public abstract class FS {
         * @since 3.0
         */
        public void setLastModified(File f, long time) throws IOException {
-               f.setLastModified(time);
+               FileUtils.setLastModified(f, time);
        }
 
        /**
@@ -273,7 +273,7 @@ public abstract class FS {
         * @since 3.0
         */
        public long length(File path) throws IOException {
-               return path.length();
+               return FileUtils.getLength(path);
        }
 
        /**
@@ -630,7 +630,7 @@ public abstract class FS {
         * @since 3.0
         */
        public boolean isSymLink(File path) throws IOException {
-               return false;
+               return FileUtils.isSymlink(path);
        }
 
        /**
@@ -642,7 +642,7 @@ public abstract class FS {
         * @since 3.0
         */
        public boolean exists(File path) {
-               return path.exists();
+               return FileUtils.exists(path);
        }
 
        /**
@@ -654,7 +654,7 @@ public abstract class FS {
         * @since 3.0
         */
        public boolean isDirectory(File path) {
-               return path.isDirectory();
+               return FileUtils.isDirectory(path);
        }
 
        /**
@@ -666,7 +666,7 @@ public abstract class FS {
         * @since 3.0
         */
        public boolean isFile(File path) {
-               return path.isFile();
+               return FileUtils.isFile(path);
        }
 
        /**
@@ -677,7 +677,7 @@ public abstract class FS {
         * @since 3.0
         */
        public boolean isHidden(File path) throws IOException {
-               return path.isHidden();
+               return FileUtils.isHidden(path);
        }
 
        /**
@@ -689,9 +689,7 @@ public abstract class FS {
         * @since 3.0
         */
        public void setHidden(File path, boolean hidden) throws IOException {
-               if (!path.getName().startsWith(".")) //$NON-NLS-1$
-                       throw new IllegalArgumentException(
-                                       JGitText.get().hiddenFilesStartWithDot);
+               FileUtils.setHidden(path, hidden);
        }
 
        /**
index c2005b13ee3a39f40dbd353b477d5f9d6273c4c7..779b10e1bb83b4425110329f5e8fe3c1227c9b82 100644 (file)
@@ -245,46 +245,6 @@ public class FS_POSIX extends FS {
                return true;
        }
 
-       @Override
-       public boolean isSymLink(File path) throws IOException {
-               return FileUtils.isSymlink(path);
-       }
-
-       @Override
-       public long lastModified(File path) throws IOException {
-               return FileUtils.lastModified(path);
-       }
-
-       @Override
-       public void setLastModified(File path, long time) throws IOException {
-               FileUtils.setLastModified(path, time);
-       }
-
-       @Override
-       public long length(File f) throws IOException {
-               return FileUtils.getLength(f);
-       }
-
-       @Override
-       public boolean exists(File path) {
-               return FileUtils.exists(path);
-       }
-
-       @Override
-       public boolean isDirectory(File path) {
-               return FileUtils.isDirectory(path);
-       }
-
-       @Override
-       public boolean isFile(File path) {
-               return FileUtils.isFile(path);
-       }
-
-       @Override
-       public boolean isHidden(File path) throws IOException {
-               return FileUtils.isHidden(path);
-       }
-
        @Override
        public void setHidden(File path, boolean hidden) throws IOException {
                // no action on POSIX
index 21aafc37deda00d72f52f246f4cbbf37e360ecc9..f0a2e721a6221001a464a99c379e54ddee9167f2 100644 (file)
@@ -183,51 +183,6 @@ public class FS_Win32 extends FS {
                }
        }
 
-       @Override
-       public boolean isSymLink(File path) throws IOException {
-               return FileUtils.isSymlink(path);
-       }
-
-       @Override
-       public long lastModified(File path) throws IOException {
-               return FileUtils.lastModified(path);
-       }
-
-       @Override
-       public void setLastModified(File path, long time) throws IOException {
-               FileUtils.setLastModified(path, time);
-       }
-
-       @Override
-       public long length(File f) throws IOException {
-               return FileUtils.getLength(f);
-       }
-
-       @Override
-       public boolean exists(File path) {
-               return FileUtils.exists(path);
-       }
-
-       @Override
-       public boolean isDirectory(File path) {
-               return FileUtils.isDirectory(path);
-       }
-
-       @Override
-       public boolean isFile(File path) {
-               return FileUtils.isFile(path);
-       }
-
-       @Override
-       public boolean isHidden(File path) throws IOException {
-               return FileUtils.isHidden(path);
-       }
-
-       @Override
-       public void setHidden(File path, boolean hidden) throws IOException {
-               FileUtils.setHidden(path, hidden);
-       }
-
        /**
         * @since 3.3
         */
index 2952b65202df2d1b6d7193d0860a4ded9bd57629..2450be4c17f211f88f51b1dbffa6fd3687704879 100644 (file)
@@ -44,7 +44,6 @@
 package org.eclipse.jgit.util;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -168,59 +167,6 @@ public class FS_Win32_Cygwin extends FS_Win32 {
                return true;
        }
 
-       @Override
-       public boolean isSymLink(File path) throws IOException {
-               return FileUtils.isSymlink(path);
-       }
-
-       @Override
-       public long lastModified(File path) throws IOException {
-               return FileUtils.lastModified(path);
-       }
-
-       @Override
-       public void setLastModified(File path, long time) throws IOException {
-               FileUtils.setLastModified(path, time);
-       }
-
-       @Override
-       public long length(File f) throws IOException {
-               return FileUtils.getLength(f);
-       }
-
-       @Override
-       public boolean exists(File path) {
-               return FileUtils.exists(path);
-       }
-
-       @Override
-       public boolean isDirectory(File path) {
-               return FileUtils.isDirectory(path);
-       }
-
-       @Override
-       public boolean isFile(File path) {
-               return FileUtils.isFile(path);
-       }
-
-       @Override
-       public boolean isHidden(File path) throws IOException {
-               return FileUtils.isHidden(path);
-       }
-
-       @Override
-       public void setHidden(File path, boolean hidden) throws IOException {
-               FileUtils.setHidden(path, hidden);
-       }
-
-       /**
-        * @since 3.3
-        */
-       @Override
-       public Attributes getAttributes(File path) {
-               return FileUtils.getFileAttributesBasic(this, path);
-       }
-
        /**
         * @since 3.7
         */