Пример #1
0
        public bool Run(Assembly assm, string ResourceName, string OutputPath, TaskLoggingHelper Log)
        {
            // Ensure our output directory exists
            if (!Directory.Exists (Path.GetDirectoryName (OutputPath)))
                Directory.CreateDirectory (Path.GetDirectoryName (OutputPath));

            // Copy out one of our embedded resources to a path
            using (var from = GetManifestResourceStream (ResourceName)) {

                // If the resource already exists, only overwrite if it's changed
                if (File.Exists (OutputPath)) {
                    var hash1 = MonoAndroidHelper.HashFile (OutputPath);
                    var hash2 = MonoAndroidHelper.HashStream (from);

                    if (hash1 == hash2) {
                        Log.LogDebugMessage ("Resource {0} is unchanged. Skipping.", OutputPath);
                        return true;
                    }
                }

                // Hash calculation read to the end, move back to beginning of file
                from.Position = 0;

                // Write out the resource
                using (var to = File.Create (OutputPath))
                    Copy (from, to);

                Log.LogDebugMessage ("Wrote resource {0}.", OutputPath);
            }

            return true;
        }