diff options
author | Raphael <raphael@google.com> | 2012-02-06 15:32:14 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-06 15:32:14 -0800 |
commit | 858b17c8539f9d9cb7202e6fa7e87bda35ca021c (patch) | |
tree | 9bc4a157ed80d0effd26d20d6254804c88d2378c /sdkmanager/libs/sdklib/src | |
parent | 585c358c3cf4c10d70b28da7f777ea844c79e41f (diff) | |
parent | 2d0bec5514d42fe717133f6c017019c542ef0c46 (diff) | |
download | sdk-858b17c8539f9d9cb7202e6fa7e87bda35ca021c.zip sdk-858b17c8539f9d9cb7202e6fa7e87bda35ca021c.tar.gz sdk-858b17c8539f9d9cb7202e6fa7e87bda35ca021c.tar.bz2 |
Merge "SDK Manager: extract samples as read only."
Diffstat (limited to 'sdkmanager/libs/sdklib/src')
-rwxr-xr-x | sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SamplePackage.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SamplePackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SamplePackage.java index 0462a9d..9b2daf7 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SamplePackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SamplePackage.java @@ -23,9 +23,11 @@ import com.android.sdklib.SdkConstants; import com.android.sdklib.SdkManager;
import com.android.sdklib.internal.repository.Archive.Arch;
import com.android.sdklib.internal.repository.Archive.Os;
+import com.android.sdklib.io.IFileOp;
import com.android.sdklib.repository.PkgProps;
import com.android.sdklib.repository.SdkRepoConstants;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.w3c.dom.Node;
import java.io.File;
@@ -367,6 +369,26 @@ public class SamplePackage extends MinToolsPackage }
/**
+ * Set all the files from a sample package as read-only so that
+ * users don't end up modifying sources by mistake in Eclipse
+ * (samples are copied if using the NPW > Create from sample.)
+ */
+ @Override
+ public void postUnzipFileHook(
+ Archive archive,
+ ITaskMonitor monitor,
+ IFileOp fileOp,
+ File unzippedFile,
+ ZipArchiveEntry zipEntry) {
+ super.postUnzipFileHook(archive, monitor, fileOp, unzippedFile, zipEntry);
+
+ if (fileOp.isFile(unzippedFile) &&
+ !SdkConstants.FN_SOURCE_PROP.equals(unzippedFile.getName())) {
+ fileOp.setReadOnly(unzippedFile);
+ }
+ }
+
+ /**
* Reads the hash from the properties file, if it exists.
* Returns null if something goes wrong, e.g. there's no property file or
* it doesn't contain our hash. Returns an empty string if the hash wasn't
|