diff --git a/DiskAccessLibrary.FileSystems.Abstractions/DiskAccessLibrary.FileSystems.Abstractions.csproj b/DiskAccessLibrary.FileSystems.Abstractions/DiskAccessLibrary.FileSystems.Abstractions.csproj deleted file mode 100644 index dbd4cfa..0000000 --- a/DiskAccessLibrary.FileSystems.Abstractions/DiskAccessLibrary.FileSystems.Abstractions.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net20;net40;netstandard2.0 - DiskAccessLibrary.FileSystems.Abstractions - 1.0.0 - 1573;1591 - DiskAccessLibrary.FileSystems.Abstractions - false - Tal Aloni - Copyright © Tal Aloni 2012-2023 - DiskAccessLibrary abstractions and interfaces for FileSystem implementations - LGPL-3.0-or-later - https://github.com/TalAloni/DynamicDiskPartitioner - https://github.com/TalAloni/DynamicDiskPartitioner - true - - - diff --git a/DiskAccessLibrary.FileSystems.Abstractions/FileSystem.cs b/DiskAccessLibrary.FileSystems.Abstractions/FileSystem.cs deleted file mode 100644 index 8f29d38..0000000 --- a/DiskAccessLibrary.FileSystems.Abstractions/FileSystem.cs +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. - * - * You can redistribute this program and/or modify it under the terms of - * the GNU Lesser Public License as published by the Free Software Foundation, - * either version 3 of the License, or (at your option) any later version. - */ -using System; -using System.Collections.Generic; -using System.IO; - -namespace DiskAccessLibrary.FileSystems.Abstractions -{ - public abstract class FileSystem : IFileSystem - { - public abstract FileSystemEntry GetEntry(string path); - public abstract FileSystemEntry CreateFile(string path); - public abstract FileSystemEntry CreateDirectory(string path); - public abstract void Move(string source, string destination); - public abstract void Delete(string path); - public abstract List ListEntriesInDirectory(string path); - public abstract Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options); - public abstract void SetAttributes(string path, bool? isHidden, bool? isReadonly, bool? isArchived); - public abstract void SetDates(string path, DateTime? creationDT, DateTime? lastWriteDT, DateTime? lastAccessDT); - - public List ListEntriesInRootDirectory() - { - return ListEntriesInDirectory(@"\"); - } - - public virtual List> ListDataStreams(string path) - { - FileSystemEntry entry = GetEntry(path); - List> result = new List>(); - if (!entry.IsDirectory) - { - result.Add(new KeyValuePair("::$DATA", entry.Size)); - } - return result; - } - - public Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share) - { - return OpenFile(path, mode, access, share, FileOptions.None); - } - - public void CopyFile(string sourcePath, string destinationPath) - { - const int bufferLength = 1024 * 1024; - FileSystemEntry sourceFile = GetEntry(sourcePath); - FileSystemEntry destinationFile = GetEntry(destinationPath); - if (sourceFile == null | sourceFile.IsDirectory) - { - throw new FileNotFoundException(); - } - - if (destinationFile != null && destinationFile.IsDirectory) - { - throw new ArgumentException("Destination cannot be a directory"); - } - - if (destinationFile == null) - { - destinationFile = CreateFile(destinationPath); - } - Stream sourceStream = OpenFile(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, FileOptions.SequentialScan); - Stream destinationStream = OpenFile(destinationPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, FileOptions.None); - while (sourceStream.Position < sourceStream.Length) - { - int readSize = (int)Math.Max(bufferLength, sourceStream.Length - sourceStream.Position); - byte[] buffer = new byte[readSize]; - sourceStream.Read(buffer, 0, buffer.Length); - destinationStream.Write(buffer, 0, buffer.Length); - } - sourceStream.Close(); - destinationStream.Close(); - } - - public virtual bool Exists(string path) - { - try - { - GetEntry(path); - } - catch (FileNotFoundException) - { - return false; - } - catch (DirectoryNotFoundException) - { - return false; - } - - return true; - } - - public abstract string Name - { - get; - } - - public abstract long Size - { - get; - } - - public abstract long FreeSpace - { - get; - } - - public abstract bool SupportsNamedStreams - { - get; - } - - public static string GetParentDirectory(string path) - { - if (path == String.Empty) - { - path = @"\"; - } - - if (!path.StartsWith(@"\")) - { - throw new ArgumentException("Invalid path"); - } - - if (path.Length > 1 && path.EndsWith(@"\")) - { - path = path.Substring(0, path.Length - 1); - } - - int separatorIndex = path.LastIndexOf(@"\"); - return path.Substring(0, separatorIndex + 1); - } - - /// - /// Will append a trailing slash to a directory path if not already present - /// - /// - /// - public static string GetDirectoryPath(string path) - { - if (path.EndsWith(@"\")) - { - return path; - } - else - { - return path + @"\"; - } - } - } -} diff --git a/DiskAccessLibrary.FileSystems.Abstractions/FileSystemEntry.cs b/DiskAccessLibrary.FileSystems.Abstractions/FileSystemEntry.cs deleted file mode 100644 index 56e042d..0000000 --- a/DiskAccessLibrary.FileSystems.Abstractions/FileSystemEntry.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. - * - * You can redistribute this program and/or modify it under the terms of - * the GNU Lesser Public License as published by the Free Software Foundation, - * either version 3 of the License, or (at your option) any later version. - */ -using System; - -namespace DiskAccessLibrary.FileSystems.Abstractions -{ - public class FileSystemEntry - { - /// - /// Full Path. Directory path should end with a trailing slash. - /// - public string FullName; - public string Name; - public bool IsDirectory; - public ulong Size; - public DateTime CreationTime; - public DateTime LastWriteTime; - public DateTime LastAccessTime; - public bool IsHidden; - public bool IsReadonly; - public bool IsArchived; - - public FileSystemEntry(string fullName, string name, bool isDirectory, ulong size, DateTime creationTime, DateTime lastWriteTime, DateTime lastAccessTime, bool isHidden, bool isReadonly, bool isArchived) - { - FullName = fullName; - Name = name; - IsDirectory = isDirectory; - Size = size; - CreationTime = creationTime; - LastWriteTime = lastWriteTime; - LastAccessTime = lastAccessTime; - IsHidden = isHidden; - IsReadonly = isHidden; - IsArchived = isHidden; - - if (isDirectory) - { - FullName = FileSystem.GetDirectoryPath(FullName); - } - } - - public FileSystemEntry Clone() - { - FileSystemEntry clone = (FileSystemEntry)MemberwiseClone(); - return clone; - } - } -} diff --git a/DiskAccessLibrary.FileSystems.Abstractions/IFileSystem.cs b/DiskAccessLibrary.FileSystems.Abstractions/IFileSystem.cs deleted file mode 100644 index 14f6e9d..0000000 --- a/DiskAccessLibrary.FileSystems.Abstractions/IFileSystem.cs +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. - * - * You can redistribute this program and/or modify it under the terms of - * the GNU Lesser Public License as published by the Free Software Foundation, - * either version 3 of the License, or (at your option) any later version. - */ -using System; -using System.Collections.Generic; -using System.IO; - -namespace DiskAccessLibrary.FileSystems.Abstractions -{ - public interface IFileSystem - { - /// - /// - /// - /// - FileSystemEntry GetEntry(string path); - - /// - /// - /// - FileSystemEntry CreateFile(string path); - - /// - /// - /// - FileSystemEntry CreateDirectory(string path); - - /// - /// - /// - /// - void Move(string source, string destination); - - /// - /// - /// - /// - void Delete(string path); - - /// - /// - /// - List ListEntriesInDirectory(string path); - - /// - /// - /// - /// - List> ListDataStreams(string path); - - /// - /// - /// - /// - Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options); - - /// - /// - /// - void SetAttributes(string path, bool? isHidden, bool? isReadonly, bool? isArchived); - - /// - /// - /// - void SetDates(string path, DateTime? creationDT, DateTime? lastWriteDT, DateTime? lastAccessDT); - - string Name - { - get; - } - - /// - long Size - { - get; - } - - /// - long FreeSpace - { - get; - } - - /// - /// Indicates support for opening named streams (alternate data streams). - /// Named streams are opened using the filename:stream syntax. - /// - bool SupportsNamedStreams - { - get; - } - } -} diff --git a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj index 5575892..87591f1 100644 --- a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj +++ b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj @@ -16,8 +16,11 @@ - + + + + diff --git a/SMBServer.sln b/SMBServer.sln index f13b65c..416bcca 100644 --- a/SMBServer.sln +++ b/SMBServer.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29728.190 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiskAccessLibrary.FileSystems.Abstractions", "DiskAccessLibrary.FileSystems.Abstractions\DiskAccessLibrary.FileSystems.Abstractions.csproj", "{9119EC7E-AF78-4814-BF03-F3823A29A471}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utilities", "Utilities\Utilities.csproj", "{6E0F2D1E-6167-4032-BA90-DEE3A99207D0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMBLibrary", "SMBLibrary\SMBLibrary.csproj", "{8D9E8F5D-FD13-4E4C-9723-A333DA2034A7}" @@ -23,10 +21,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9119EC7E-AF78-4814-BF03-F3823A29A471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9119EC7E-AF78-4814-BF03-F3823A29A471}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9119EC7E-AF78-4814-BF03-F3823A29A471}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9119EC7E-AF78-4814-BF03-F3823A29A471}.Release|Any CPU.Build.0 = Release|Any CPU {6E0F2D1E-6167-4032-BA90-DEE3A99207D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6E0F2D1E-6167-4032-BA90-DEE3A99207D0}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E0F2D1E-6167-4032-BA90-DEE3A99207D0}.Release|Any CPU.ActiveCfg = Release|Any CPU