diff --git a/SMBLibrary/NTFileStore/Adapter/IOExceptionHelper.cs b/SMBLibrary.Adapters/NTFileSystemAdapter/IOExceptionHelper.cs similarity index 86% rename from SMBLibrary/NTFileStore/Adapter/IOExceptionHelper.cs rename to SMBLibrary.Adapters/NTFileSystemAdapter/IOExceptionHelper.cs index f4bd588..80da3d3 100644 --- a/SMBLibrary/NTFileStore/Adapter/IOExceptionHelper.cs +++ b/SMBLibrary.Adapters/NTFileSystemAdapter/IOExceptionHelper.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* 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, @@ -11,7 +11,7 @@ using System.Reflection; using System.Text; using Utilities; -namespace SMBLibrary +namespace SMBLibrary.Adapters { public class IOExceptionHelper { diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.Query.cs similarity index 97% rename from SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs rename to SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.Query.cs index 25696ae..f619992 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs +++ b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.Query.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2018 Tal Aloni . All rights reserved. +/* 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, @@ -10,7 +10,7 @@ using System.IO; using DiskAccessLibrary.FileSystems.Abstractions; using Utilities; -namespace SMBLibrary +namespace SMBLibrary.Adapters { public partial class NTFileSystemAdapter { diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.QueryDirectory.cs b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.QueryDirectory.cs similarity index 97% rename from SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.QueryDirectory.cs rename to SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.QueryDirectory.cs index 51a33c1..3a92023 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.QueryDirectory.cs +++ b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.QueryDirectory.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2018 Tal Aloni . All rights reserved. +/* 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, @@ -10,7 +10,7 @@ using System.IO; using DiskAccessLibrary.FileSystems.Abstractions; using Utilities; -namespace SMBLibrary +namespace SMBLibrary.Adapters { public partial class NTFileSystemAdapter { diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.QueryFileSystem.cs b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.QueryFileSystem.cs similarity index 96% rename from SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.QueryFileSystem.cs rename to SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.QueryFileSystem.cs index 73bb765..ff06274 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.QueryFileSystem.cs +++ b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.QueryFileSystem.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* 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, @@ -9,7 +9,7 @@ using System.Collections.Generic; using System.IO; using Utilities; -namespace SMBLibrary +namespace SMBLibrary.Adapters { public partial class NTFileSystemAdapter { diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Set.cs b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.Set.cs similarity index 96% rename from SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Set.cs rename to SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.Set.cs index ee1272d..94d1c1c 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Set.cs +++ b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.Set.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2018 Tal Aloni . All rights reserved. +/* 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, @@ -9,7 +9,7 @@ using System.Collections.Generic; using System.IO; using Utilities; -namespace SMBLibrary +namespace SMBLibrary.Adapters { public partial class NTFileSystemAdapter { diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.cs similarity index 96% rename from SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs rename to SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.cs index 32a93e8..8db57a9 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs +++ b/SMBLibrary.Adapters/NTFileSystemAdapter/NTFileSystemAdapter.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2019 Tal Aloni . All rights reserved. +/* 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, @@ -9,7 +9,7 @@ using System.IO; using DiskAccessLibrary.FileSystems.Abstractions; using Utilities; -namespace SMBLibrary +namespace SMBLibrary.Adapters { public partial class NTFileSystemAdapter : INTFileStore { @@ -408,7 +408,9 @@ namespace SMBLibrary if (bytesRead < maxCount) { // EOF, we must trim the response data array - data = ByteReader.ReadBytes(data, 0, bytesRead); + byte[] temp = new byte[bytesRead]; + Array.Copy(data, temp, bytesRead); + data = temp; } return NTStatus.STATUS_SUCCESS; } diff --git a/SMBLibrary.Adapters/Properties/AssemblyInfo.cs b/SMBLibrary.Adapters/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..249784f --- /dev/null +++ b/SMBLibrary.Adapters/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SMBLibrary.Adapters")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("none")] +[assembly: AssemblyProduct("SMBLibrary.Adapters")] +[assembly: AssemblyCopyright("Copyright © none 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("359460ac-a179-40cf-8491-e51a198e438c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.4.3.0")] +[assembly: AssemblyFileVersion("1.4.3.0")] diff --git a/SMBLibrary.Adapters/SMBLibrary.Adapters.VS2005.csproj b/SMBLibrary.Adapters/SMBLibrary.Adapters.VS2005.csproj new file mode 100644 index 0000000..9a41e01 --- /dev/null +++ b/SMBLibrary.Adapters/SMBLibrary.Adapters.VS2005.csproj @@ -0,0 +1,60 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC} + Library + Properties + SMBLibrary.Adapters + SMBLibrary.Adapters + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + {9119EC7E-AF78-4814-BF03-F3823A29A471} + DiskAccessLibrary.FileSystems.Abstractions + + + {8D9E8F5D-FD13-4E4C-9723-A333DA2034A7} + SMBLibrary.VS2005 + + + + + \ No newline at end of file diff --git a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj new file mode 100644 index 0000000..f18b418 --- /dev/null +++ b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj @@ -0,0 +1,21 @@ + + + + net20;net40;netstandard2.0 + false + SMBLibrary.Adapters + 1.4.3 + SMBLibrary.Adapters + Tal Aloni + FileSystem adapters for SMBLibrary + LGPL-3.0-or-later + https://github.com/TalAloni/SMBLibrary + https://github.com/TalAloni/SMBLibrary + + + + + + + + diff --git a/SMBLibrary/NTFileStore/Adapter/FileHandle.cs b/SMBLibrary/NTFileStore/FileHandle.cs similarity index 89% rename from SMBLibrary/NTFileStore/Adapter/FileHandle.cs rename to SMBLibrary/NTFileStore/FileHandle.cs index 914da46..ecdf897 100644 --- a/SMBLibrary/NTFileStore/Adapter/FileHandle.cs +++ b/SMBLibrary/NTFileStore/FileHandle.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* 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, diff --git a/SMBLibrary/SMBLibrary.VS2005.csproj b/SMBLibrary/SMBLibrary.VS2005.csproj index 093b96c..83d90f3 100644 --- a/SMBLibrary/SMBLibrary.VS2005.csproj +++ b/SMBLibrary/SMBLibrary.VS2005.csproj @@ -102,13 +102,6 @@ - - - - - - - @@ -130,6 +123,7 @@ + @@ -597,10 +591,6 @@ - - {9119EC7E-AF78-4814-BF03-F3823A29A471} - DiskAccessLibrary.FileSystems.Abstractions.VS2005 - {6E0F2D1E-6167-4032-BA90-DEE3A99207D0} Utilities diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index f2afec4..724680f 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -15,7 +15,6 @@ - diff --git a/SMBLibrary/Server/Shares/FileSystemShare.cs b/SMBLibrary/Server/Shares/FileSystemShare.cs index cd65fdd..205c574 100644 --- a/SMBLibrary/Server/Shares/FileSystemShare.cs +++ b/SMBLibrary/Server/Shares/FileSystemShare.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* 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, @@ -6,7 +6,6 @@ */ using System; using System.IO; -using DiskAccessLibrary.FileSystems.Abstractions; namespace SMBLibrary.Server { @@ -29,13 +28,6 @@ namespace SMBLibrary.Server m_cachingPolicy = cachingPolicy; } - public FileSystemShare(string shareName, IFileSystem fileSystem, CachingPolicy cachingPolicy) - { - m_name = shareName; - m_fileSystem = new NTFileSystemAdapter(fileSystem); - m_cachingPolicy = cachingPolicy; - } - public bool HasReadAccess(SecurityContext securityContext, string path) { return HasAccess(securityContext, path, FileAccess.Read); diff --git a/SMBLibrary/Server/Shares/SMBShareCollection.cs b/SMBLibrary/Server/Shares/SMBShareCollection.cs index 62ad016..4cd61a1 100644 --- a/SMBLibrary/Server/Shares/SMBShareCollection.cs +++ b/SMBLibrary/Server/Shares/SMBShareCollection.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. +/* 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, @@ -6,18 +6,11 @@ */ using System; using System.Collections.Generic; -using DiskAccessLibrary.FileSystems.Abstractions; namespace SMBLibrary.Server { public class SMBShareCollection : List { - public void Add(string shareName, IFileSystem fileSystem, CachingPolicy cachingPolicy) - { - FileSystemShare share = new FileSystemShare(shareName, fileSystem, cachingPolicy); - this.Add(share); - } - public bool Contains(string shareName, StringComparison comparisonType) { return (this.IndexOf(shareName, comparisonType) != -1); diff --git a/SMBServer.VS2005.sln b/SMBServer.VS2005.sln index ad3bff0..587ab08 100644 --- a/SMBServer.VS2005.sln +++ b/SMBServer.VS2005.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMBLibrary.VS2005", "SMBLib EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMBLibrary.Win32.VS2005", "SMBLibrary.Win32\SMBLibrary.Win32.VS2005.csproj", "{8CE25496-A52B-4841-822F-74C469D10EE7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMBLibrary.Adapters.VS2005", "SMBLibrary.Adapters\SMBLibrary.Adapters.VS2005.csproj", "{DF51D33B-F030-4B25-803A-3BEBC35E5BEC}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMBServer.VS2005", "SMBServer\SMBServer.VS2005.csproj", "{70D43E2A-26A2-4046-A472-5BA8C9437612}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMBLibrary.Tests.VS2005", "SMBLibrary.Tests\SMBLibrary.Tests.VS2005.csproj", "{C79B06EB-32C1-44CA-B7E1-A891B8135658}" @@ -35,6 +37,10 @@ Global {8CE25496-A52B-4841-822F-74C469D10EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CE25496-A52B-4841-822F-74C469D10EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CE25496-A52B-4841-822F-74C469D10EE7}.Release|Any CPU.Build.0 = Release|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Release|Any CPU.Build.0 = Release|Any CPU {70D43E2A-26A2-4046-A472-5BA8C9437612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70D43E2A-26A2-4046-A472-5BA8C9437612}.Debug|Any CPU.Build.0 = Debug|Any CPU {70D43E2A-26A2-4046-A472-5BA8C9437612}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/SMBServer.VS2019.sln b/SMBServer.VS2019.sln index 7d022e6..f13b65c 100644 --- a/SMBServer.VS2019.sln +++ b/SMBServer.VS2019.sln @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMBLibrary", "SMBLibrary\SM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMBLibrary.Win32", "SMBLibrary.Win32\SMBLibrary.Win32.csproj", "{8CE25496-A52B-4841-822F-74C469D10EE7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMBLibrary.Adapters", "SMBLibrary.Adapters\SMBLibrary.Adapters.csproj", "{DF51D33B-F030-4B25-803A-3BEBC35E5BEC}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMBServer", "SMBServer\SMBServer.csproj", "{70D43E2A-26A2-4046-A472-5BA8C9437612}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMBLibrary.Tests", "SMBLibrary.Tests\SMBLibrary.Tests.csproj", "{C79B06EB-32C1-44CA-B7E1-A891B8135658}" @@ -37,6 +39,10 @@ Global {8CE25496-A52B-4841-822F-74C469D10EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CE25496-A52B-4841-822F-74C469D10EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CE25496-A52B-4841-822F-74C469D10EE7}.Release|Any CPU.Build.0 = Release|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF51D33B-F030-4B25-803A-3BEBC35E5BEC}.Release|Any CPU.Build.0 = Release|Any CPU {70D43E2A-26A2-4046-A472-5BA8C9437612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70D43E2A-26A2-4046-A472-5BA8C9437612}.Debug|Any CPU.Build.0 = Debug|Any CPU {70D43E2A-26A2-4046-A472-5BA8C9437612}.Release|Any CPU.ActiveCfg = Release|Any CPU