package test; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import javax.annotation.Nonnull; /** * * * Do Stuff * * @author jbrown */ public class Link { /** * @param args the command line arguments * p4javassl://host:port * client * user * */ public static void main(String[] args) { boolean goodSyntax = true; if (args.length < 2) { goodSyntax = false; } if (!goodSyntax) { printSyntax(); System.exit(1); } Link obj = new Link(); try { obj.doCreateLink(args); } catch (Throwable ex) { ex.printStackTrace(System.out); } } public static void printSyntax() { System.out.println("test.Link src-file link-name"); } /* perform the sync * */ private void doCreateLink(String[] args) throws Throwable { String target = args[0]; String link = args[1]; System.out.println("target: " + target); System.out.println("link: " + link); Path linkPath = Paths.get(link); Path targetPath = Paths.get(target); createParentDirsIfNotExist(linkPath); Path pathObject = Files.createSymbolicLink(linkPath, targetPath); System.out.println("Link Created: " + pathObject.toString()); } private static void createParentDirsIfNotExist(@Nonnull final Path filePath) throws IOException { Path parent = filePath.getParent(); if (parent != null && Files.notExists(parent)) { Files.createDirectories(parent); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 28709 | Joel Brown |
Allow setting character encoding (charset) with syncs with the Java System Property -Dcharset=<value> |
||
#1 | 25636 | Joel Brown | Simple P4Java methods to sync and reconcile. |