public static SafeUri CopySidecarToTest(SafeUri uri, string filename) { var target = uri.ReplaceExtension (".xmp"); var orig_uri = new SafeUri (Environment.CurrentDirectory + TestDataLocation + filename); var file = GLib.FileFactory.NewForUri (orig_uri); var file2 = GLib.FileFactory.NewForUri (target); file.Copy (file2, GLib.FileCopyFlags.Overwrite, null, null); return target; }
void CopyIfNeeded(IPhoto item, SafeUri destination) { if (item.DefaultVersion.Uri.Equals (destination)) return; // Copy image var file = GLib.FileFactory.NewForUri (item.DefaultVersion.Uri); var new_file = GLib.FileFactory.NewForUri (destination); file.Copy (new_file, GLib.FileCopyFlags.AllMetadata, null, null); copied_files.Add (destination); original_files.Add (item.DefaultVersion.Uri); item.DefaultVersion.Uri = destination; // Copy XMP sidecar var xmp_original = item.DefaultVersion.Uri.ReplaceExtension(".xmp"); var xmp_file = GLib.FileFactory.NewForUri (xmp_original); if (xmp_file.Exists) { var xmp_destination = destination.ReplaceExtension (".xmp"); var new_xmp_file = GLib.FileFactory.NewForUri (xmp_destination); xmp_file.Copy (new_xmp_file, GLib.FileCopyFlags.AllMetadata | GLib.FileCopyFlags.Overwrite, null, null); copied_files.Add (xmp_destination); original_files.Add (xmp_original); } }
public void TestReplaceExtension() { var uri = new SafeUri ("file:///test/image.jpg", true); var goal = new SafeUri ("file:///test/image.xmp", true); Assert.AreEqual (goal, uri.ReplaceExtension (".xmp")); }