Skip to content

Commit

Permalink
Merge pull request #11 from afffsdd/master
Browse files Browse the repository at this point in the history
Hide settings dotfolder on Windows if not hidden. (#10)
  • Loading branch information
Konloch committed Dec 20, 2014
2 parents 4e6647b + 36960da commit 058e32d
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
Expand Down Expand Up @@ -511,12 +507,33 @@ public static void cleanup() {
public static String getBCVDirectory() {
File f = new File(System.getProperty("user.home") + fs
+ ".Bytecode-Viewer");
while (!f.exists())
while (!f.exists()) {
System.out.println("it doesn't exist."); // debug
f.mkdirs();
}
System.out.println("it exists now."); // debug
if (!f.isHidden() && isWindows())
hideFile(f);

return f.getAbsolutePath();
}

private static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("win");
}

private static void hideFile(File f) {
System.out.println("hiding file");
try {
// Hide file by running attrib system command (on Windows)
Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath());
} catch (IOException e) {
System.out.println("Could not hide settings folder (~/.Bytecode-Viewer) using attrib!");
System.out.println(e.getMessage());
e.printStackTrace();
}
}

private static String quickConvert(ArrayList<String> a) {
String s = "";
for (String r : a)
Expand Down

0 comments on commit 058e32d

Please sign in to comment.