@@ -37,8 +37,8 @@ public static String getTextFromFilePath(String path) {
37
37
}
38
38
39
39
private static String getCurrentPath (String module ) {
40
- String path = new File ("." ). getAbsolutePath (). replace ( "." , "" ). replace ( module + File . separator , "" );
41
- return path ;
40
+ File mod = new File (module );
41
+ return mod . exists () && mod . isDirectory () ? mod . getAbsolutePath () + File . separator : null ;
42
42
}
43
43
44
44
public static String getString (BufferedReader br ) {
@@ -60,15 +60,19 @@ public static String getString(BufferedReader br) {
60
60
// detect multiple sourceSet res.srcDirs
61
61
public static void backupStringResources (String module , Config config , boolean debug ) {
62
62
String path = getCurrentPath (module );
63
+ if (path == null ) {
64
+ PrintUtils .print (module , "module " + module + " not found" , true );
65
+ return ;
66
+ }
63
67
for (String folder : config .getSrcFolders ()) {
64
- String currentPath = path + module + File .separator + folder + File .separator + "res" + File .separator ;
68
+ String currentPath = path + folder + File .separator + "res" + File .separator ;
69
+
65
70
File file = new File (currentPath );
66
71
String [] directories = file .list ((current , name ) -> new File (current , name ).isDirectory ());
67
72
if (directories != null ) {
68
73
for (String dir : directories ) {
69
74
String pathToCopy = currentPath + dir + File .separator ;
70
- String pathToCheck = getCurrentPath (module ) + module + File .separator + "resbackup" + File .separator + dir + File .separator ;
71
-
75
+ String pathToCheck = getCurrentPath (module ) + "resbackup" + File .separator + dir + File .separator ;
72
76
for (String sFile : config .getStringFiles ()) {
73
77
try {
74
78
File toCopy = new File (pathToCopy + sFile );
@@ -94,14 +98,19 @@ public static void backupStringResources(String module, Config config, boolean d
94
98
PrintUtils .print (module , "source folder not found: " + currentPath , true );
95
99
} else {
96
100
PrintUtils .print (module , "source folder not found: " + folder , true );
97
- } }
101
+ }
102
+ }
98
103
}
99
104
}
100
105
101
106
public static void encryptStringResources (String module , Config config , String key , boolean debug ) {
102
107
String path = getCurrentPath (module );
108
+ if (path == null ) {
109
+ PrintUtils .print (module , "module " + module + " not found" , true );
110
+ return ;
111
+ }
103
112
for (String folder : config .getSrcFolders ()) {
104
- String currentPath = path + module + File . separator + folder + File .separator + "res" + File .separator ;
113
+ String currentPath = path + folder + File .separator + "res" + File .separator ;
105
114
File file = new File (currentPath );
106
115
String [] directories = file .list ((current , name ) -> new File (current , name ).isDirectory ());
107
116
if (directories != null ) {
@@ -132,15 +141,19 @@ public static void encryptStringResources(String module, Config config, String k
132
141
}
133
142
134
143
public static void restoreStringResources (String module , Config config , boolean debug ) {
135
- String currentPath = getCurrentPath (module ) + module + File .separator + "resbackup" + File .separator ;
144
+ if (getCurrentPath (module ) == null ) {
145
+ PrintUtils .print (module , "module " + module + " not found" , true );
146
+ return ;
147
+ }
148
+ String currentPath = getCurrentPath (module ) + "resbackup" + File .separator ;
136
149
File file = new File (currentPath );
137
150
String [] directories = file .list ((current , name ) -> new File (current , name ).isDirectory ());
138
151
if (directories != null ) {
139
152
File toRestore ;
140
153
for (String dir : directories ) {
141
154
String pathToRestore = currentPath + dir + File .separator ;
142
155
for (String folder : config .getSrcFolders ()) {
143
- String pathRes = getCurrentPath (module ) + module + File . separator + folder + File .separator + "res" + File .separator + dir + File .separator ;
156
+ String pathRes = getCurrentPath (module ) + folder + File .separator + "res" + File .separator + dir + File .separator ;
144
157
145
158
for (String sFile : config .getStringFiles ()) {
146
159
toRestore = new File (pathToRestore + sFile );
0 commit comments