File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change 11package com .espressif .idf .core .tools ;
22
3+ import java .io .File ;
34import java .io .FileReader ;
45import java .io .IOException ;
56
67import org .eclipse .core .runtime .Platform ;
78
9+ import com .espressif .idf .core .logging .Logger ;
810import com .espressif .idf .core .tools .vo .EimJson ;
911import com .google .gson .Gson ;
1012import com .google .gson .GsonBuilder ;
@@ -13,35 +15,43 @@ public class EimIdfConfiguratinParser
1315{
1416 private EimJson eimJson ;
1517 private Gson gson ;
16-
18+
1719 public EimIdfConfiguratinParser ()
1820 {
1921 gson = new GsonBuilder ().setPrettyPrinting ().enableComplexMapKeySerialization ()
2022 .excludeFieldsWithoutExposeAnnotation ().create ();
2123 }
22-
24+
2325 private void load () throws IOException
2426 {
25- try (FileReader fileReader = new FileReader (
26- Platform .getOS ().equals (Platform .OS_WIN32 ) ? EimConstants .EIM_WIN_PATH : EimConstants .EIM_POSIX_PATH ))
27+ String path = Platform .getOS ().equals (Platform .OS_WIN32 ) ? EimConstants .EIM_WIN_PATH
28+ : EimConstants .EIM_POSIX_PATH ;
29+
30+ File file = new File (path );
31+ if (!file .exists ())
32+ {
33+ Logger .log ("EIM config file not found: " + path ); //$NON-NLS-1$
34+ return ;
35+ }
36+
37+ try (FileReader fileReader = new FileReader (file ))
2738 {
2839 eimJson = gson .fromJson (fileReader , EimJson .class );
2940 }
3041 }
3142
32-
3343 public EimJson getEimJson (boolean reload ) throws IOException
3444 {
3545 if (reload )
3646 {
3747 load ();
3848 }
39-
49+
4050 if (eimJson == null )
4151 {
4252 load ();
4353 }
44-
54+
4555 return eimJson ;
4656 }
4757}
You can’t perform that action at this time.
0 commit comments