Exemplo n.º 1
0
        public void Import(string source, Folder destination, string name, CallbacksBase importCallbacks)
        {
            CheckDisposed();
            CheckName(name);
            CheckVersion();

            destination = ArchiveAndReplaceRoot(destination, null, null);

            if (Directory.Exists(source)) CollectImportDirectoryTotals(source, importCallbacks);
            else if (File.Exists(source)) importCallbacks.TotalToProcess++;
            else throw new NotFoundException();

            if (Directory.Exists(source)) ImportDirectory(source, destination, name, importCallbacks, false);
            else if (File.Exists(source)) ImportFile(source, destination, name, importCallbacks);
            else throw new NotFoundException();

            SetBlocksUsed();

            importCallbacks.OperationCompleted(!importCallbacks.ShouldAbort());
        }
Exemplo n.º 2
0
        public void Copy(IIndexNode nodeToCopy, Folder destination, string name, CallbacksBase copyCallbacks)
        {
            CheckDisposed();
            CheckName(name);
            CheckVersion();

            // Gather totals (copy in ~O(1) :D)
            copyCallbacks.TotalToProcess++;

            // Do the real copy
            if (nodeToCopy is Folder) CopyFolder(nodeToCopy as Folder, destination, name, copyCallbacks);
            else if (nodeToCopy is VFSFile) CopyFile(nodeToCopy as VFSFile, destination, name, copyCallbacks);
            else throw new ArgumentException("nodeToCopy must be of type Folder or VFSFile", "nodeToCopy");

            SetBlocksUsed();

            copyCallbacks.OperationCompleted(!copyCallbacks.ShouldAbort());
        }
Exemplo n.º 3
0
        public void Export(IIndexNode source, string destination, CallbacksBase exportCallbacks)
        {
            var absoluteDestination = Path.GetFullPath(destination);
            EnsureParentDirectoryExists(absoluteDestination);
            CheckDisposed();

            if (source == null) throw new NotFoundException();

            if (File.Exists(absoluteDestination) || Directory.Exists(absoluteDestination)) throw new VFSException("Destination already exists!");

            // Gather totals
            if (source is Folder) CollectExportDirectoryTotals(source as Folder, exportCallbacks);
            else if (source is VFSFile) exportCallbacks.TotalToProcess++;
            else throw new ArgumentException("Source must be of type Folder or VFSFile", "source");

            // Do the real export
            if (source is Folder) ExportFolder(source as Folder, absoluteDestination, exportCallbacks);
            else ExportFile(source as VFSFile, absoluteDestination, exportCallbacks);

            exportCallbacks.OperationCompleted(!exportCallbacks.ShouldAbort());
        }