]> source.dussan.org Git - jgit.git/commitdiff
Length of symbolic link is the number of bytes, not characters 89/15389/13
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Wed, 10 Jul 2013 15:33:50 +0000 (17:33 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 10 Feb 2014 22:29:25 +0000 (23:29 +0100)
Change-Id: I6b615f0d5da4339f1f23a29bcaeb80f0346f5764

org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java
org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FileUtil.java

index 4b5fe5979eeef4ece4d5769d35a48ede8cb0a3e2..70eaef231a0bced57e8bb64f767180d441580b51 100644 (file)
@@ -85,16 +85,16 @@ public class FSJava7Test {
        @Test
        public void testSymlinkAttributes() throws IOException, InterruptedException {
                FS fs = FS.DETECTED;
-               File link = new File(trash, "x");
-               File target = new File(trash, "y");
-               fs.createSymLink(link, "y");
+               File link = new File(trash, "ä");
+               File target = new File(trash, "å");
+               fs.createSymLink(link, "å");
                assertTrue(fs.exists(link));
                String targetName = fs.readSymLink(link);
-               assertEquals("y", targetName);
+               assertEquals("å", targetName);
                assertTrue(fs.lastModified(link) > 0);
                assertTrue(fs.exists(link));
                assertFalse(fs.canExecute(link));
-               assertEquals(1, fs.length(link));
+               assertEquals(2, fs.length(link));
                assertFalse(fs.exists(target));
                assertFalse(fs.isFile(target));
                assertFalse(fs.isDirectory(target));
index 428a45f79bd4a5119e40ac0fe78dab49223773a8..0fd19bcdd17c5d6dc8df626936fb1f4c76939247 100644 (file)
@@ -52,7 +52,7 @@ import java.nio.file.attribute.FileTime;
 import java.text.Normalizer;
 import java.text.Normalizer.Form;
 
-import org.eclipse.jgit.util.SystemReader;
+import org.eclipse.jgit.lib.Constants;
 
 class FileUtil {
 
@@ -113,7 +113,8 @@ class FileUtil {
        public static long getLength(File path) throws IOException {
                Path nioPath = path.toPath();
                if (Files.isSymbolicLink(nioPath))
-                       return Files.readSymbolicLink(nioPath).toString().length();
+                       return Files.readSymbolicLink(nioPath).toString()
+                                       .getBytes(Constants.CHARSET).length;
                return Files.size(nioPath);
        }