|
3 | 3 | import java.awt.event.ActionEvent;
|
4 | 4 | import java.awt.event.ActionListener;
|
5 | 5 | import java.awt.image.BufferedImage;
|
6 |
| -import java.io.BufferedReader; |
7 |
| -import java.io.ByteArrayInputStream; |
8 |
| -import java.io.File; |
9 |
| -import java.io.FileInputStream; |
10 |
| -import java.io.InputStreamReader; |
| 6 | +import java.io.*; |
11 | 7 | import java.net.HttpURLConnection;
|
12 | 8 | import java.net.URL;
|
13 | 9 | import java.util.ArrayList;
|
@@ -511,12 +507,33 @@ public static void cleanup() {
|
511 | 507 | public static String getBCVDirectory() {
|
512 | 508 | File f = new File(System.getProperty("user.home") + fs
|
513 | 509 | + ".Bytecode-Viewer");
|
514 |
| - while (!f.exists()) |
| 510 | + while (!f.exists()) { |
| 511 | + System.out.println("it doesn't exist."); // debug |
515 | 512 | f.mkdirs();
|
| 513 | + } |
| 514 | + System.out.println("it exists now."); // debug |
| 515 | + if (!f.isHidden() && isWindows()) |
| 516 | + hideFile(f); |
516 | 517 |
|
517 | 518 | return f.getAbsolutePath();
|
518 | 519 | }
|
519 | 520 |
|
| 521 | + private static boolean isWindows() { |
| 522 | + return System.getProperty("os.name").toLowerCase().contains("win"); |
| 523 | + } |
| 524 | + |
| 525 | + private static void hideFile(File f) { |
| 526 | + System.out.println("hiding file"); |
| 527 | + try { |
| 528 | + // Hide file by running attrib system command (on Windows) |
| 529 | + Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath()); |
| 530 | + } catch (IOException e) { |
| 531 | + System.out.println("Could not hide settings folder (~/.Bytecode-Viewer) using attrib!"); |
| 532 | + System.out.println(e.getMessage()); |
| 533 | + e.printStackTrace(); |
| 534 | + } |
| 535 | + } |
| 536 | + |
520 | 537 | private static String quickConvert(ArrayList<String> a) {
|
521 | 538 | String s = "";
|
522 | 539 | for (String r : a)
|
|
0 commit comments