@@ -58,10 +58,10 @@ public static String getString(BufferedReader br) {
58
58
}
59
59
60
60
// detect multiple sourceSet res.srcDirs
61
- public static void backupStringResources (String module , Config config ) {
62
- String currentPath = getCurrentPath (module );
61
+ public static void backupStringResources (String module , Config config , boolean debug ) {
62
+ String path = getCurrentPath (module );
63
63
for (String folder : config .getSrcFolders ()) {
64
- currentPath += module + File .separator + folder + File .separator + "res" + File .separator ;
64
+ String currentPath = path + module + File .separator + folder + File .separator + "res" + File .separator ;
65
65
File file = new File (currentPath );
66
66
String [] directories = file .list ((current , name ) -> new File (current , name ).isDirectory ());
67
67
if (directories != null ) {
@@ -77,8 +77,11 @@ public static void backupStringResources(String module, Config config) {
77
77
toCheck .delete ();
78
78
}
79
79
if (toCopy .exists ()) {
80
- PrintUtils .print ("- " + toCopy .getParentFile ().getName () + File .separator + toCopy .getName (), true );
80
+ PrintUtils .print (module , "- " + toCopy .getParentFile ().getName () + File .separator + toCopy .getName (), true );
81
81
copyFile (toCopy , toCheck );
82
+ if (debug ) {
83
+ PrintUtils .print (module , "backuping file: " + toCopy .getPath (), true );
84
+ }
82
85
}
83
86
} catch (IOException e ) {
84
87
e .printStackTrace ();
@@ -87,15 +90,18 @@ public static void backupStringResources(String module, Config config) {
87
90
}
88
91
}
89
92
} else {
90
- PrintUtils .print (module , "source folder not found: " + folder , true );
91
- }
93
+ if (debug ) {
94
+ PrintUtils .print (module , "source folder not found: " + currentPath , true );
95
+ } else {
96
+ PrintUtils .print (module , "source folder not found: " + folder , true );
97
+ } }
92
98
}
93
99
}
94
100
95
- public static void encryptStringResources (String module , Config config , String key ) {
96
- String currentPath = getCurrentPath (module );
101
+ public static void encryptStringResources (String module , Config config , String key , boolean debug ) {
102
+ String path = getCurrentPath (module );
97
103
for (String folder : config .getSrcFolders ()) {
98
- currentPath += module + File .separator + folder + File .separator + "res" + File .separator ;
104
+ String currentPath = path + module + File .separator + folder + File .separator + "res" + File .separator ;
99
105
File file = new File (currentPath );
100
106
String [] directories = file .list ((current , name ) -> new File (current , name ).isDirectory ());
101
107
if (directories != null ) {
@@ -104,19 +110,28 @@ public static void encryptStringResources(String module, Config config, String k
104
110
for (String sFile : config .getStringFiles ()) {
105
111
File toEncrypt = new File (pathToEncrypt + sFile );
106
112
if (toEncrypt .exists ()) {
107
- PrintUtils .print ("- " + toEncrypt .getParentFile ().getName () + File .separator + toEncrypt .getName (), true );
108
- String encrypted = find (getTextFromFilePath (toEncrypt .getAbsolutePath ()), key );
113
+ PrintUtils .print (module , "- " + toEncrypt .getParentFile ().getName () + File .separator + toEncrypt .getName (), true );
114
+ String encrypted = find (module , getTextFromFilePath (toEncrypt .getAbsolutePath ()), key , debug );
109
115
writeFile (toEncrypt , encrypted );
116
+ if (debug ) {
117
+ PrintUtils .print (module , "writing file: " + toEncrypt .getPath (), true );
118
+ }
119
+ } else if (debug ) {
120
+ PrintUtils .print (module , "source file not exist: " + pathToEncrypt + sFile , true );
110
121
}
111
122
}
112
123
}
113
124
} else {
114
- PrintUtils .print (module , "source folder not found: " + folder , true );
125
+ if (debug ) {
126
+ PrintUtils .print (module , "source folder not found: " + currentPath , true );
127
+ } else {
128
+ PrintUtils .print (module , "source folder not found: " + folder , true );
129
+ }
115
130
}
116
131
}
117
132
}
118
133
119
- public static void restoreStringResources (String module , Config config ) {
134
+ public static void restoreStringResources (String module , Config config , boolean debug ) {
120
135
String currentPath = getCurrentPath (module ) + module + File .separator + "resbackup" + File .separator ;
121
136
File file = new File (currentPath );
122
137
String [] directories = file .list ((current , name ) -> new File (current , name ).isDirectory ());
@@ -132,8 +147,11 @@ public static void restoreStringResources(String module, Config config) {
132
147
File toCheck = new File (pathRes + sFile );
133
148
if (toRestore .exists ()) {
134
149
try {
135
- PrintUtils .print ("- " + toCheck .getParentFile ().getName () + File .separator + toCheck .getName (), true );
150
+ PrintUtils .print (module , "- " + toCheck .getParentFile ().getName () + File .separator + toCheck .getName (), true );
136
151
copyFile (toRestore , toCheck );
152
+ if (debug ) {
153
+ PrintUtils .print (module , "restoring: " + toRestore .getPath (), true );
154
+ }
137
155
} catch (IOException e ) {
138
156
e .printStackTrace ();
139
157
}
@@ -146,9 +164,16 @@ public static void restoreStringResources(String module, Config config) {
146
164
}
147
165
if (file .isDirectory ()) {
148
166
file .delete ();
167
+ if (debug ) {
168
+ PrintUtils .print (module , "temp source folder removed: " + file .getPath (), true );
169
+ }
149
170
}
150
171
} else {
151
- PrintUtils .print (module , "restore folder not found" , true );
172
+ if (debug ) {
173
+ PrintUtils .print (module , "restore folder not found: " + currentPath , true );
174
+ } else {
175
+ PrintUtils .print (module , "restore folder not found" , true );
176
+ }
152
177
}
153
178
}
154
179
@@ -168,7 +193,7 @@ public static boolean isEncrypted(String value, String key) {
168
193
return encrypted ;
169
194
}
170
195
171
- public static String find (String xmlO , String key ) {
196
+ public static String find (String module , String xmlO , String key , boolean debug ) {
172
197
String content = xmlO ;
173
198
String toFind1 = "hidden=\" true\" " ;
174
199
@@ -198,9 +223,9 @@ public static String find(String xmlO, String key) {
198
223
199
224
toShow = toShow .length () > maxToShow ? toShow .substring (0 , maxToShow ) + ".." : toShow ;
200
225
encrypted = encrypted .length () > maxToShow ? encrypted .substring (0 , maxToShow ) + ".." : encrypted ;
201
- PrintUtils .print ("\t [" + toShow + "] - [" + encrypted + "]" + (hasExtra ? extra : "" ), true );
226
+ PrintUtils .print (module , "\t [" + toShow + "] - [" + encrypted + "]" + (hasExtra ? extra : "" ), true );
202
227
} catch (Exception e ) {
203
- PrintUtils .print ("error on " + result );
228
+ PrintUtils .print (module , "error on " + result , true );
204
229
e .printStackTrace ();
205
230
}
206
231
0 commit comments