summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2009-10-30 16:34:47 -0700
committerXavier Ducrohet <xav@android.com>2009-11-02 12:13:45 -0800
commit0dd85d89fa90de0d79da296292f75ceb5cf48b92 (patch)
treeb98b654756f29eae4ade06fa4d4ddb682d7a1208 /tools
parentd3f9eb79c79752b76e483d5d6774b76bcf91a8de (diff)
downloadandroid_development-0dd85d89fa90de0d79da296292f75ceb5cf48b92.tar.gz
android_development-0dd85d89fa90de0d79da296292f75ceb5cf48b92.tar.bz2
android_development-0dd85d89fa90de0d79da296292f75ceb5cf48b92.zip
Only apply permission to files with +x (do not merge)
integrated from eclair branch.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
index 41443add3..e7239d37c 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
+++ b/tools/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()
});
}
}