aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2012-02-06 14:19:39 -0800
committerRaphael <raphael@google.com>2012-02-06 15:29:47 -0800
commit2d0bec5514d42fe717133f6c017019c542ef0c46 (patch)
treefa31973800f043b758477a3b90a192332dcc2413 /sdkmanager/libs
parent72b588de47324540a1989fcc7d1b820b56045371 (diff)
downloadsdk-2d0bec5514d42fe717133f6c017019c542ef0c46.zip
sdk-2d0bec5514d42fe717133f6c017019c542ef0c46.tar.gz
sdk-2d0bec5514d42fe717133f6c017019c542ef0c46.tar.bz2
SDK Manager: extract samples as read only.
This changes the SDK Manager to extract sample code as read-only files (for java, aidl and xml sources). Then we have a change in ADT to make sure that the NPW copies the sources of a sample as read-write. Change-Id: I26a494d3b1a08890b5b6970eea759b6f7c63c62c
Diffstat (limited to 'sdkmanager/libs')
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SamplePackage.java22
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