internal static bool IsJpegRawPair(SafeUri file1, SafeUri file2) { return file1.GetBaseUri ().ToString () == file2.GetBaseUri ().ToString () && file1.GetFilenameWithoutExtension () == file2.GetFilenameWithoutExtension () && ((ImageFile.IsJpeg (file1) && ImageFile.IsRaw (file2)) || (ImageFile.IsRaw (file1) && ImageFile.IsJpeg (file2))); }
public void TestFileUris() { foreach (var test in tests) { var suri = new SafeUri (test.Uri); Assert.AreEqual (suri.AbsoluteUri, test.AbsoluteUri, String.Format("AbsoluteUri for {0}", test.Uri)); Assert.AreEqual (suri.GetExtension (), test.Extension, String.Format("Extension for {0}", test.Uri)); Assert.AreEqual (suri.GetBaseUri ().ToString (), test.BaseUri, String.Format("BaseUri for {0}", test.Uri)); Assert.AreEqual (suri.GetFilename (), test.Filename, String.Format("Filename for {0}", test.Uri)); Assert.AreEqual (suri.GetFilenameWithoutExtension (), test.FilenameWithoutExtension, String.Format("FilenameWithoutExtension for {0}", test.Uri)); } }
SafeUri GetUniqueFilename (SafeUri dest) { // Find an unused name int i = 1; var base_uri = dest.GetBaseUri (); var filename = dest.GetFilenameWithoutExtension (); var extension = dest.GetExtension (); while (file_system.File.Exists (dest)) { dest = base_uri.Append (String.Format ("{0}-{1}{2}", filename, i++, extension)); } return dest; }