Пример #1
0
 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);
 }
Пример #2
0
 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);
 }
Пример #3
0
 protected internal void DeleteFile(FileMock file)
 {
     file.IsDeleted = true;
     var r = _files.Remove(file.Name);
 }
Пример #4
0
 protected internal void AddFile(FileMock file)
 {
     _files.Add(file.Name, file);
 }
Пример #5
0
 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();
     }
 }
Пример #6
0
 public static FileMock Copy(FileMock file, string targetPath)
 {
     var bytes = file.Bytes;
     var newFile = new FileMock(targetPath, bytes)
     {
         Encoding = file.Encoding,
     };
     return newFile;
 }
Пример #7
0
 public static FileMock Create(string path, Lazy<byte[]> content, Encoding encoding)
 {
     var file = new FileMock(path, content, encoding);
     return file;
 }