Пример #1
0
        private uint CreateVersion(string name, uint base_version_id, bool create, bool is_protected)
        {
            System.Uri new_uri      = GetUriForVersionName(name, System.IO.Path.GetExtension(VersionUri(base_version_id).AbsolutePath));
            System.Uri original_uri = VersionUri(base_version_id);
            string     md5_sum      = MD5Sum;

            if (VersionNameExists(name))
            {
                throw new Exception("This version name already exists");
            }

            if (create)
            {
                if ((new Gnome.Vfs.Uri(new_uri.ToString())).Exists)
                {
                    throw new Exception(String.Format("An object at this uri {0} already exists", new_uri.ToString()));
                }

                Xfer.XferUri(
                    new Gnome.Vfs.Uri(original_uri.ToString()),
                    new Gnome.Vfs.Uri(new_uri.ToString()),
                    XferOptions.Default, XferErrorMode.Abort,
                    XferOverwriteMode.Abort,
                    delegate(Gnome.Vfs.XferProgressInfo info) { return(1); });

                //			Mono.Unix.Native.Stat stat;
                //			int stat_err = Mono.Unix.Native.Syscall.stat (original_path, out stat);
                //			File.Copy (original_path, new_path);
                FSpot.ThumbnailGenerator.Create(new_uri).Dispose();
                //
                //			if (stat_err == 0)
                //				try {
                //					Mono.Unix.Native.Syscall.chown(new_path, Mono.Unix.Native.Syscall.getuid (), stat.st_gid);
                //				} catch (Exception) {}
                //
            }
            else
            {
                md5_sum = Photo.GenerateMD5(new_uri);
            }
            highest_version_id++;

            Versions [highest_version_id] = new PhotoVersion(this, highest_version_id, new_uri, md5_sum, name, is_protected);

            changes.AddVersion(highest_version_id);

            return(highest_version_id);
        }