aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-11-02 14:40:10 -0500
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-11-02 14:40:10 -0500
commit2555661dcc794929665276e87c07dc8e608c89fc (patch)
tree0bb7c4dff8346a7dcc3f772cb1f1c0372154d44e /sdkmanager
parent0317603a1d93818710fc8f1c75f35d614af42b49 (diff)
parent48a5b6db26292d6dd9a177eb56002df48ba16ef4 (diff)
downloadsdk-2555661dcc794929665276e87c07dc8e608c89fc.zip
sdk-2555661dcc794929665276e87c07dc8e608c89fc.tar.gz
sdk-2555661dcc794929665276e87c07dc8e608c89fc.tar.bz2
Merge change Ied3304a0 into eclair
* changes: Only apply permission to files with +x
Diffstat (limited to 'sdkmanager')
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
index 41443ad..e7239d3 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
@@ -807,8 +807,12 @@ public class Archive implements IDescription {
}
// if needed set the permissions.
- if (usingUnixPerm) {
- setPermission(destFile, entry.getUnixMode());
+ if (usingUnixPerm && destFile.isFile()) {
+ // get the mode and test if it contains the executable bit
+ int mode = entry.getUnixMode();
+ if ((mode & 0111) != 0) {
+ setExecutablePermission(destFile);
+ }
}
// Increment progress bar to match. We update only between files.
@@ -928,19 +932,14 @@ public class Archive implements IDescription {
}
/**
- * Sets the Unix permission on a file or folder.
+ * Sets the executable Unix permission (0777) on a file or folder.
* @param file The file to set permissions on.
* @param unixMode the permissions as received from {@link ZipArchiveEntry#getUnixMode()}.
* @throws IOException
*/
- private void setPermission(File file, int unixMode) throws IOException {
- // permissions contains more than user/group/all, and we need the 777 display mode, so we
- // convert it in octal string and take the last 3 digits.
- String permission = String.format("%o", unixMode);
- permission = permission.substring(permission.length() - 3, permission.length());
-
+ private void setExecutablePermission(File file) throws IOException {
Runtime.getRuntime().exec(new String[] {
- "chmod", permission, file.getAbsolutePath()
+ "chmod", "777", file.getAbsolutePath()
});
}
}