From 1bc83891c68ee269727e81a13cc70da698bcc7a7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 2 Jun 2015 19:53:31 +0200 Subject: [server] Compiling again, still lots of stubs --- .../src/main/java/util/FileSystem.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dozentenmodulserver/src/main/java/util/FileSystem.java (limited to 'dozentenmodulserver/src/main/java/util/FileSystem.java') diff --git a/dozentenmodulserver/src/main/java/util/FileSystem.java b/dozentenmodulserver/src/main/java/util/FileSystem.java new file mode 100644 index 00000000..5f5a1e08 --- /dev/null +++ b/dozentenmodulserver/src/main/java/util/FileSystem.java @@ -0,0 +1,25 @@ +package util; + +import java.io.File; + +import org.apache.log4j.Logger; + +public class FileSystem { + + private static final Logger LOGGER = Logger.getLogger(FileSystem.class); + + public static String getRelativePath(File absolutePath, File parentDir) { + String file; + String dir; + try { + file = absolutePath.getCanonicalPath(); + dir = parentDir.getCanonicalPath() + File.separator; + } catch (Exception e) { + LOGGER.error("Could not get relative path for " + absolutePath.toString(), e); + return null; + } + if (!file.startsWith(dir)) + return null; + return file.substring(dir.length()); + } +} -- cgit v1.2.3-55-g7522