public void Copy(string source, string dest, CallbacksBase copyCallbacks) { if (copyCallbacks == null) copyCallbacks = new CopyCallbacks(); if (!Exists(source)) throw new VFSException(string.Format("Source {0} does not exist", source)); if (Exists(dest)) throw new VFSException(string.Format("Destination {0} already exists", dest)); CreateParentFolder(dest); _fileSystem.Copy(FindNode(source), FindParentFolder(dest), PathParser.GetNodeName(dest), copyCallbacks); // Leads to errors? -> hope that it should be better now _searchService.AddToIndexRecursive(dest); }
public void Import(string source, string dest, CallbacksBase importCallbacks) { }
public void Copy(string source, string dest, CallbacksBase copyCallbacks) { _lock.EnterWriteLock(); try { _manipulator.Copy(source, dest, copyCallbacks); } finally { _lock.ExitWriteLock(); } }
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()); }
public void Export(IIndexNode source, string destination, CallbacksBase exportCallbacks) { _lock.EnterWriteLock(); try { _fileSystem.Export(source, destination, exportCallbacks); } finally { _lock.ExitWriteLock(); } }
public void Export(string testFileSource, string dest, CallbacksBase exportCallbacks, long version) { var originalVersion = Version("/"); try { SwitchToVersion(version); Export(testFileSource, dest, exportCallbacks); } finally { SwitchToVersion(originalVersion); } }
private void ExportFolder(Folder folder, string destination, CallbacksBase exportCallbacks) { if (exportCallbacks.ShouldAbort()) return; Directory.CreateDirectory(destination); exportCallbacks.CurrentlyProcessed++; foreach (var vfsFile in Files(folder)) { ExportFile(vfsFile, Path.Combine(destination, vfsFile.Name), exportCallbacks); } foreach (var f in Folders(folder)) { ExportFolder(f, Path.Combine(destination, f.Name), exportCallbacks); } }
public void Export(string source, string dest, CallbacksBase exportCallbacks, long version) { }
private void CopyFolder(Folder folderToCopy, Folder destination, string name, CallbacksBase copyCallbacks) { if (copyCallbacks.ShouldAbort()) return; CheckName(name); var copiedFolder = CreateFolder(destination, name, true); copiedFolder.IndirectNodeNumber = folderToCopy.IndirectNodeNumber; copiedFolder.BlocksCount = folderToCopy.BlocksCount; copiedFolder.PredecessorBlockNr = folderToCopy.BlockNumber; //copiedFolder.Version = NextVersion; _persistence.Persist(copiedFolder); //ArchiveAndReplaceRoot(copiedFolder.Parent, null, copiedFolder); copyCallbacks.CurrentlyProcessed++; }
private void ExportFile(VFSFile file, string destination, CallbacksBase exportCallbacks) { if (exportCallbacks.ShouldAbort()) return; EnsureParentDirectoryExists(destination); using (var stream = File.OpenWrite(destination)) { using (var reader = DecorateToHostStream( new VFSFileStream(file, _blockParser, _options, _blockAllocation, _blockManipulator, _persistence))) { var buffer = new byte[_options.BlockSize]; int read; while ((read = reader.Read(buffer, 0, _options.BlockSize)) > 0) { stream.Write(buffer, 0, read); } } } exportCallbacks.CurrentlyProcessed++; }
private void CopyFile(VFSFile fileToCopy, Folder destination, string name, CallbacksBase copyCallbacks) { if (copyCallbacks.ShouldAbort()) return; CheckName(name); var newFile = new VFSFile(name) { Parent = destination, BlockNumber = _blockAllocation.Allocate(), LastBlockSize = fileToCopy.LastBlockSize, IndirectNodeNumber = fileToCopy.IndirectNodeNumber, BlocksCount = fileToCopy.BlocksCount, PredecessorBlockNr = fileToCopy.BlockNumber, Version = NextVersion }; _persistence.Persist(newFile); copyCallbacks.CurrentlyProcessed++; ArchiveAndReplaceRoot(destination, null, newFile); }
private void CollectExportDirectoryTotals(Folder source, CallbacksBase exportCallbacks) { // Direcotry exportCallbacks.TotalToProcess++; // File exportCallbacks.TotalToProcess += Files(source).Count(); foreach (var folder in Folders(source)) { CollectExportDirectoryTotals(folder, exportCallbacks); } }
private static void CollectImportDirectoryTotals(string source, CallbacksBase importCallbacks) { var info = new DirectoryInfo(source); importCallbacks.TotalToProcess++; foreach (var directoryInfo in info.GetDirectories()) CollectImportDirectoryTotals(directoryInfo.FullName, importCallbacks); importCallbacks.TotalToProcess += info.GetFiles().Length; }
public void Copy(string source, string dest, CallbacksBase copyCallbacks) { }
private void ImportDirectory(string source, Folder destination, string name, CallbacksBase importCallbacks, bool createVersion) { if (importCallbacks.ShouldAbort()) return; var info = new DirectoryInfo(source); var newFolder = CreateFolder(destination, name, createVersion); importCallbacks.CurrentlyProcessed++; foreach (var directoryInfo in info.GetDirectories()) ImportDirectory(directoryInfo.FullName, newFolder, directoryInfo.Name, importCallbacks, false); foreach (var fileInfo in info.GetFiles()) ImportFile(fileInfo.FullName, newFolder, fileInfo.Name, importCallbacks); }
public void Export(string source, string dest, CallbacksBase exportCallbacks) { }
private void ImportFile(string source, Folder destination, string name, CallbacksBase importCallbacks) { if (importCallbacks.ShouldAbort()) return; var f = new FileInfo(source); if (f.Length > _options.MaximumFileSize) throw new VFSException( string.Format("File is too big. Maximum file size is {0}. You can adjust the BlockSize in the Options to allow bigger files.", _options.MaximumFileSize)); var file = CreateFile(source, destination, name); AppendBlockReference(destination, file.BlockNumber); importCallbacks.CurrentlyProcessed++; }
public void Export(string source, string dest, CallbacksBase exportCallbacks) { if (exportCallbacks == null) exportCallbacks = new ExportCallbacks(); _fileSystem.Export(FindNode(source), dest, exportCallbacks); }
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()); }
public void Import(string source, string dest, CallbacksBase importCallbacks) { if (importCallbacks == null) importCallbacks = new ImportCallbacks(); var node = CreateParentFolder(dest); _fileSystem.Import(source, node, PathParser.GetNodeName(dest), importCallbacks); // Leads to errors? -> hope that it should be better now _searchService.AddToIndexRecursive(dest); }
public void Export(string source, string dest, CallbacksBase exportCallbacks, long version) { _lock.EnterWriteLock(); try { _manipulator.Export(source, dest, exportCallbacks, version); } finally { _lock.ExitWriteLock(); } }
public void Copy(IIndexNode nodeToCopy, Folder destination, string nameOfCopiedElement, CallbacksBase copyCallbacks) { _lock.EnterWriteLock(); try { _fileSystem.Copy(nodeToCopy, destination, nameOfCopiedElement, copyCallbacks); } finally { _lock.ExitWriteLock(); } }
public void Import(string source, string dest, CallbacksBase importCallbacks) { _lock.EnterWriteLock(); try { _manipulator.Import(source, dest, importCallbacks); } finally { _lock.ExitWriteLock(); } }
public void Import(string source, Folder destination, string name, CallbacksBase importCallbacks) { _lock.EnterWriteLock(); try { _fileSystem.Import(source, destination, name, importCallbacks); } finally { _lock.ExitWriteLock(); } }
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()); }