From 9af47c10c6a268877c1d232c8d71ee6df4f8a7ab Mon Sep 17 00:00:00 2001
From: Jeroen Baten <jeroen@jeroenbaten.nl>
Date: Fri, 04 Jan 2013 05:18:37 -0500
Subject: [PATCH] Dutch translation before spellcheck

---
 src/com/gitblit/utils/FileUtils.java |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/com/gitblit/utils/FileUtils.java b/src/com/gitblit/utils/FileUtils.java
index c291da6..0b8aeb4 100644
--- a/src/com/gitblit/utils/FileUtils.java
+++ b/src/com/gitblit/utils/FileUtils.java
@@ -99,6 +99,25 @@
 		}
 		return defaultValue;
 	}
+	
+	/**
+	 * Returns the byte [] content of the specified file.
+	 * 
+	 * @param file
+	 * @return the byte content of the file
+	 */
+	public static byte [] readContent(File file) {
+		byte [] buffer = new byte[(int) file.length()];
+		try {
+			BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
+			is.read(buffer,  0,  buffer.length);
+			is.close();
+		} catch (Throwable t) {
+			System.err.println("Failed to read byte content of " + file.getAbsolutePath());
+			t.printStackTrace();
+		}
+		return buffer;
+	}
 
 	/**
 	 * Returns the string content of the specified file.
@@ -226,7 +245,10 @@
 	public static String getRelativePath(File basePath, File path) {
 		File exactBase = getExactFile(basePath);
 		File exactPath = getExactFile(path);
-		if (exactPath.getPath().startsWith(exactBase.getPath())) {
+		if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {
+			// absolute base-path match
+			return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());
+		} else if (exactPath.getPath().startsWith(exactBase.getPath())) {
 			// canonical base-path match
 			return StringUtils.getRelativePath(exactBase.getPath(), exactPath.getPath());
 		} else if (exactPath.getPath().startsWith(basePath.getAbsolutePath())) {
@@ -235,9 +257,6 @@
 		} else if (path.getAbsolutePath().startsWith(exactBase.getPath())) {
 			// mixed path match
 			return StringUtils.getRelativePath(exactBase.getPath(), path.getAbsolutePath());
-		} else if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {
-			// absolute base-path match
-			return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());
 		}
 		// no relative relationship
 		return null;

--
Gitblit v1.9.1