Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: jamessanders/JSync
base: 20f2166118
...
head fork: jamessanders/JSync
compare: bebcbf4b56
  • 3 commits
  • 16 files changed
  • 0 commit comments
  • 1 contributor
1  build-exe.bat
View
@@ -0,0 +1 @@
+"C:\Program Files (x86)\JSmooth 0.9.9-7\jsmoothcmd.exe" jsync.jsmooth
2  build-windows.sh
View
@@ -0,0 +1,2 @@
+#!/bin/sh
+mvn install -Dversion=`cat VERSION` && (cd java; mvn assembly:single -Dversion=`cat ../VERSION`) && cp java/target/JSync-`cat VERSION`-jar-with-dependencies.jar java/target/JSync-jar-with-dependencies.jar && echo "DONE, NOW BUILD THE EXE WITH JSMOOTH USING jsync.jsmooth"
0  config.guess 100755 → 100644
View
File mode changed
0  config.sub 100755 → 100644
View
File mode changed
0  configure 100755 → 100644
View
File mode changed
0  depcomp 100755 → 100644
View
File mode changed
0  install-sh 100755 → 100644
View
File mode changed
6 java/pom.xml
View
@@ -18,6 +18,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
8 java/src/main/java/com/jsync/FsResourceUnix.java
View
@@ -0,0 +1,8 @@
+package com.jsync;
+
+/**
+ * User: sanders
+ * Date: 9/23/12
+ */
+public class FsResourceUnix {
+}
104 java/src/main/java/com/jsync/FsResourceWindows.java
View
@@ -0,0 +1,104 @@
+package com.jsync;
+
+import java.io.File;
+import java.util.ArrayList;
+
+/**
+ * User: sanders
+ * Date: 9/23/12
+ */
+public class FsResourceWindows extends FsResource {
+
+ public FsResourceWindows(File file) {
+ super(file);
+ }
+ public FsResourceWindows(String fn) {
+ super(new File(fn));
+ }
+
+ @Override
+ public IResource[] list() {
+ if (file.isDirectory()) {
+ String[] files = file.list();
+ if (files == null) {
+ return new FsResourceWindows[0];
+ } else {
+ ArrayList<FsResourceWindows> resultList;
+ resultList = new ArrayList<FsResourceWindows>();
+ for (String child: files) {
+ File resource = new File(file, child);
+ resultList.add(new FsResourceWindows(resource));
+ }
+ FsResourceWindows[] out = new FsResourceWindows[resultList.size()];
+ return resultList.toArray(out);
+ }
+ } else if (file.isFile()) {
+ return new FsResourceWindows[0];
+ }
+ return null;
+ }
+
+ @Override
+ public FsResource join(String name) {
+ return new FsResourceWindows(new File(file, name));
+ }
+
+ @Override
+ public boolean isSymlink() {
+ return false;
+ }
+
+ @Override
+ public int getMode() {
+ return -1;
+ }
+
+ @Override
+ public void setGid(int gid) {
+ }
+
+ @Override
+ public int getGid() {
+ return -1;
+ }
+
+ @Override
+ public void setUid(int uid) {
+ }
+
+ @Override
+ public int getUid() {
+ return -1;
+ }
+
+ @Override
+ public void setMode(int mode) {
+ }
+
+ @Override
+ public void createSymlink(String target) {
+ }
+
+ @Override
+ public long getAccessTime() {
+ return -1;
+ }
+
+ @Override
+ public void setAccessTime(long accessTime) {
+ }
+
+ @Override
+ public long getModifiedTime() {
+ return super.lastModified();
+ }
+
+ @Override
+ public void setModifiedTime(long modifiedTime) {
+ }
+
+ @Override
+ public String getSymlinkTarget() {
+ return null;
+ }
+}
31 java/src/main/java/com/jsync/JSync.java
View
@@ -4,21 +4,40 @@
public class JSync {
static {
- System.setProperty("jna.library.path", System.getenv("LIBJSYNC_PATH"));
+ if (System.getenv("LIBJSYNC_PATH") != null) {
+ System.setProperty("jna.library.path", System.getenv("LIBJSYNC_PATH"));
+ }
+ }
+ public static void exitWithHelp(JSyncOptions options, int code) {
+ System.err.println("");
+ System.err.println("Usage: jsync [options] <input_path> <output_path>");
+ System.err.println("");
+ System.err.println("Options: ");
+ options.showHelp();
+ System.exit(code);
}
+
public static void main(String[] args) throws IOException {
JSyncOptions options = new JSyncOptions(args);
- System.out.println(" + Generating Resources");
+ if (options.needsHelp()) {
+ exitWithHelp(options, 0);
+ }
+
ResourceGenerator generator =
new ResourceGenerator(options);
- System.out.println(" + Starting Copy");
-
- IResource in = generator.getInputResource();
- IResource out = generator.getOutputResource();
+ IResource in = null;
+ IResource out = null;
+ try {
+ in = generator.getInputResource();
+ out = generator.getOutputResource();
+ } catch (IndexOutOfBoundsException e) {
+ System.err.println("No input or output directory specified");
+ exitWithHelp(options, 1);
+ }
IResource back = generator.getBackupResource();
ResourceCopier.copyDirectory(in, out, back);
33 java/src/main/java/com/jsync/JSyncOptions.java
View
@@ -10,24 +10,39 @@
public class JSyncOptions {
+ OptionParser parser;
OptionSet options;
List<String> arguments;
public JSyncOptions(String[] args) {
- OptionParser parser = new OptionParser();
-
- parser.accepts("aws").withRequiredArg();
- parser.accepts("delete");
- parser.accepts("reduced-redundancy");
- parser.accepts("rr-storage");
- parser.accepts("verbose");
- parser.accepts("backup").withRequiredArg();
-
+ parser = new OptionParser() {
+ {
+ accepts("aws", "aws credentials (seperated by ':')").withRequiredArg().describedAs( "credentials" );
+ accepts("delete", "delete files at destination that do not exists in the source dir");
+ accepts("reduced-redundancy", "use reduced redundancy when uploading files to S3");
+ accepts("rr-storage", "same as --reduced-redundancy");
+ accepts("verbose", "be verbose");
+ accepts("help", "show this help");
+ accepts("backup", "backup any modified or deleted files" ).withRequiredArg().describedAs("path");
+ }
+ };
options = parser.parse(args);
arguments = options.nonOptionArguments();
}
+ public void showHelp() {
+ try {
+ parser.printHelpOn(System.err);
+ } catch (IOException e) {
+
+ }
+ }
+
+ public boolean needsHelp() {
+ return options.has("help");
+ }
+
public boolean doDelete() {
return options.has("delete");
}
17 java/src/main/java/com/jsync/ResourceCopier.java
View
@@ -19,12 +19,19 @@ public static void copy(IResource in, IResource out) throws IOException {
out.mkdirs();
- out.setUid(in.getUid());
- out.setGid(in.getGid());
- out.setMode(in.getMode());
- out.setAccessTime(in.getAccessTime());
- out.setModifiedTime(in.getModifiedTime());
+ int uid = in.getUid();
+ int gid = in.getGid();
+ int mode = in.getMode();
+ long atime = in.getAccessTime();
+ long mtime = in.getModifiedTime();
+
+ if (uid != -1) out.setUid(uid);
+ if (gid != -1) out.setGid(gid);
+ if (mode != -1) out.setMode(mode);
+ if (atime != -1) out.setAccessTime(atime);
+ if (mtime != -1) out.setModifiedTime(mtime);
+
out.setMimeType(in.getMimeType());
out.setSize(in.getSize());
9 java/src/main/java/com/jsync/ResourceGenerator.java
View
@@ -1,7 +1,7 @@
package com.jsync;
import com.amazonaws.auth.AWSCredentials;
-
+import org.apache.commons.lang3.SystemUtils;
import java.net.URI;
import java.net.URISyntaxException;
@@ -40,8 +40,11 @@ public IResource generateResource(String path) {
try {
uri = new URI(path);
} catch (URISyntaxException e) {
- System.out.println("Cannot parse URI");
- return new FsResource(path);
+ if (SystemUtils.IS_OS_WINDOWS) {
+ return new FsResourceWindows(path);
+ } else {
+ return new FsResource(path);
+ }
}
String scheme = uri.getScheme();
if (scheme == null || scheme.equals("file")) {
32 jsync.jsmooth
View
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<jsmoothproject>
+<JVMSearchPath>registry</JVMSearchPath>
+<JVMSearchPath>javahome</JVMSearchPath>
+<JVMSearchPath>jrepath</JVMSearchPath>
+<JVMSearchPath>jdkpath</JVMSearchPath>
+<JVMSearchPath>exepath</JVMSearchPath>
+<JVMSearchPath>jview</JVMSearchPath>
+<currentDirectory>${EXECUTABLEPATH}</currentDirectory>
+<embeddedJar>true</embeddedJar>
+<executableName>jsync.exe</executableName>
+<initialMemoryHeap>-1</initialMemoryHeap>
+<jarLocation>java\target\JSync-jar-with-dependencies.jar</jarLocation>
+<mainClassName>com.jsync.JSync</mainClassName>
+<maximumMemoryHeap>-1</maximumMemoryHeap>
+<maximumVersion></maximumVersion>
+<minimumVersion>1.6</minimumVersion>
+<skeletonName>Console Wrapper</skeletonName>
+<skeletonProperties>
+<key>Message</key>
+<value>This program needs Java to run.
+Please download it at http://www.java.com</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>PressKey</key>
+<value>0</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>Debug</key>
+<value>0</value>
+</skeletonProperties>
+</jsmoothproject>
0  missing 100755 → 100644
View
File mode changed

No commit comments for this range

Something went wrong with that request. Please try again.