[Schmitzm-commits] r1328 - in trunk: src/skrueger src/skrueger/linux src_junit/skrueger src_junit/skrueger/linux

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Dec 5 20:34:11 CET 2010


Author: alfonx
Date: 2010-12-05 20:34:11 +0100 (Sun, 05 Dec 2010)
New Revision: 1328

Added:
   trunk/src/skrueger/linux/
   trunk/src/skrueger/linux/LinuxUtil.java
   trunk/src_junit/skrueger/linux/
   trunk/src_junit/skrueger/linux/LinuxUtilTest.java
Log:


Added: trunk/src/skrueger/linux/LinuxUtil.java
===================================================================
--- trunk/src/skrueger/linux/LinuxUtil.java	2010-12-05 17:23:22 UTC (rev 1327)
+++ trunk/src/skrueger/linux/LinuxUtil.java	2010-12-05 19:34:11 UTC (rev 1328)
@@ -0,0 +1,31 @@
+package skrueger.linux;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Utility methods to do linux specific stuff, e.g. symbolic links
+ */
+public class LinuxUtil {
+
+	/**
+	 * Creates a symbolic link
+	 * 
+	 * @param from
+	 *            an existing {@link File}
+	 * @param to
+	 *            the new file to create
+	 * @throws IOException
+	 */
+	public static void createSymlink(File from, File to) throws IOException {
+		ProcessBuilder processBuilder = new ProcessBuilder("/bin/ln", "-s",
+				from.getAbsolutePath(), to.getAbsolutePath());
+		Process started = processBuilder.start();
+		try {
+			started.waitFor();
+		} catch (InterruptedException e) {
+			new RuntimeException(e);
+		}
+	}
+
+}


Property changes on: trunk/src/skrueger/linux/LinuxUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Added: trunk/src_junit/skrueger/linux/LinuxUtilTest.java
===================================================================
--- trunk/src_junit/skrueger/linux/LinuxUtilTest.java	2010-12-05 17:23:22 UTC (rev 1327)
+++ trunk/src_junit/skrueger/linux/LinuxUtilTest.java	2010-12-05 19:34:11 UTC (rev 1328)
@@ -0,0 +1,36 @@
+package skrueger.linux;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import schmitzm.swing.TestingUtil;
+
+public class LinuxUtilTest {
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void testCreateSymlink() throws IOException, InterruptedException {
+		File from = TestingUtil.getNewTempDir();
+		File to = new File(TestingUtil.getNewTempDir(), "link");
+		assertFalse(to.exists());
+
+		LinuxUtil.createSymlink(from, to);
+		assertTrue(to.exists());
+
+	}
+
+}


Property changes on: trunk/src_junit/skrueger/linux/LinuxUtilTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list