Esempio n. 1
0
		public void CopyIfNeeded (IPhoto item, SafeUri destinationBase)
		{
			// remember source uri for copying xmp file
			SafeUri defaultVersionUri = item.DefaultVersion.Uri;

			foreach (IPhotoVersion version in item.Versions) {
				// Copy into photo folder and update IPhotoVersion uri
				var source = version.Uri;
				var destination = destinationBase.Append (source.GetFilename ());
				if (!source.Equals (destination)) {
					destination = GetUniqueFilename (destination);
					file_system.File.Copy (source, destination, false);
					copied_files.Add (destination);
					original_files.Add (source);
					version.Uri = destination;
				}
			}

			// Copy XMP sidecar
			var xmp_original = defaultVersionUri.ReplaceExtension(".xmp");
			if (file_system.File.Exists (xmp_original)) {
				var xmp_destination = item.DefaultVersion.Uri.ReplaceExtension (".xmp");
				file_system.File.Copy (xmp_original, xmp_destination, true);
				copied_files.Add (xmp_destination);
				original_files.Add (xmp_original);
			}
		}
Esempio n. 2
0
		public void CreateDirectory (SafeUri uri)
		{
			var parts = uri.AbsolutePath.Split('/');
			var current = new SafeUri (uri.Scheme + ":///", true);
			for (int i = 0; i < parts.Length; i++) {
				current = current.Append (parts [i]);
				var file = FileFactory.NewForUri (current);
				if (!file.Exists) {
					file.MakeDirectory (null);
				}
			}
		}
Esempio n. 3
0
        protected virtual string ImageName(int image_num)
        {
            var uri = Collection [image_num].DefaultVersion.Uri;
            var dest_uri = new SafeUri (GalleryPath);

            // Find an unused name
            int i = 1;
            var dest = dest_uri.Append (uri.GetFilename ());
            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.GetFilename ();
        }
Esempio n. 4
0
		internal static SafeUri FindImportDestination (IPhoto item, SafeUri baseUri)
		{
			DateTime time = item.Time;
			return baseUri
				.Append (time.Year.ToString ())
				.Append (String.Format ("{0:D2}", time.Month))
				.Append (String.Format ("{0:D2}", time.Day));
		}