aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/util
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net/sourceforge/jnlp/util')
-rw-r--r--netx/net/sourceforge/jnlp/util/FileUtils.java37
-rw-r--r--netx/net/sourceforge/jnlp/util/StreamUtils.java19
2 files changed, 55 insertions, 1 deletions
diff --git a/netx/net/sourceforge/jnlp/util/FileUtils.java b/netx/net/sourceforge/jnlp/util/FileUtils.java
index 80a303a..804983d 100644
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java
+++ b/netx/net/sourceforge/jnlp/util/FileUtils.java
@@ -176,6 +176,39 @@ public final class FileUtils {
}
}
+ if (JNLPRuntime.isWindows()) {
+ // remove all permissions
+ if (!tempFile.setExecutable(false, false)) {
+ System.err.println(R("RRemoveXPermFailed", tempFile));
+ }
+ if (!tempFile.setReadable(false, false)) {
+ System.err.println(R("RRemoveRPermFailed", tempFile));
+ }
+ if (!tempFile.setWritable(false, false)) {
+ System.err.println(R("RRemoveWPermFailed", tempFile));
+ }
+
+ // allow owner to read
+ if (!tempFile.setReadable(true, true)) {
+ System.err.println(R("RGetRPermFailed", tempFile));
+ }
+
+ // allow owner to write
+ if (writableByOwner && !tempFile.setWritable(true, true)) {
+ System.err.println(R("RGetWPermFailed", tempFile));
+ }
+
+ // allow owner to enter directories
+ if (isDir && !tempFile.setExecutable(true, true)) {
+ System.err.println(R("RGetXPermFailed", tempFile));
+ }
+ // rename this file. Unless the file is moved/renamed, any program that
+ // opened the file right after it was created might still be able to
+ // read the data.
+ if (!tempFile.renameTo(file)) {
+ System.err.println(R("RCantRename", tempFile, file));
+ }
+ } else {
// remove all permissions
if (!tempFile.setExecutable(false, false)) {
throw new IOException(R("RRemoveXPermFailed", tempFile));
@@ -201,13 +234,15 @@ public final class FileUtils {
if (isDir && !tempFile.setExecutable(true, true)) {
throw new IOException(R("RGetXPermFailed", tempFile));
}
-
+
// rename this file. Unless the file is moved/renamed, any program that
// opened the file right after it was created might still be able to
// read the data.
if (!tempFile.renameTo(file)) {
throw new IOException(R("RCantRename", tempFile, file));
}
+ }
+
}
diff --git a/netx/net/sourceforge/jnlp/util/StreamUtils.java b/netx/net/sourceforge/jnlp/util/StreamUtils.java
index 3a179d5..7dd7a92 100644
--- a/netx/net/sourceforge/jnlp/util/StreamUtils.java
+++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java
@@ -37,9 +37,11 @@ exception statement from your version.
package net.sourceforge.jnlp.util;
+import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
public class StreamUtils {
@@ -71,4 +73,21 @@ public class StreamUtils {
}
}
}
+
+
+ public static String readStreamAsString(InputStream stream) throws IOException {
+ InputStreamReader is = new InputStreamReader(stream);
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = new BufferedReader(is);
+ while (true) {
+ String read = br.readLine();
+ if (read == null) {
+ break;
+ }
+ sb.append(read);
+
+ }
+
+ return sb.toString();
+ }
}