Skip to content

Commit 7785fbd

Browse files
committed
remove unused options in extractFolder util function
1 parent 9f5ce68 commit 7785fbd

File tree

6 files changed

+30
-67
lines changed

6 files changed

+30
-67
lines changed

processing/mode/src/processing/mode/android/AndroidBuild.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ private File createTempBuildFolder(final Sketch sketch) throws IOException {
991991

992992
private void installGradlew(File exportFolder) throws IOException {
993993
File gradlewFile = mode.getContentFile("mode/gradlew.zip");
994-
AndroidUtil.extractFolder(gradlewFile, exportFolder, false, false);
994+
AndroidUtil.extractFolder(gradlewFile, exportFolder);
995995
if (Platform.isMacOS() || Platform.isLinux()) {
996996
File execFile = new File(exportFolder, "gradlew");
997997
execFile.setExecutable(true);

processing/mode/src/processing/mode/android/AndroidSDK.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,6 @@ private static File findCliTool(final File toolDir, String toolName)
434434
Path toolPath = Paths.get(toolFile.getAbsolutePath());
435435
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(toolPath);
436436

437-
// Print the file permissions
438-
System.out.println("File permissions for " + toolPath + ":");
439-
for (PosixFilePermission permission : permissions) {
440-
System.out.println(permission);
441-
}
442-
443437
boolean addedPerm = false;
444438
if (!permissions.contains(PosixFilePermission.OWNER_EXECUTE)) {
445439
permissions.add(PosixFilePermission.OWNER_EXECUTE);
@@ -451,6 +445,7 @@ private static File findCliTool(final File toolDir, String toolName)
451445
}
452446

453447
if (addedPerm) {
448+
// Set the missing POSIX execute (group and owner) permissions
454449
Files.setPosixFilePermissions(toolPath, permissions);
455450
}
456451
} catch (Exception e) {

processing/mode/src/processing/mode/android/AndroidUtil.java

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ static public void writeFile(final File file, String[] lines) {
110110
writer.flush();
111111
writer.close();
112112
}
113-
114-
113+
115114
static public File createPath(final File parent, final String name)
116115
throws SketchException {
117116
final File result = new File(parent, name);
@@ -120,12 +119,10 @@ static public File createPath(final File parent, final String name)
120119
}
121120
return result;
122121
}
123-
124-
122+
125123
static public void createFileFromTemplate(final File tmplFile, final File destFile) {
126124
createFileFromTemplate(tmplFile, destFile, null);
127-
}
128-
125+
}
129126

130127
static public void createFileFromTemplate(final File tmplFile, final File destFile,
131128
final HashMap<String, String> replaceMap) {
@@ -149,8 +146,7 @@ static public void createFileFromTemplate(final File tmplFile, final File destFi
149146
pw.flush();
150147
pw.close();
151148
}
152-
153-
149+
154150
static public File createSubFolder(File parent, String name) throws IOException {
155151
File newFolder = new File(parent, name);
156152
if (newFolder.exists()) {
@@ -190,15 +186,9 @@ static public File createSubFolder(File parent, String name) throws IOException
190186
}
191187
return newFolder;
192188
}
193-
194-
195-
static public void extractFolder(File file, File newPath, boolean setExec)
189+
190+
static public void extractFolder(File file, File newPath)
196191
throws IOException {
197-
extractFolder(file, newPath, setExec, false);
198-
}
199-
200-
static public void extractFolder(File file, File newPath, boolean setExec,
201-
boolean remRoot) throws IOException {
202192
int BUFFER = 2048;
203193

204194
ZipFile zip = new ZipFile(file);
@@ -209,32 +199,14 @@ static public void extractFolder(File file, File newPath, boolean setExec,
209199
// grab a zip file entry
210200
ZipEntry entry = zipFileEntries.nextElement();
211201
String currentEntry = entry.getName();
212-
213-
if (remRoot) {
214-
// Remove root folder from path
215-
int idx = currentEntry.indexOf("/");
216-
if (idx == -1) {
217-
// Let's try the system file separator
218-
// https://stackoverflow.com/a/16485210
219-
idx = currentEntry.indexOf(File.separator);
220-
}
221-
currentEntry = currentEntry.substring(idx + 1);
222-
}
223-
202+
224203
File destFile = new File(newPath, currentEntry);
225204
//destFile = new File(newPath, destFile.getName());
226205
File destinationParent = destFile.getParentFile();
227206

228207
// create the parent directory structure if needed
229208
destinationParent.mkdirs();
230209

231-
String ext = PApplet.getExtension(currentEntry);
232-
if (setExec && ext.equals("unknown")) {
233-
// On some OS X machines the android binaries lose their executable
234-
// attribute, rendering the mode unusable
235-
destFile.setExecutable(true);
236-
}
237-
238210
if (!entry.isDirectory()) {
239211
// should preserve permissions
240212
// https://bitbucket.org/atlassian/amps/pull-requests/21/amps-904-preserve-executable-file-status/diff
@@ -263,17 +235,15 @@ static public void extractClassesJarFromAar(File wearFile, File explodeDir,
263235
File jarFile) throws IOException {
264236
extractClassesJarFromAar(wearFile, explodeDir, jarFile, true);
265237
}
266-
267-
238+
268239
static public void extractClassesJarFromAar(File wearFile, File explodeDir,
269240
File jarFile, boolean removeDir) throws IOException {
270-
extractFolder(wearFile, explodeDir, false);
241+
extractFolder(wearFile, explodeDir);
271242
File classFile = new File(explodeDir, "classes.jar");
272243
Util.copyFile(classFile, jarFile);
273244
Util.removeDir(explodeDir);
274245
}
275246

276-
277247
static public File[] getFileList(File folder, String[] names) {
278248
return getFileList(folder, names, null);
279249
}
@@ -289,8 +259,7 @@ static public File[] getFileList(File folder, String[] names, String[] altNames)
289259
}
290260
return icons;
291261
}
292-
293-
262+
294263
static public File[] getFileList(Mode mode, String prefix, String[] names) {
295264
File[] icons = new File[names.length];
296265
for (int i = 0; i < names.length; i++) {
@@ -305,8 +274,7 @@ static public boolean allFilesExists(File[] files) {
305274
}
306275
return true;
307276
}
308-
309-
277+
310278
static public boolean noFileExists(File[] files) {
311279
for (File f: files) {
312280
if (f.exists()) return false;

processing/mode/src/processing/mode/android/Device.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public Device(final Devices env, final String id) {
7171
public void bringLauncherToFront() {
7272
try {
7373
adb("shell", "am", "start",
74-
"-a", "android.intent.action.MAIN",
75-
"-c", "android.intent.category.HOME");
74+
"-a", "android.intent.action.MAIN",
75+
"-c", "android.intent.category.HOME");
7676
} catch (final Exception e) {
7777
e.printStackTrace(System.err);
7878
}
@@ -389,9 +389,9 @@ private void reportStackTrace(final LogEntry entry) {
389389
void initialize() throws IOException, InterruptedException {
390390
adb("logcat", "-c");
391391

392-
final String[] cmd = {"-s", id, "logcat", "-v", "brief"};
392+
final String[] cmd = genAdbCommand("logcat", "-v", "brief");
393393
final String title = PApplet.join(cmd, ' ');
394-
logcat = adbProc(cmd);
394+
logcat = env.getSDK().getAdbProcess(cmd);
395395

396396
ProcessRegistry.watch(logcat);
397397
new StreamPump(logcat.getInputStream(), "log: " + title).addTarget(

processing/mode/src/processing/mode/android/SDKDownloader.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected Object doInBackground() throws Exception {
141141

142142
// Command-line tools
143143
File downloadedCmdLineTools = new File(tempFolder, downloadUrls.cmdlineToolsFilename);
144-
downloadAndUnpack(downloadUrls.cmdlineToolsUrl, downloadedCmdLineTools, sdkFolder, true);
144+
downloadAndUnpack(downloadUrls.cmdlineToolsUrl, downloadedCmdLineTools, sdkFolder);
145145
File tmpFrom = new File(sdkFolder, "cmdline-tools");
146146
File tmpTo = new File(sdkFolder, "cmdline-tmp");
147147
AndroidUtil.moveDir(tmpFrom, tmpTo);
@@ -151,32 +151,32 @@ protected Object doInBackground() throws Exception {
151151

152152
// Platform tools
153153
File downloadedPlatformTools = new File(tempFolder, downloadUrls.platformToolsFilename);
154-
downloadAndUnpack(downloadUrls.platformToolsUrl, downloadedPlatformTools, sdkFolder, true);
154+
downloadAndUnpack(downloadUrls.platformToolsUrl, downloadedPlatformTools, sdkFolder);
155155

156156
// Build tools
157157
File downloadedBuildTools = new File(tempFolder, downloadUrls.buildToolsFilename);
158-
downloadAndUnpack(downloadUrls.buildToolsUrl, downloadedBuildTools, buildToolsFolder, true);
158+
downloadAndUnpack(downloadUrls.buildToolsUrl, downloadedBuildTools, buildToolsFolder);
159159

160160
// Platform
161161
File downloadedPlatform = new File(tempFolder, downloadUrls.platformFilename);
162-
downloadAndUnpack(downloadUrls.platformUrl, downloadedPlatform, platformsFolder, false);
162+
downloadAndUnpack(downloadUrls.platformUrl, downloadedPlatform, platformsFolder);
163163

164164
// USB driver
165165
if (Platform.isWindows()) {
166166
File downloadedFolder = new File(tempFolder, downloadUrls.usbDriverFilename);
167-
downloadAndUnpack(downloadUrls.usbDriverUrl, downloadedFolder, googleRepoFolder, false);
167+
downloadAndUnpack(downloadUrls.usbDriverUrl, downloadedFolder, googleRepoFolder);
168168
}
169169

170170
// HAXM
171171
if (!Platform.isLinux()) {
172172
File downloadedFolder = new File(tempFolder, downloadUrls.haxmFilename);
173-
downloadAndUnpack(downloadUrls.haxmUrl, downloadedFolder, haxmFolder, true);
173+
downloadAndUnpack(downloadUrls.haxmUrl, downloadedFolder, haxmFolder);
174174
}
175175

176176
if (DOWNLOAD_EMU_WITH_SDK) {
177177
// Emulator, unpacks directly to sdk folder
178178
File downloadedEmulator = new File(tempFolder, downloadUrls.emulatorFilename);
179-
downloadAndUnpack(downloadUrls.emulatorUrl, downloadedEmulator, sdkFolder, true);
179+
downloadAndUnpack(downloadUrls.emulatorUrl, downloadedEmulator, sdkFolder);
180180
}
181181

182182
if (Platform.isLinux() || Platform.isMacOS()) {
@@ -216,7 +216,7 @@ protected void done() {
216216
}
217217

218218
private void downloadAndUnpack(String urlString, File saveTo,
219-
File unpackTo, boolean setExec) throws IOException {
219+
File unpackTo) throws IOException {
220220
URL url = null;
221221
try {
222222
url = new URL(urlString);
@@ -248,7 +248,7 @@ private void downloadAndUnpack(String urlString, File saveTo,
248248
inputStream.close();
249249
outputStream.close();
250250

251-
AndroidUtil.extractFolder(saveTo, unpackTo, setExec);
251+
AndroidUtil.extractFolder(saveTo, unpackTo);
252252
}
253253

254254
private void getMainDownloadUrls(SDKUrlHolder urlHolder,

processing/mode/src/processing/mode/android/SysImageDownloader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected Object doInBackground() throws Exception {
148148
if (!tmp.exists()) tmp.mkdir();
149149
File sysImgWearFinalFolder = new File(tmp, downloadUrls.sysImgWearTag);
150150
if (!sysImgWearFinalFolder.exists()) sysImgWearFinalFolder.mkdir();
151-
downloadAndUnpack(downloadUrls.sysImgWearUrl, downloadedSysImgWear, sysImgWearFinalFolder, false);
151+
downloadAndUnpack(downloadUrls.sysImgWearUrl, downloadedSysImgWear, sysImgWearFinalFolder);
152152
fixSourceProperties(sysImgWearFinalFolder);
153153
} else {
154154
// mobile system images
@@ -157,7 +157,7 @@ protected Object doInBackground() throws Exception {
157157
if (!tmp.exists()) tmp.mkdir();
158158
File sysImgFinalFolder = new File(tmp, downloadUrls.sysImgTag);
159159
if (!sysImgFinalFolder.exists()) sysImgFinalFolder.mkdir();
160-
downloadAndUnpack(downloadUrls.sysImgUrl, downloadedSysImg, sysImgFinalFolder, false);
160+
downloadAndUnpack(downloadUrls.sysImgUrl, downloadedSysImg, sysImgFinalFolder);
161161
fixSourceProperties(sysImgFinalFolder);
162162
}
163163

@@ -193,7 +193,7 @@ protected void done() {
193193
}
194194

195195
private void downloadAndUnpack(String urlString, File saveTo,
196-
File unpackTo, boolean setExec) throws IOException {
196+
File unpackTo) throws IOException {
197197
URL url = null;
198198
try {
199199
url = new URL(urlString);
@@ -218,7 +218,7 @@ private void downloadAndUnpack(String urlString, File saveTo,
218218
inputStream.close();
219219
outputStream.close();
220220

221-
AndroidUtil.extractFolder(saveTo, unpackTo, setExec);
221+
AndroidUtil.extractFolder(saveTo, unpackTo);
222222
}
223223

224224
// For some reason the source.properties file includes Addon entries,

0 commit comments

Comments
 (0)