@@ -224,7 +224,7 @@ public MediaEditorGUI(String file) {
224224
225225 // Main frame
226226 frame = new JFrame ("Emrick Designer" );
227- Image icon = Toolkit .getDefaultToolkit ().getImage (PathConverter .pathConverter ("src/main/resources/ images/icon.png" ));
227+ Image icon = Toolkit .getDefaultToolkit ().getImage (PathConverter .pathConverter ("res/ images/icon.png" , true ));
228228 frame .setIconImage (icon );
229229
230230 // Scrub Bar
@@ -236,9 +236,13 @@ public MediaEditorGUI(String file) {
236236
237237 currentID = MAX_CONNECTIONS ;
238238
239+ // Make sure user dir exists
240+ File userDir = new File (PathConverter .pathConverter ("" , false ));
241+ userDir .mkdirs ();
242+
239243
240244 // Delete leftover files from show_data/
241- File showDataDir = new File (PathConverter .pathConverter ("show_data/" ));
245+ File showDataDir = new File (PathConverter .pathConverter ("show_data/" , false ));
242246 if (showDataDir .exists ()) {
243247 showDataDir .mkdirs ();
244248 if (showDataDir .isDirectory ()) {
@@ -672,7 +676,7 @@ public void createAndShowGUI() {
672676 stopWebServer .setEnabled (false );
673677 runWebServer .setEnabled (true );
674678
675- File dir = new File (PathConverter .pathConverter ("tmp/" ));
679+ File dir = new File (PathConverter .pathConverter ("tmp/" , false ));
676680 File [] files = dir .listFiles ();
677681 for (File f : files ) {
678682 f .delete ();
@@ -803,7 +807,7 @@ public void windowClosing(WindowEvent e) {
803807 requestIDs = null ;
804808 runWebServer .setEnabled (true );
805809 stopWebServer .setEnabled (false );
806- File dir = new File (PathConverter .pathConverter ("tmp/" ));
810+ File dir = new File (PathConverter .pathConverter ("tmp/" , false ));
807811 File [] files = dir .listFiles ();
808812 for (File f : files ) {
809813 f .delete ();
@@ -831,7 +835,7 @@ public void windowClosing(WindowEvent e) {
831835 }
832836 }
833837 }
834- File showDataDir = new File (PathConverter .pathConverter ("show_data/" ));
838+ File showDataDir = new File (PathConverter .pathConverter ("show_data/" , false ));
835839 showDataDir .mkdirs ();
836840 File [] cleanFiles = showDataDir .listFiles ();
837841 for (File f : cleanFiles ) {
@@ -931,7 +935,7 @@ public SerialTransmitter comPortPrompt() {
931935 }
932936 String port = (String ) JOptionPane .showInputDialog (null , "Choose" ,
933937 "Menu" , JOptionPane .INFORMATION_MESSAGE ,
934- new ImageIcon (PathConverter .pathConverter ("icon.ico" )),
938+ new ImageIcon (PathConverter .pathConverter ("icon.ico" , true )),
935939 allPortNames , allPortNames [0 ]);
936940 st .setSerialPort (port );
937941 return st ;
@@ -958,7 +962,7 @@ public void runServer(String path) {
958962 }
959963 else { //there is a project open
960964 if (path .equals ("" )) {
961- f = new File ("tempPkt.pkt" );
965+ f = new File (PathConverter . pathConverter ( "tempPkt.pkt" , false ) );
962966 exportPackets (f );
963967 } else {
964968 f = new File (path );
@@ -983,13 +987,13 @@ public void runServer(String path) {
983987
984988 serialTransmitter = comPortPrompt ();
985989
986- Unzip .unzip (f .getAbsolutePath (), PathConverter .pathConverter ("tmp/" ));
990+ Unzip .unzip (f .getAbsolutePath (), PathConverter .pathConverter ("tmp/" , false ));
987991
988992 server = HttpServer .create (new InetSocketAddress (port ), 250 );
989993 writeSysMsg ("server started at " + port );
990994 requestIDs = new ArrayList <>();
991995
992- server .createContext ("/" , new GetHandler (PathConverter .pathConverter ("tmp/" ), this ));
996+ server .createContext ("/" , new GetHandler (PathConverter .pathConverter ("tmp/" , false ), this ));
993997 server .setExecutor (new ServerExecutor ());
994998 server .start ();
995999 currentID = Math .min (MAX_CONNECTIONS , footballFieldPanel .drill .ledStrips .size ());
@@ -1019,7 +1023,7 @@ public void loadProject(File path) {
10191023 try {
10201024 // TODO: pdf loading is redundant with project file. fix? - LHD
10211025
1022- File showDataDir = new File (PathConverter .pathConverter ("show_data/" ));
1026+ File showDataDir = new File (PathConverter .pathConverter ("show_data/" , false ));
10231027 showDataDir .mkdirs ();
10241028 File [] cleanFiles = showDataDir .listFiles ();
10251029 for (File f : cleanFiles ) {
@@ -1029,7 +1033,7 @@ public void loadProject(File path) {
10291033 f .delete ();
10301034 }
10311035 }
1032- Unzip .unzip (path .getAbsolutePath (), PathConverter .pathConverter ("show_data/" ));
1036+ Unzip .unzip (path .getAbsolutePath (), PathConverter .pathConverter ("show_data/" , false ));
10331037 File [] dataFiles = showDataDir .listFiles ();
10341038 for (File f : dataFiles ) {
10351039 if (!f .isDirectory ()) {
@@ -1045,7 +1049,7 @@ public void loadProject(File path) {
10451049 r .close ();
10461050 ImportArchive ia = new ImportArchive (this );
10471051
1048- archivePath = new File (PathConverter .pathConverter ("show_data/" + pf .archivePath ));
1052+ archivePath = new File (PathConverter .pathConverter ("show_data/" + pf .archivePath , false ));
10491053
10501054 ia .fullImport (archivePath .getAbsolutePath (), null );
10511055 footballFieldPanel .drill = pf .drill ;
@@ -1943,7 +1947,7 @@ public void saveProject(File path, File archivePath) {
19431947
19441948 String jsonName = path .getName ();
19451949 jsonName = jsonName .substring (0 , jsonName .indexOf (".emrick" )) + ".json" ;
1946- File dir = new File (PathConverter .pathConverter ("show_data/" ));
1950+ File dir = new File (PathConverter .pathConverter ("show_data/" , false ));
19471951 dir .mkdirs ();
19481952 File [] cleanJson = dir .listFiles ();
19491953 for (File f : cleanJson ) {
@@ -1953,15 +1957,15 @@ public void saveProject(File path, File archivePath) {
19531957 }
19541958
19551959 try {
1956- FileWriter w = new FileWriter (PathConverter .pathConverter ("show_data/" + jsonName ));
1960+ FileWriter w = new FileWriter (PathConverter .pathConverter ("show_data/" + jsonName , false ));
19571961 w .write (g );
19581962 w .close ();
19591963 } catch (IOException e ) {
19601964 writeSysMsg ("Failed to save to `" + path + "`." );
19611965 throw new RuntimeException (e );
19621966 }
19631967
1964- File showDataDir = new File (PathConverter .pathConverter ("show_data/" ));
1968+ File showDataDir = new File (PathConverter .pathConverter ("show_data/" , false ));
19651969 showDataDir .mkdirs ();
19661970 File [] saveFiles = showDataDir .listFiles ();
19671971 ArrayList <String > files = new ArrayList <>();
@@ -2060,7 +2064,7 @@ public void exportPackets(File path) {
20602064 timesMS = timeMS .toArray (timesMS );
20612065 try {
20622066 String out = "" ;
2063- File dir = new File (PathConverter .pathConverter ("tmp/" ));
2067+ File dir = new File (PathConverter .pathConverter ("tmp/" , false ));
20642068 dir .mkdirs ();
20652069 ArrayList <String > files = new ArrayList <>();
20662070 ArrayList <LEDStrip > list0 = new ArrayList <>();
@@ -2073,7 +2077,7 @@ public void exportPackets(File path) {
20732077 ArrayList <LEDStrip > list7 = new ArrayList <>();
20742078 for (int k = 0 ; k < footballFieldPanel .drill .ledStrips .size (); k ++) {
20752079 LEDStrip l = footballFieldPanel .drill .ledStrips .get (k );
2076- File curr = new File (PathConverter .pathConverter ("tmp/" + l .getId ()));
2080+ File curr = new File (PathConverter .pathConverter ("tmp/" + l .getId (), false ));
20772081 curr .createNewFile ();
20782082 files .add (curr .getAbsolutePath ());
20792083
@@ -2269,7 +2273,7 @@ public void run() {
22692273 int a = 0 ;
22702274 for (LEDStrip l : ledStrips ) {
22712275 a ++;
2272- File curr = new File (PathConverter .pathConverter ("tmp/" + l .getId ()));
2276+ File curr = new File (PathConverter .pathConverter ("tmp/" + l .getId (), false ));
22732277
22742278 BufferedWriter bfw = new BufferedWriter (new FileWriter (curr ));
22752279
0 commit comments