From 2d0bec5514d42fe717133f6c017019c542ef0c46 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 6 Feb 2012 14:19:39 -0800 Subject: 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 --- .../sdklib/internal/repository/SamplePackage.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sdkmanager/libs') 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 -- cgit v1.1