Пример #1
0
        static void Main(string[] args)
        {
            TestXferOptions opt = new TestXferOptions();

            opt.ProcessArgs(args);

            if (opt.RemainingArguments.Length < 2)
            {
                opt.DoUsage();
                return;
            }

            XferOptions       options       = XferOptions.Default;
            XferOverwriteMode overwriteMode = XferOverwriteMode.Query;

            if (opt.recursive)
            {
                Console.WriteLine("Warning: Recursive xfer of directories.");
                options |= XferOptions.Recursive;
            }
            if (opt.followSymlinks)
            {
                Console.WriteLine("Warning: Following symlinks.");
                options |= XferOptions.FollowLinks;
            }
            if (opt.recursiveSymlinks)
            {
                Console.WriteLine("Warning: Following symlinks recursively.");
                options |= XferOptions.FollowLinksRecursive;
            }
            if (opt.replace)
            {
                Console.WriteLine("Warning: Using replace overwrite mode.");
                overwriteMode = XferOverwriteMode.Replace;
            }
            if (opt.deleteSource)
            {
                Console.WriteLine("Warning: Removing source files.");
                options |= XferOptions.Removesource;
            }

            Gnome.Vfs.Vfs.Initialize();

            Gnome.Vfs.Uri source = new Gnome.Vfs.Uri(opt.RemainingArguments[0]);
            Console.WriteLine("Source: `{0}'", source);
            Gnome.Vfs.Uri target = new Gnome.Vfs.Uri(opt.RemainingArguments[1]);
            Console.WriteLine("Target: `{0}'", target);

            Result result = Xfer.XferUri(source, target, options,
                                         XferErrorMode.Query,
                                         overwriteMode,
                                         new XferProgressCallback(OnProgress));

            Console.WriteLine("Result: {0}", Gnome.Vfs.Vfs.ResultToString(result));

            Gnome.Vfs.Vfs.Shutdown();
        }
Пример #2
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);
        }