+
+ // returns whether directory was created or not
+ bool CreateDirectoryIfRequired (string name)
+ {
+ if (Directory.Exists (name))
+ return false;
+
+ Log.LogMessage ("Creating directory '{0}'", name);
+ Directory.CreateDirectory (name);
+ return true;
+ }
+
+ void CopyFile (string source, string dest, bool create_dir)
+ {
+ if (create_dir)
+ CreateDirectoryIfRequired (Path.GetDirectoryName (dest));
+ if (overwriteReadOnlyFiles)
+ ClearReadOnlyAttribute (dest);
+ Log.LogMessage ("Copying file from '{0}' to '{1}'", source, dest);
+ if (String.Compare (source, dest) != 0)
+ File.Copy (source, dest, true);
+ ClearReadOnlyAttribute (dest);
+ }
+
+ void ClearReadOnlyAttribute (string name)
+ {
+ if (File.Exists (name) && ((File.GetAttributes (name) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly))
+ File.SetAttributes (name, FileAttributes.Normal);
+ }
+
+ bool HasFileChanged (string source, string dest)
+ {
+ if (!File.Exists (dest))
+ return true;
+
+ FileInfo sourceInfo = new FileInfo (source);
+ FileInfo destinationInfo = new FileInfo (dest);
+
+ return !(sourceInfo.Length == destinationInfo.Length &&
+ File.GetLastWriteTime (source) <= File.GetLastWriteTime (dest));
+ }
+