Exemplo n.º 1
0
		public void Copy(DirectoryData source, string destination, bool overwrite = false) {

			var attributes = _scanner.Attributes(destination);
			var exists = attributes.Exists();

			if (exists && !overwrite) {
				throw new PathExistsException(destination);
			}

			var destPath = _paths.ParsePath(destination);

			// If exists then simple fill the directory
			// If it doesnt exist create it
			if (!exists) {
				_win32IO.CreateDirectory(destPath);
				_win32IO.SetFileAttributes(destPath, source.Attributes);
			}
			// The destination is a file, so delete it as we cant fill a file as a directory
			else if(attributes.IsFile()) {

				_win32IO.DeleteFile(destPath);
			}
			
			foreach (var item in _scanner.EnumerateDirectoryContents(source.Path)) {

				if (item.IsDirectory) {
					
					Copy((DirectoryData)item, _paths.Combine(destination, item.Name), true);
				}
				else if (!item.IsDirectory) {

					Copy((FileData)item, _paths.Combine(destination, item.Name), true);
				}
			}
		}
Exemplo n.º 2
0
        public void Delete(DirectoryData data)
        {
            var setAttribitesRequired = data.Attributes != FileAttributes.Normal;

            foreach (var item in _scanner.EnumerateDirectoryContents(data.Path))
            {
                if (item.IsDirectory)
                {
                    Delete((DirectoryData)item);
                }
                else if (!item.IsDirectory)
                {
                    Delete((FileData)item);
                }
            }

            var path = _paths.ParsePath(data.Path);

            if (setAttribitesRequired)
            {
                _win32IO.SetFileAttributes(path, FileAttributes.Normal);
            }

            _win32IO.RemoveDirectory(_paths.ParsePath(data.Path));
        }
Exemplo n.º 3
0
        public void Copy(DirectoryData source, string destination, bool overwrite = false)
        {
            var attributes = _scanner.Attributes(destination);
            var exists     = attributes.Exists();

            if (exists && !overwrite)
            {
                throw new PathExistsException(destination);
            }

            var destPath = _paths.ParsePath(destination);

            // If exists then simple fill the directory
            // If it doesnt exist create it
            if (!exists)
            {
                _win32IO.CreateDirectory(destPath);
                _win32IO.SetFileAttributes(destPath, source.Attributes);
            }
            // The destination is a file, so delete it as we cant fill a file as a directory
            else if (attributes.IsFile())
            {
                _win32IO.DeleteFile(destPath);
            }

            foreach (var item in _scanner.EnumerateDirectoryContents(source.Path))
            {
                if (item.IsDirectory)
                {
                    Copy((DirectoryData)item, _paths.Combine(destination, item.Name), true);
                }
                else if (!item.IsDirectory)
                {
                    Copy((FileData)item, _paths.Combine(destination, item.Name), true);
                }
            }
        }
Exemplo n.º 4
0
		public void Delete(DirectoryData data) {

			var setAttribitesRequired = data.Attributes != FileAttributes.Normal;

			foreach (var item in _scanner.EnumerateDirectoryContents(data.Path)) {

				if (item.IsDirectory) {

					Delete((DirectoryData)item);
				}
				else if (!item.IsDirectory) {

					Delete((FileData)item);
				}
			}

			var path = _paths.ParsePath(data.Path);

			if (setAttribitesRequired) {

				_win32IO.SetFileAttributes(path, FileAttributes.Normal);
			}

			_win32IO.RemoveDirectory(_paths.ParsePath(data.Path));
		}
		public DirectoryDataSnapshot(DirectoryData data) : base(data.Path, data.Raw) {
		}
 public DirectoryDataSnapshot(DirectoryData data) : base(data.Path, data.Raw)
 {
 }