diff options
| author | Simon Rettberg | 2015-06-02 19:53:31 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-06-02 19:53:31 +0200 |
| commit | 1bc83891c68ee269727e81a13cc70da698bcc7a7 (patch) | |
| tree | b052a72ad7d65864068752f71c5ed2b49a171276 /dozentenmodulserver/src/main/java/util/FileSystem.java | |
| parent | [server] Started work on the internal file server (diff) | |
| download | tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.tar.gz tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.tar.xz tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.zip | |
[server] Compiling again, still lots of stubs
Diffstat (limited to 'dozentenmodulserver/src/main/java/util/FileSystem.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/util/FileSystem.java | 25 |
1 files changed, 25 insertions, 0 deletions
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()); + } +} |
