protected internal void MoveFile(FileMock file, string targetPath, DirectoryMock targetDir) { var r = _files.Remove(file.Name); file.Path = targetPath; file.Name = System.IO.Path.GetFileName(file.Path); targetDir._files.Add(file.Name, file); }
public void AddFile(FileMock file) { var dirPath = PathHelper.GetParentOrDefault(file.Path); if (string.IsNullOrEmpty(dirPath)) throw new DirectoryNotFoundException(Lux.IO.Consts.ErrorMessages.ERROR_DIR_NOT_FOUND); var dir = GetDirectory(dirPath); if (dir == null) { dir = CreateDirectory(dirPath); dir = GetDirectory(dirPath); } dir.AddFile(file); }
protected internal void DeleteFile(FileMock file) { file.IsDeleted = true; var r = _files.Remove(file.Name); }
protected internal void AddFile(FileMock file) { _files.Add(file.Name, file); }
public void AddFile(FileMock file) { if (_fileSystem is MemoryFileSystem) { var memoryFileStream = (MemoryFileSystem)_fileSystem; memoryFileStream.AddFile(file); return; } var dirPath = PathHelper.GetParent(file.Path); _fileSystem.CreateDir(dirPath); using (var stream = _fileSystem.OpenFile(file.Path, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (var s = file.GetStream()) { s.CopyTo(stream); } stream.Flush(); } }
public static FileMock Copy(FileMock file, string targetPath) { var bytes = file.Bytes; var newFile = new FileMock(targetPath, bytes) { Encoding = file.Encoding, }; return newFile; }
public static FileMock Create(string path, Lazy<byte[]> content, Encoding encoding) { var file = new FileMock(path, content, encoding); return file; }