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));
     }
 }
Exemplo n.º 2
0
		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;
		}
Exemplo n.º 3
0
		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)));
		}
Exemplo n.º 4
0
        SafeUri FindImportDestination(SafeUri uri, DateTime time)
        {
            // Find a new unique location inside the photo folder
            string name = uri.GetFilename ();

            var dest_uri = FSpot.Core.Global.PhotoUri.Append (time.Year.ToString ())
                                          .Append (String.Format ("{0:D2}", time.Month))
                                          .Append (String.Format ("{0:D2}", time.Day));
            EnsureDirectory (dest_uri);

            // If the destination we'd like to use is the file itself return that
            if (dest_uri.Append (name) == uri)
                return uri;

            // Find an unused name
            int i = 1;
            var dest = dest_uri.Append (name);
            var file = GLib.FileFactory.NewForUri (dest);
            while (file.Exists) {
                var filename = uri.GetFilenameWithoutExtension ();
                var extension = uri.GetExtension ();
                dest = dest_uri.Append (String.Format ("{0}-{1}{2}", filename, i++, extension));
                file = GLib.FileFactory.NewForUri (dest);
            }

            return dest;
        }