diff --git a/ComputingServices/Cluster/Master.vb b/ComputingServices/Cluster/Master.vb deleted file mode 100644 index 5fa92b0..0000000 --- a/ComputingServices/Cluster/Master.vb +++ /dev/null @@ -1,158 +0,0 @@ -#Region "Microsoft.VisualBasic::29306db6025bcb28ecbc5f64b5575737, ComputingServices\Cluster\Master.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class Master - ' - ' Properties: Nodes - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' Function: [Select], GetPreferNode, Invoke - ' - ' Sub: Scan, ScanTask - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports Microsoft.VisualBasic.ComponentModel.Collection -Imports Microsoft.VisualBasic.Language -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Http -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Tcp -Imports Microsoft.VisualBasic.Parallel -Imports sciBASIC.ComputingServices.TaskHost - -Namespace Cluster - - ''' - ''' Client - ''' - Public Class Master - - ''' - ''' Online avaliable nodes in this server cluster. - ''' - Dim _nodes As New Dictionary(Of TaskRemote) - Dim node_port% - Dim net$ - - ''' - ''' 返回节点的数量 - ''' - ''' - Public ReadOnly Property Nodes As Integer - Get - Return _nodes.Count - End Get - End Property - - ''' - ''' - ''' - ''' - ''' - Sub New(net$, node_port%) - Me.node_port = node_port - Me.net = net - End Sub - - Public Sub Scan() - Dim request As New RequestStream(Protocols.ProtocolEntry, TaskProtocols.Handshake) - - For Each IP$ In EnumerateAddress(Me.net) - Dim response = New TcpRequest(IP, node_port) _ - .SendMessage(request, 200) - - SyncLock _nodes - - If response.Protocol = HTTP_RFC.RFC_OK Then - If Not _nodes.ContainsKey(IP) Then - Call _nodes.Add(New TaskRemote(IP, node_port)) - Call $"Add new node: {IP}".__DEBUG_ECHO - End If - Else - If _nodes.ContainsKey(IP) Then - Call _nodes.Remove(IP) - Call $"Removes offline node: {IP}".__DEBUG_ECHO - End If - End If - End SyncLock - Next - End Sub - - ''' - ''' 返回负载量最低的节点 - ''' - ''' - Public Function GetPreferNode() As TaskRemote - SyncLock _nodes - - Return LinqAPI.DefaultFirst(Of TaskRemote) <= - _ - From node As TaskRemote - In _nodes.Values.AsParallel - Select node, - node.Load - Order By Load Ascending - - End SyncLock - End Function - - ''' - ''' 自动分配空闲的计算节点 - ''' - ''' - ''' - Public Function Invoke(target As [Delegate], ParamArray args As Object()) As Object - Dim node As TaskRemote = GetPreferNode() - Dim out As Object = node.Invoke(target, args) - Return out - End Function - - Public Iterator Function [Select](Of T, Tout)(source As IEnumerable(Of T), task As [Delegate], args As Object()) As IEnumerable(Of Tout) - Dim node As TaskRemote = GetPreferNode() - Dim out As ILinq(Of Tout) = node.Select(Of T, Tout)(task, source.ToArray, args) - - For Each x As Tout In out - Yield x - Next - End Function - - Public Sub ScanTask() - Call RunTask(AddressOf Scan) - End Sub - End Class -End Namespace diff --git a/ComputingServices/ComponentModel/IHostBase.vb b/ComputingServices/ComponentModel/IHostBase.vb deleted file mode 100644 index b9205de..0000000 --- a/ComputingServices/ComponentModel/IHostBase.vb +++ /dev/null @@ -1,78 +0,0 @@ -#Region "Microsoft.VisualBasic::b18fd8363c2ff03baf0c40c12922f872, ComputingServices\ComponentModel\IHostBase.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class IHostBase - ' - ' Constructor: (+2 Overloads) Sub New - ' - ' Class IMasterBase - ' - ' - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Abstract -Imports Microsoft.VisualBasic.Net.Tcp - -Namespace ComponentModel - - Public MustInherit Class IHostBase : Inherits IMasterBase(Of TcpServicesSocket) - - Sub New(portal As Integer) - __host = New TcpServicesSocket(portal) - End Sub - - Sub New() - End Sub - End Class - - Public MustInherit Class IMasterBase(Of TSocket As IServicesSocket) - - Public MustOverride ReadOnly Property Portal As IPEndPoint - - Protected Friend __host As TSocket - - Public Shared Narrowing Operator CType(master As IMasterBase(Of TSocket)) As IPEndPoint - Return master.Portal - End Operator - - Public Shared Narrowing Operator CType(master As IMasterBase(Of TSocket)) As System.Net.IPEndPoint - Return master.Portal.GetIPEndPoint - End Operator - - End Class -End Namespace diff --git a/ComputingServices/ComponentModel/IRemote.vb b/ComputingServices/ComponentModel/IRemote.vb deleted file mode 100644 index 0af1ba6..0000000 --- a/ComputingServices/ComponentModel/IRemote.vb +++ /dev/null @@ -1,51 +0,0 @@ -#Region "Microsoft.VisualBasic::4ed036e6d3b96a7f496681ffbbb780e9, ComputingServices\ComponentModel\IRemote.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Interface IRemoteSupport - ' - ' Properties: FileSystem - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports sciBASIC.ComputingServices.FileSystem - -Namespace ComponentModel - - Public Interface IRemoteSupport - - ReadOnly Property FileSystem As FileSystemHost - End Interface -End Namespace diff --git a/ComputingServices/ComputingServices.vbproj b/ComputingServices/ComputingServices.vbproj index 71b930f..a070fb4 100644 --- a/ComputingServices/ComputingServices.vbproj +++ b/ComputingServices/ComputingServices.vbproj @@ -207,21 +207,6 @@ - - - - - - - - - - - - - - - @@ -238,10 +223,6 @@ Settings.settings True - - - - diff --git a/ComputingServices/Extensions.vb b/ComputingServices/Extensions.vb deleted file mode 100644 index f2d8a90..0000000 --- a/ComputingServices/Extensions.vb +++ /dev/null @@ -1,48 +0,0 @@ -#Region "Microsoft.VisualBasic::352864497ee44603ec76226fc0b6f23e, ComputingServices\Extensions.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Module Extensions - ' - ' Properties: Sha256Provider - ' - ' /********************************************************************************/ - -#End Region - -''' -''' 不对外公开的拓展方法 -''' -Module Extensions - - Public ReadOnly Property Sha256Provider As New SecurityString.SHA256("xie.guigang@gmail.com", "ghTGAbcZ") -End Module diff --git a/ComputingServices/FileSystem/FileSystem.vb b/ComputingServices/FileSystem/FileSystem.vb deleted file mode 100644 index cfd3d6b..0000000 --- a/ComputingServices/FileSystem/FileSystem.vb +++ /dev/null @@ -1,1725 +0,0 @@ -#Region "Microsoft.VisualBasic::1e6140186df16b913520dda4de4273a5, ComputingServices\FileSystem\FileSystem.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class FileSystem - ' - ' Properties: CurrentDirectory, Drives, Portal - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' Function: DirectoryExists, FileExists, (+2 Overloads) FindInFiles, (+2 Overloads) GetDirectories, GetDirectoryInfo - ' GetDriveInfo, GetFileInfo, (+2 Overloads) GetFiles, GetParentPath, GetTempFileName - ' (+2 Overloads) OpenFileHandle, (+2 Overloads) OpenTextFieldParser, (+2 Overloads) OpenTextFileReader, (+2 Overloads) OpenTextFileWriter, ReadAllBytes - ' (+2 Overloads) ReadAllText, ToString - ' - ' Sub: (+2 Overloads) CopyDirectory, (+2 Overloads) CopyFile, CreateDirectory, DeleteDirectory, DeleteFile - ' (+2 Overloads) MoveDirectory, (+2 Overloads) MoveFile, RenameDirectory, RenameFile, WriteAllBytes - ' (+2 Overloads) WriteAllText - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.Collections.ObjectModel -Imports System.IO -Imports System.Text -Imports Microsoft.VisualBasic.FileIO -Imports Microsoft.VisualBasic.Linq -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Tcp -Imports Microsoft.VisualBasic.Serialization.JSON -Imports sciBASIC.ComputingServices.FileSystem.Protocols - -Namespace FileSystem - - ''' - ''' Provides properties and methods for working with drives, files, and directories on remote server. - ''' (分布式文件系统) - ''' - Public Class FileSystem - - ''' - ''' 远端服务器的开放的句柄端口 - ''' - Public ReadOnly Property Portal As IPEndPoint - - Sub New(portal As IPEndPoint) - _Portal = portal - End Sub - - Public Overrides Function ToString() As String - Return $"{CurrentDirectory}@{_Portal.ToString}" - End Function - - ' Exceptions: - ' T:System.IO.DirectoryNotFoundException: - ' The path is not valid. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' Gets or sets the current directory. - ''' - ''' The current directory for file I/O operations. - Public Property CurrentDirectory As String - Get - Dim req As RequestStream = New RequestStream(ProtocolEntry, FileSystemAPI.CurrentDirectory) - Dim invoke As New TcpRequest(_Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - Return req.GetUTF8String - End Get - Set(value As String) - Dim req As RequestStream = New RequestStream(ProtocolEntry, FileSystemAPI.CurrentDirectory, value) - Dim invoke As New TcpRequest(_Portal) - Call invoke.SendMessage(req) - End Set - End Property - - ''' - ''' Returns a read-only collection of all available drive names. - ''' - ''' A read-only collection of all available drives as System.IO.DriveInfo objects. - Public ReadOnly Property Drives As ReadOnlyCollection(Of System.IO.DriveInfo) - Get - Dim req As RequestStream = New RequestStream(ProtocolEntry, FileSystemAPI.Drives) - Dim invoke As New TcpRequest(_Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - Dim array As String() = req.GetUTF8String.LoadJSON(Of String()) - Dim lst As DriveInfo() = array.Select(Function(s) s.LoadJSON(Of DriveInfo)).ToArray - Return New ReadOnlyCollection(Of System.IO.DriveInfo)(CType(lst, IList(Of System.IO.DriveInfo))) - End Get - End Property - - ' Exceptions: - ' T:System.ArgumentException: - ' The new name specified for the directory contains a colon (:) or slash (\ or - ' /). - ' - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' destinationDirectoryName or sourceDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The source directory does not exist. - ' - ' T:System.IO.IOException: - ' The source directory is a root directory - ' - ' T:System.IO.IOException: - ' The combined path points to an existing file. - ' - ' T:System.IO.IOException: - ' The source path and target path are the same. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A folder name in the path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' A destination file exists but cannot be accessed. - ''' - ''' Copies the contents of a directory to another directory. - ''' - ''' The directory to be copied. - ''' The location to which the directory contents should be copied. - Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String) - - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The new name specified for the directory contains a colon (:) or slash (\ or - ' /). - ' - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' destinationDirectoryName or sourceDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The source directory does not exist. - ' - ' T:System.IO.IOException: - ' The source directory is a root directory - ' - ' T:System.IO.IOException: - ' The combined path points to an existing file. - ' - ' T:System.IO.IOException: - ' The source path and target path are the same. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A folder name in the path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' A destination file exists but cannot be accessed. - ''' - ''' Copies the contents of a directory to another directory. - ''' - ''' The directory to be copied. - ''' The location to which the directory contents should be copied. - ''' True to overwrite existing files; otherwise False. Default is False. - Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean) - - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' The system could not retrieve the absolute path. - ' - ' T:System.ArgumentException: - ' destinationFileName contains path information. - ' - ' T:System.ArgumentNullException: - ' destinationFileName or sourceFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The combined path points to an existing directory. - ' - ' T:System.IO.IOException: - ' The user does not have sufficient permissions to access the file. - ' - ' T:System.IO.IOException: - ' A file in the target directory with the same name is in use. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - - ''' - ''' Copies a file to a new location. - ''' - ''' The file to be copied. - ''' The location to which the file should be copied. - Public Sub CopyFile(sourceFileName As String, destinationFileName As String) - Call CopyFile(sourceFileName, destinationFileName) - End Sub - - ' - ' Summary: - ' Copies a file to a new location. - ' - ' Parameters: - ' sourceFileName: - ' The file to be copied. - ' - ' destinationFileName: - ' The location to which the file should be copied. - ' - ' overwrite: - ' True if existing files should be overwritten; otherwise False. Default is False. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' The system could not retrieve the absolute path. - ' - ' T:System.ArgumentException: - ' destinationFileName contains path information. - ' - ' T:System.ArgumentNullException: - ' destinationFileName or sourceFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The combined path points to an existing directory. - ' - ' T:System.IO.IOException: - ' The user does not have sufficient permissions to access the file. - ' - ' T:System.IO.IOException: - ' A file in the target directory with the same name is in use. - ' - ' T:System.IO.IOException: - ' The destination file exists and overwrite is set to False. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' - ''' - ''' - ''' - ''' - Public Sub CopyFile(sourceFileName As String, destinationFileName As String, overwrite As Boolean) - Dim source As FileURI = New FileURI(sourceFileName) - Dim destination As FileURI = New FileURI(destinationFileName) - - If source.IsLocal Then - If destination.IsLocal Then - Call FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, overwrite) - Else ' 进行文件上传 - Call NetTransfer.Upload(source.File, destination.File, destination.EntryPoint) - End If - Else - If destination.IsLocal Then ' 文件下载,然后执行删除 - Call NetTransfer.Download(source.File, destination.File, source.EntryPoint) - Else ' 远程文件系统之上的文件复制 - - End If - End If - End Sub - - ' - ' Summary: - ' Creates a directory. - ' - ' Parameters: - ' directory: - ' Name and location of the directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The directory name is malformed. For example, it contains illegal characters - ' or is only white space. - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The directory name is too long. - ' - ' T:System.NotSupportedException: - ' The directory name is only a colon (:). - ' - ' T:System.IO.IOException: - ' The parent directory of the directory to be created is read-only - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have permission to create the directory. - ''' - ''' - ''' - ''' - Public Sub CreateDirectory(directory As String) - Dim req As New RequestStream(ProtocolEntry, FileSystemAPI.CreateDirectory, directory) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - End Sub - ' - ' Summary: - ' Deletes a directory. - ' - ' Parameters: - ' directory: - ' Directory to be deleted. - ' - ' onDirectoryNotEmpty: - ' Specifies what should be done when a directory that is to be deleted contains - ' files or directories. Default is DeleteDirectoryOption.DeleteAllContents. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is a zero-length string, is malformed, contains only white space, or - ' contains invalid characters (including wildcard characters). The path is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist or is a file. - ' - ' T:System.IO.IOException: - ' The directory is not empty, and onDirectoryNotEmpty is set to ThrowIfDirectoryNonEmpty. - ' - ' T:System.IO.IOException: - ' The user does not have permission to delete the directory or subdirectory. - ' - ' T:System.IO.IOException: - ' A file in the directory or subdirectory is in use. - ' - ' T:System.NotSupportedException: - ' The directory name contains a colon (:). - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.Security.SecurityException: - ' The user does not have required permissions. - ' - ' T:System.OperationCanceledException: - ' The user cancels the operation or the directory cannot be deleted. - ''' - ''' - ''' - ''' - ''' - Public Sub DeleteDirectory(directory As String, onDirectoryNotEmpty As DeleteDirectoryOption) - Dim op As New DeleteArgs With { - .obj = directory, - .option = onDirectoryNotEmpty - } - Dim req As RequestStream = RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.DeleteDirectory, op) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - End Sub - - ' - ' Summary: - ' Deletes a file. - ' - ' Parameters: - ' file: - ' Name and path of the file to be deleted. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; it has a trailing - ' slash where a file must be specified; or it is a device path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' file is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.IOException: - ' The file is in use. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have permission to delete the file or the file is read-only. - ''' - ''' - ''' - ''' - Public Sub DeleteFile(file As String) - Dim req As RequestStream = New RequestStream(ProtocolEntry, FileSystemAPI.DeleteFile, file) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - End Sub - - ' - ' Summary: - ' Moves a directory from one location to another. - ' - ' Parameters: - ' sourceDirectoryName: - ' Path of the directory to be moved. - ' - ' destinationDirectoryName: - ' Path of the directory to which the source directory is being moved. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' The source is a root directory or The source path and the target path are the - ' same. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ''' - ''' - ''' - ''' - ''' - Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String) - - End Sub - ' - ' Summary: - ' Moves a directory from one location to another. - ' - ' Parameters: - ' sourceDirectoryName: - ' Path of the directory to be moved. - ' - ' destinationDirectoryName: - ' Path of the directory to which the source directory is being moved. - ' - ' overwrite: - ' True if existing directories should be overwritten; otherwise False. Default - ' is False. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' The source is a root directory or The source path and the target path are the - ' same. - ' - ' T:System.IO.IOException: - ' The target directory already exists and overwrite is set to False. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ''' - ''' - ''' - ''' - ''' - ''' - Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean) - - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' destinationFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Moves a file to a new location. - ''' - ''' Path of the file to be moved. - ''' Path of the directory into which the file should be moved. - Public Sub MoveFile(sourceFileName As String, destinationFileName As String) - Call MoveFile(sourceFileName, destinationFileName, False) - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' destinationFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The destination file exists and overwrite is set to False. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Moves a file to a new location. - ''' - ''' Path of the file to be moved. - ''' Path of the directory into which the file should be moved. - ''' True to overwrite existing files; otherwise False. Default is False. - Public Sub MoveFile(sourceFileName As String, destinationFileName As String, overwrite As Boolean) - Dim source As FileURI = New FileURI(sourceFileName) - Dim destination As FileURI = New FileURI(destinationFileName) - - If source.IsLocal Then - If destination.IsLocal Then - Call FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, overwrite) - Else ' 进行文件上传 - Call NetTransfer.Upload(source.File, destination.File, destination.EntryPoint) - End If - Else - If destination.IsLocal Then ' 文件下载,然后执行删除 - Call NetTransfer.Download(source.File, destination.File, source.EntryPoint) - Call DeleteFile(source.File) - Else ' 远程文件系统之上的文件移动 - - - End If - End If - End Sub - - ' - ' Summary: - ' Renames a directory. - ' - ' Parameters: - ' directory: - ' Path and name of directory to be renamed. - ' - ' newName: - ' New name for directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' newName contains path information. - ' - ' T:System.ArgumentNullException: - ' directory is Nothing.-or-newName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' There is an existing file or directory with the name specified in newName. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds 248 characters. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - - ''' - ''' - ''' - ''' - ''' - Public Sub RenameDirectory(directory As String, newName As String) - Dim rename As New RenameArgs With { - .old = directory, - .[New] = newName - } - Dim req As RequestStream = RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.RenameDirectory, rename) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - End Sub - ' - ' Summary: - ' Renames a file. - ' - ' Parameters: - ' file: - ' File to be renamed. - ' - ' newName: - ' New name of file. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' newName contains path information or ends with a backslash (\). - ' - ' T:System.ArgumentNullException: - ' file is Nothing.-or-newName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' There is an existing file or directory with the name specified in newName. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ''' - ''' - ''' - ''' - ''' - Public Sub RenameFile(file As String, newName As String) - Dim rename As New RenameArgs With { - .old = file, - .[New] = newName - } - Dim req As RequestStream = RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.RenameFile, rename) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.OutOfMemoryException: - ' There is not enough memory to write the string to buffer. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Writes data to a binary file. - ''' - ''' Path and name of the file to be written to. - ''' Data to be written to the file. - ''' True to append to the file contents; False to overwrite the file contents. Default - ''' is False. - Public Sub WriteAllBytes(file As String, data() As Byte, append As Boolean) - Dim mode As FileMode = If(append, FileMode.Append, FileMode.OpenOrCreate) - Dim remoteFile As New IO.RemoteFileStream(file, mode, Me) - Call remoteFile.Write(data, Scan0, data.Length) - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.OutOfMemoryException: - ' There is not enough memory to write the string to buffer. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Writes text to a file. - ''' - ''' File to be written to. - ''' Text to be written to file. - ''' True to append to the contents of the file; False to overwrite the contents of - ''' the file. - Public Sub WriteAllText(file As String, text As String, append As Boolean) - Call WriteAllText(file, text, append, Encoding.Default) - End Sub - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.OutOfMemoryException: - ' There is not enough memory to write the string to buffer. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Writes text to a file. - ''' - ''' File to be written to. - ''' Text to be written to file. - ''' True to append to the contents of the file; False to overwrite the contents of - ''' the file. - ''' What encoding to use when writing to file. - Public Sub WriteAllText(file As String, text As String, append As Boolean, encoding As Encoding) - Dim buf As Byte() = encoding.GetBytes(text) - Call WriteAllBytes(file, buf, append) - End Sub - - ' - ' Summary: - ' Returns True if the specified directory exists. - ' - ' Parameters: - ' directory: - ' Path of the directory. - ' - ' Returns: - ' True if the directory exists; otherwise False. - ''' - ''' - ''' - ''' - ''' - Public Function DirectoryExists(directory As String) As Boolean - Dim req As RequestStream = New RequestStream(ProtocolEntry, FileSystemAPI.DirectoryExists, directory) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - If rep.ChunkBuffer.First = 1 Then - Return True - Else - Return False - End If - End Function - - ' - ' Summary: - ' Returns True if the specified file exists. - ' - ' Parameters: - ' file: - ' Name and path of the file. - ' - ' Returns: - ' Returns True if the file exists; otherwise this method returns False. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The name of the file ends with a backslash (\). - ''' - ''' - ''' - ''' - ''' - Public Function FileExists(file As String) As Boolean - Dim req As RequestStream = New RequestStream(ProtocolEntry, FileSystemAPI.FileExists, file) - Dim invoke As New TcpRequest(Portal) - Dim rep As RequestStream = invoke.SendMessage(req) - If rep.ChunkBuffer.First = 1 Then - Return True - Else - Return False - End If - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The specified directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' Returns a read-only collection of strings representing the names of files containing - ''' the specified text. - ''' - ''' The directory to be searched. - ''' The search text. - ''' True if the search should be case-sensitive; otherwise False. Default is True. - ''' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly. - ''' Read-only collection of the names of files containing the specified text.. - Public Function FindInFiles(directory As String, containsText As String, ignoreCase As Boolean, searchType As FileIO.SearchOption) As ReadOnlyCollection(Of String) - Return FindInFiles(directory, containsText, ignoreCase, searchType, "*.*") - End Function - ' - ' Summary: - ' Returns a read-only collection of strings representing the names of files containing - ' the specified text. - ' - ' Parameters: - ' directory: - ' The directory to be searched. - ' - ' containsText: - ' The search text. - ' - ' ignoreCase: - ' True if the search should be case-sensitive; otherwise False. Default is True. - ' - ' searchType: - ' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly. - ' - ' fileWildcards: - ' Pattern to be matched. - ' - ' Returns: - ' Read-only collection of the names of files containing the specified text.. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The specified directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Function FindInFiles(directory As String, containsText As String, ignoreCase As Boolean, searchType As FileIO.SearchOption, ParamArray fileWildcards() As String) As ReadOnlyCollection(Of String) - - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' Returns a collection of strings representing the path names of subdirectories - ''' within a directory. - ''' - ''' Name and path of directory. - ''' Read-only collection of the path names of subdirectories within the specified - ''' directory. - Public Function GetDirectories(directory As String) As ReadOnlyCollection(Of String) - Return GetDirectories(directory, FileIO.SearchOption.SearchTopLevelOnly) - End Function - ' - ' Summary: - ' Returns a collection of strings representing the path names of subdirectories - ' within a directory. - ' - ' Parameters: - ' directory: - ' Name and path of directory. - ' - ' searchType: - ' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly. - ' - ' wildcards: - ' Pattern to match names. - ' - ' Returns: - ' Read-only collection of the path names of subdirectories within the specified - ' directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.ArgumentNullException: - ' One or more of the specified wildcard characters is Nothing, an empty string, - ' or contains only spaces. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Function GetDirectories(directory As String, searchType As FileIO.SearchOption, ParamArray wildcards() As String) As ReadOnlyCollection(Of String) - - End Function - ' - ' Summary: - ' Returns a System.IO.DirectoryInfo object for the specified path. - ' - ' Parameters: - ' directory: - ' String. Path of directory. - ' - ' Returns: - ' System.IO.DirectoryInfo object for the specified path. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path - ''' - ''' - ''' - ''' - ''' - Public Function GetDirectoryInfo(directory As String) As System.IO.DirectoryInfo - - End Function - ' - ' Summary: - ' Returns a System.IO.DriveInfo object for the specified drive. - ' - ' Parameters: - ' drive: - ' Drive to be examined. - ' - ' Returns: - ' System.IO.DriveInfo object for the specified drive. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' drive is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path - ''' - ''' - ''' - ''' - ''' - Public Function GetDriveInfo(drive As String) As System.IO.DriveInfo - - End Function - ' - ' Summary: - ' Returns a System.IO.FileInfo object for the specified file. - ' - ' Parameters: - ' file: - ' Name and path of the file. - ' - ' Returns: - ' System.IO.FileInfo object for the specified file - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path name is malformed. For example, it contains invalid characters or is - ' only white space. The file name has a trailing slash mark. - ' - ' T:System.ArgumentNullException: - ' file is Nothing or an empty string. - ' - ' T:System.NotSupportedException: - ' The path contains a colon in the middle of the string. - ' - ' T:System.IO.PathTooLongException: - ' The path is too long. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks ACL (access control list) access to the file. - ''' - ''' - ''' - ''' - ''' - Public Function GetFileInfo(file As String) As System.IO.FileInfo - - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory to search does not exist. - ' - ' T:System.IO.IOException: - ' directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' Returns a read-only collection of strings representing the names of files within - ''' a directory. - ''' - ''' Directory to be searched. - ''' Read-only collection of file names from the specified directory. - Public Function GetFiles(directory As String) As ReadOnlyCollection(Of String) - Return GetFiles(directory, FileIO.SearchOption.SearchTopLevelOnly) - End Function - ' - ' Summary: - ' Returns a read-only collection of strings representing the names of files within - ' a directory. - ' - ' Parameters: - ' directory: - ' Directory to be searched. - ' - ' searchType: - ' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly. - ' - ' wildcards: - ' Pattern to be matched. - ' - ' Returns: - ' Read-only collection of file names from the specified directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory to search does not exist. - ' - ' T:System.IO.IOException: - ' directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Function GetFiles(directory As String, searchType As FileIO.SearchOption, ParamArray wildcards() As String) As ReadOnlyCollection(Of String) - - End Function - - ' - ' Summary: - ' Returns the parent path of the provided path. - ' - ' Parameters: - ' path: - ' Path to be examined. - ' - ' Returns: - ' The parent path of the provided path. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' Path does not have a parent path because it is a root path. - ' - ' T:System.ArgumentNullException: - ' path is Nothing. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ''' - ''' - ''' - ''' - ''' - Public Function GetParentPath(path As String) As String - - End Function - ' - ' Summary: - ' Creates a uniquely named zero-byte temporary file on disk and returns the full - ' path of that file. - ' - ' Returns: - ' String containing the full path of the temporary file. - ''' - ''' - ''' - ''' - Public Function GetTempFileName() As String - - End Function - - ''' - ''' 在远程服务器上面打开一个文件句柄 - ''' - ''' - ''' - Public Function OpenFileHandle(file As String, mode As FileMode, access As FileAccess) As FileStreamInfo - Return OpenFileHandle(file, mode, access, Me.Portal) - End Function - - ''' - ''' 在远程服务器上面打开一个文件句柄 - ''' - ''' - ''' - Public Shared Function OpenFileHandle(file As String, mode As FileMode, access As FileAccess, portal As IPEndPoint) As FileStreamInfo - Dim req As RequestStream = Protocols.API.OpenHandle(file, mode, access) - Dim invoke As New TcpRequest(portal) - Dim rep As RequestStream = invoke.SendMessage(req) - Return rep.GetUTF8String.LoadJSON(Of FileStreamInfo) - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:Microsoft.VisualBasic.FileIO.MalformedLineException: - ' A row cannot be parsed using the specified format. The exception message specifies - ' the line causing the exception, while the Microsoft.VisualBasic.FileIO.TextFieldParser.ErrorLine - ' property is assigned the text contained in the line. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' The OpenTextFieldParser method allows you to create a Microsoft.VisualBasic.FileIO.TextFieldParser - ''' object, which provides a way to easily and efficiently parse structured text - ''' files, such as logs. The TextFieldParser object can be used to read both delimited - ''' and fixed-width files. - ''' - ''' The file to be opened with the TextFieldParser. - ''' Delimiters for the fields. - ''' Microsoft.VisualBasic.FileIO.TextFieldParser to read the specified file. - Public Function OpenTextFieldParser(file As String, ParamArray delimiters() As String) As TextFieldParser - Dim fileStream As New IO.RemoteFileStream(file, FileMode.Open, Me) - Dim parser As New TextFieldParser(fileStream, System.Text.Encoding.Default, True) - parser.Delimiters = delimiters - Return parser - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:Microsoft.VisualBasic.FileIO.MalformedLineException: - ' A row cannot be parsed using the specified format. The exception message specifies - ' the line causing the exception, while the Microsoft.VisualBasic.FileIO.TextFieldParser.ErrorLine - ' property is assigned the text contained in the line. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' The OpenTextFieldParser method allows you to create a Microsoft.VisualBasic.FileIO.TextFieldParser - ''' object, which provides a way to easily and efficiently parse structured text - ''' files, such as logs. The TextFieldParser object can be used to read both delimited - ''' and fixed-width files. - ''' - ''' The file to be opened with the TextFieldParser. - ''' Widths of the fields. - ''' Microsoft.VisualBasic.FileIO.TextFieldParser to read the specified file. - Public Function OpenTextFieldParser(file As String, ParamArray fieldWidths() As Integer) As TextFieldParser - Dim fileStream As New IO.RemoteFileStream(file, FileMode.Open, Me) - Dim parser As New TextFieldParser(fileStream, System.Text.Encoding.Default, True) - parser.FieldWidths = fieldWidths - Return parser - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The file name ends with a backslash (\). - ' - ' T:System.IO.FileNotFoundException: - ' The specified file cannot be found. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to read from the file. - ''' - ''' Opens a System.IO.StreamReader object to read from a file. - ''' - ''' File to be read. - ''' System.IO.StreamReader object to read from the file - Public Function OpenTextFileReader(file As String) As System.IO.StreamReader - Return OpenTextFileReader(file, Encoding.ASCII) - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The file name ends with a backslash (\). - ' - ' T:System.IO.FileNotFoundException: - ' The specified file cannot be found. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to read from the file. - ''' - ''' Opens a System.IO.StreamReader object to read from a file. - ''' - ''' File to be read. - ''' The encoding to use for the file contents. Default is ASCII. - ''' System.IO.StreamReader object to read from the file - Public Function OpenTextFileReader(file As String, encoding As Encoding) As System.IO.StreamReader - Dim fileStream As New IO.RemoteFileStream(file, FileMode.OpenOrCreate, Me) - Dim reader As New System.IO.StreamReader(fileStream, encoding) - Return reader - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The file name ends with a trailing slash. - ''' - ''' Opens a System.IO.StreamWriter object to write to the specified file. - ''' - ''' File to be written to. - ''' True to append to the contents of the file; False to overwrite the contents of - ''' the file. Default is False. - ''' System.IO.StreamWriter object to write to the specified file. - Public Function OpenTextFileWriter(file As String, append As Boolean) As System.IO.StreamWriter - Return OpenTextFileWriter(file, append, System.Text.Encoding.ASCII) - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The file name ends with a trailing slash. - ''' - ''' Opens a System.IO.StreamWriter to write to the specified file. - ''' - ''' File to be written to. - ''' True to append to the contents in the file; False to overwrite the contents of - ''' the file. Default is False. - ''' Encoding to be used in writing to the file. Default is ASCII. - ''' System.IO.StreamWriter object to write to the specified file. - Public Function OpenTextFileWriter(file As String, append As Boolean, encoding As Encoding) As System.IO.StreamWriter - Dim mode As FileMode = If(append, FileMode.Append, FileMode.OpenOrCreate) - Dim fileStream As New IO.RemoteFileStream(file, mode, Me) - Return New StreamWriter(fileStream, encoding) - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.OutOfMemoryException: - ' There is not enough memory to write the string to buffer. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Returns the contents of a file as a byte array. - ''' - ''' File to be read. - ''' Byte array containing the contents of the file. - Public Function ReadAllBytes(file As String) As Byte() - Dim fileStream As New IO.RemoteFileStream(file, FileMode.Open, Me) - Dim buffer As Byte() = New Byte(fileStream.Length - 1) {} - Call fileStream.Read(buffer, Scan0, buffer.Length) - Return buffer - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.OutOfMemoryException: - ' There is not enough memory to write the string to buffer. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - - ''' - ''' Returns the contents of a text file as a String. - ''' - ''' Name and path of the file to read. - ''' String containing the contents of the file. - Public Function ReadAllText(file As String) As String - Return ReadAllText(file, Encoding.ASCII) - End Function - - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' file is Nothing. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.OutOfMemoryException: - ' There is not enough memory to write the string to buffer. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ''' - ''' Returns the contents of a text file as a String. - ''' - ''' Name and path of the file to read. - ''' Character encoding to use in reading the file. Default is UTF-8. - ''' String containing the contents of the file. - Public Function ReadAllText(file As String, encoding As Encoding) As String - Dim reader = OpenTextFileReader(file, encoding) - Return reader.ReadToEnd - End Function - End Class -End Namespace diff --git a/ComputingServices/FileSystem/FileSystemHost.vb b/ComputingServices/FileSystem/FileSystemHost.vb deleted file mode 100644 index 1cb9cd3..0000000 --- a/ComputingServices/FileSystem/FileSystemHost.vb +++ /dev/null @@ -1,1029 +0,0 @@ -#Region "Microsoft.VisualBasic::02e9122e4b440986afba2eb45fa18f5f, ComputingServices\FileSystem\FileSystemHost.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class FileSystemHost - ' - ' Properties: OpenedHandles, Portal - ' - ' Constructor: (+1 Overloads) Sub New - ' Function: CloseHandle, CombinePath, CopyDirectory, CopyFile, CreateDirectory - ' CurrentDirectory, DeleteDirectory, DeleteFile, DirectoryExists, Drives - ' FileExists, FindInFiles, Flush, GetDirectories, GetDirectoryInfo - ' GetDriveInfo, GetFileInfo, GetFiles, GetName, GetParentPath - ' GetSetLength, GetSetPosition, GetStreamInfo, GetTempFileName, Lock - ' MoveDirectory, MoveFile, OpenFileHandle, ReadBuffer, RenameDirectory - ' RenameFile, Seek, WriteBuffer - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports Microsoft.VisualBasic.Linq -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Http -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Protocols.Reflection -Imports Microsoft.VisualBasic.Net.Tcp -Imports Microsoft.VisualBasic.Parallel -Imports Microsoft.VisualBasic.Serialization.JSON -Imports sciBASIC.ComputingServices.ComponentModel -Imports sciBASIC.ComputingServices.FileSystem.Protocols - -Namespace FileSystem - - - Public Class FileSystemHost : Inherits IHostBase - - ''' - ''' 远程服务器上面已经打开的文件句柄 - ''' - ''' - Public ReadOnly Property OpenedHandles As Dictionary(Of String, FileStream) = - New Dictionary(Of String, FileStream) - - ''' - ''' - ''' - ''' - Sub New(port As Integer) - Dim protocols As New ProtocolHandler(Me) - __host = New TcpServicesSocket(port) - __host.Responsehandler = AddressOf protocols.HandleRequest - Call RunTask(AddressOf __host.Run) - End Sub - - Public Overrides ReadOnly Property Portal As IPEndPoint - Get - Return New IPEndPoint(TcpRequest.LocalIPAddress, __host.LocalPort) - End Get - End Property - -#Region "FileStream" - - - - Private Function Lock(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim params As LockArgs = args.LoadObject(Of LockArgs) - Dim uid As String = params.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Call params.LockOrNot(stream) - Return NetResponse.RFC_OK - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function Seek(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim params As SeekArgs = args.LoadObject(Of SeekArgs) - Dim uid As String = params.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Dim l As Long = params.Seek(stream) - Dim value As RequestStream = RequestStream.CreatePackage(BitConverter.GetBytes(l)) - Return value - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function Flush(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim handle = args.GetUTF8String.LoadJSON(Of ReadBuffer) - Dim uid As String = handle.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Call stream.Flush() - Return NetResponse.RFC_OK - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function ReadBuffer(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim handle = args.GetUTF8String.LoadJSON(Of ReadBuffer) - Dim uid As String = handle.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Dim buffer As Byte() = handle.CreateBuffer - Dim n As Integer = stream.Read(buffer, handle.offset, handle.length) - Dim value As RequestStream = RequestStream.CreatePackage(buffer) - value.Protocol = CLng(n) - Return value - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function WriteBuffer(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim params As WriteStream = args.GetRawStream(Of WriteStream) - Dim uid As String = params.Handle.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Call stream.Write(params.buffer, params.offset, params.length) - Return NetResponse.RFC_OK - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - - Private Function OpenFileHandle(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim params As FileOpen = JsonContract.LoadJSON(Of FileOpen)(args.GetUTF8String) - Dim stream As FileStream = params.OpenHandle - Dim handle = FileStreamInfo.GetInfo(stream) - handle.FileName = params.FileName - Call OpenedHandles.Add(handle.Handle, stream) - Return New RequestStream(handle.GetJson) - End Function - - - Private Function GetStreamInfo(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim handle = args.GetUTF8String.LoadJSON(Of FileHandle) - Dim uid As String = handle.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Dim info As FileStreamInfo = FileStreamInfo.GetInfo(stream) - info.FileName = handle.FileName - Dim json As String = info.GetJson - Return New RequestStream(json) - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function CloseHandle(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim handle = args.GetUTF8String.LoadJSON(Of FileHandle) - Dim uid As String = handle.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - Call stream.Free - Call OpenedHandles.Remove(uid) - Return NetResponse.RFC_OK - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function GetSetPosition(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim params As FileStreamPosition = args.LoadObject(Of FileStreamPosition) - Dim uid As String = params.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - If params.Position = FileStreamPosition.GET Then - Return RequestStream.CreatePackage(stream.Position) - Else - stream.Position = params.Position - Return NetResponse.RFC_OK - End If - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function - - - Private Function GetSetLength(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim params As FileStreamPosition = args.LoadObject(Of FileStreamPosition) - Dim uid As String = params.Handle - If OpenedHandles.ContainsKey(uid) Then - Dim stream As FileStream = OpenedHandles(uid) - If params.Position = FileStreamPosition.GET Then - Return RequestStream.CreatePackage(stream.Length) - Else - stream.SetLength(params.Position) - Return NetResponse.RFC_OK - End If - Else - Return New RequestStream(Scan0, HTTP_RFC.RFC_TOKEN_INVALID, $"File handle {uid} is not opened!") - End If - End Function -#End Region - - ' Exceptions: - ' T:System.IO.DirectoryNotFoundException: - ' The path is not valid. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - ''' - ''' Gets or sets the current directory. - ''' - ''' - ''' - ''' - ''' The current directory for file I/O operations. - - Private Function CurrentDirectory(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim DIR As String = args.GetUTF8String - If String.IsNullOrEmpty(DIR) Then - DIR = FileIO.FileSystem.CurrentDirectory ' GET - Return New RequestStream(DIR) - Else - Try - FileIO.FileSystem.CurrentDirectory = DIR 'SET - Catch ex As Exception - Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_INTERNAL_SERVER_ERROR, ex.ToString) - End Try - - Return NetResponse.RFC_OK - End If - End Function - - ''' - ''' Returns a read-only collection of all available drive names. - ''' - ''' - ''' - ''' - ''' A read-only collection of all available drives as System.IO.DriveInfo objects. - - Private Function Drives(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim lst = FileIO.FileSystem.Drives.Select(Function(x) x.GetJson).ToArray - Return New RequestStream(lst.GetJson) - End Function - - ' Parameters: - ' sourceDirectoryName: - ' The directory to be copied. - ' - ' destinationDirectoryName: - ' The location to which the directory contents should be copied. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The new name specified for the directory contains a colon (:) or slash (\ or - ' /). - ' - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' destinationDirectoryName or sourceDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The source directory does not exist. - ' - ' T:System.IO.IOException: - ' The source directory is a root directory - ' - ' T:System.IO.IOException: - ' The combined path points to an existing file. - ' - ' T:System.IO.IOException: - ' The source path and target path are the same. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A folder name in the path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' A destination file exists but cannot be accessed. - ''' - ''' Copies the contents of a directory to another directory. - ''' - ''' - ''' - ''' - ''' - - Private Function CopyDirectory(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Copies a file to a new location. - ' - ' Parameters: - ' sourceFileName: - ' The file to be copied. - ' - ' destinationFileName: - ' The location to which the file should be copied. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' The system could not retrieve the absolute path. - ' - ' T:System.ArgumentException: - ' destinationFileName contains path information. - ' - ' T:System.ArgumentNullException: - ' destinationFileName or sourceFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The combined path points to an existing directory. - ' - ' T:System.IO.IOException: - ' The user does not have sufficient permissions to access the file. - ' - ' T:System.IO.IOException: - ' A file in the target directory with the same name is in use. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - Private Function CopyFile(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Creates a directory. - ' - ' Parameters: - ' directory: - ' Name and location of the directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The directory name is malformed. For example, it contains illegal characters - ' or is only white space. - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The directory name is too long. - ' - ' T:System.NotSupportedException: - ' The directory name is only a colon (:). - ' - ' T:System.IO.IOException: - ' The parent directory of the directory to be created is read-only - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have permission to create the directory. - Private Function CreateDirectory(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Deletes a directory. - ' - ' Parameters: - ' directory: - ' Directory to be deleted. - ' - ' onDirectoryNotEmpty: - ' Specifies what should be done when a directory that is to be deleted contains - ' files or directories. Default is DeleteDirectoryOption.DeleteAllContents. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is a zero-length string, is malformed, contains only white space, or - ' contains invalid characters (including wildcard characters). The path is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist or is a file. - ' - ' T:System.IO.IOException: - ' The directory is not empty, and onDirectoryNotEmpty is set to ThrowIfDirectoryNonEmpty. - ' - ' T:System.IO.IOException: - ' The user does not have permission to delete the directory or subdirectory. - ' - ' T:System.IO.IOException: - ' A file in the directory or subdirectory is in use. - ' - ' T:System.NotSupportedException: - ' The directory name contains a colon (:). - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.Security.SecurityException: - ' The user does not have required permissions. - ' - ' T:System.OperationCanceledException: - ' The user cancels the operation or the directory cannot be deleted. - Private Function DeleteDirectory(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - - - ' - ' Summary: - ' Deletes a file. - ' - ' Parameters: - ' file: - ' Name and path of the file to be deleted. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; it has a trailing - ' slash where a file must be specified; or it is a device path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' file is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.IOException: - ' The file is in use. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have permission to delete the file or the file is read-only. - Private Function DeleteFile(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Moves a directory from one location to another. - ' - ' Parameters: - ' sourceDirectoryName: - ' Path of the directory to be moved. - ' - ' destinationDirectoryName: - ' Path of the directory to which the source directory is being moved. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' The source is a root directory or The source path and the target path are the - ' same. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - Private Function MoveDirectory(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Moves a file to a new location. - ' - ' Parameters: - ' sourceFileName: - ' Path of the file to be moved. - ' - ' destinationFileName: - ' Path of the directory into which the file should be moved. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' destinationFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - Private Function MoveFile(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - - End Function - ' - ' Summary: - ' Renames a directory. - ' - ' Parameters: - ' directory: - ' Path and name of directory to be renamed. - ' - ' newName: - ' New name for directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' newName contains path information. - ' - ' T:System.ArgumentNullException: - ' directory is Nothing.-or-newName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' There is an existing file or directory with the name specified in newName. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds 248 characters. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - Private Function RenameDirectory(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Renames a file. - ' - ' Parameters: - ' file: - ' File to be renamed. - ' - ' newName: - ' New name of file. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' newName contains path information or ends with a backslash (\). - ' - ' T:System.ArgumentNullException: - ' file is Nothing.-or-newName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' There is an existing file or directory with the name specified in newName. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - Private Function RenameFile(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Combines two paths and returns a properly formatted path. - ' - ' Parameters: - ' baseDirectory: - ' String. First path to be combined. - ' - ' relativePath: - ' String. Second path to be combined. - ' - ' Returns: - ' The combination of the specified paths. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' baseDirectory or relativePath are malformed paths. - Private Function CombinePath(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns True if the specified directory exists. - ' - ' Parameters: - ' directory: - ' Path of the directory. - ' - ' Returns: - ' True if the directory exists; otherwise False. - Private Function DirectoryExists(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns True if the specified file exists. - ' - ' Parameters: - ' file: - ' Name and path of the file. - ' - ' Returns: - ' Returns True if the file exists; otherwise this method returns False. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The name of the file ends with a backslash (\). - Private Function FileExists(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns a read-only collection of strings representing the names of files containing - ' the specified text. - ' - ' Parameters: - ' directory: - ' The directory to be searched. - ' - ' containsText: - ' The search text. - ' - ' ignoreCase: - ' True if the search should be case-sensitive; otherwise False. Default is True. - ' - ' searchType: - ' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly. - ' - ' Returns: - ' Read-only collection of the names of files containing the specified text.. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The specified directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - Private Function FindInFiles(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Returns a collection of strings representing the path names of subdirectories - ' within a directory. - ' - ' Parameters: - ' directory: - ' Name and path of directory. - ' - ' Returns: - ' Read-only collection of the path names of subdirectories within the specified - ' directory.. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - Private Function GetDirectories(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - ' - ' Summary: - ' Returns a System.IO.DirectoryInfo object for the specified path. - ' - ' Parameters: - ' directory: - ' String. Path of directory. - ' - ' Returns: - ' System.IO.DirectoryInfo object for the specified path. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path - Private Function GetDirectoryInfo(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns a System.IO.DriveInfo object for the specified drive. - ' - ' Parameters: - ' drive: - ' Drive to be examined. - ' - ' Returns: - ' System.IO.DriveInfo object for the specified drive. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' drive is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path - Private Function GetDriveInfo(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns a System.IO.FileInfo object for the specified file. - ' - ' Parameters: - ' file: - ' Name and path of the file. - ' - ' Returns: - ' System.IO.FileInfo object for the specified file - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path name is malformed. For example, it contains invalid characters or is - ' only white space. The file name has a trailing slash mark. - ' - ' T:System.ArgumentNullException: - ' file is Nothing or an empty string. - ' - ' T:System.NotSupportedException: - ' The path contains a colon in the middle of the string. - ' - ' T:System.IO.PathTooLongException: - ' The path is too long. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks ACL (access control list) access to the file. - Private Function GetFileInfo(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns a read-only collection of strings representing the names of files within - ' a directory. - ' - ' Parameters: - ' directory: - ' Directory to be searched. - ' - ' Returns: - ' Read-only collection of file names from the specified directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory to search does not exist. - ' - ' T:System.IO.IOException: - ' directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - Private Function GetFiles(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - - - - ' - ' Summary: - ' Parses the file name out of the path provided. - ' - ' Parameters: - ' path: - ' Required. Path to be parsed. String. - ' - ' Returns: - ' The file name from the specified path. - Private Function GetName(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Returns the parent path of the provided path. - ' - ' Parameters: - ' path: - ' Path to be examined. - ' - ' Returns: - ' The parent path of the provided path. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' Path does not have a parent path because it is a root path. - ' - ' T:System.ArgumentNullException: - ' path is Nothing. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - Private Function GetParentPath(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - ' - ' Summary: - ' Creates a uniquely named zero-byte temporary file on disk and returns the full - ' path of that file. - ' - ' Returns: - ' String containing the full path of the temporary file. - Private Function GetTempFileName(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - - End Function - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Objects/DirectoryInfo.vb b/ComputingServices/FileSystem/Objects/DirectoryInfo.vb deleted file mode 100644 index 947b58d..0000000 --- a/ComputingServices/FileSystem/Objects/DirectoryInfo.vb +++ /dev/null @@ -1,59 +0,0 @@ -#Region "Microsoft.VisualBasic::36492bd31cd03dcecb89840dc9b70a6d, ComputingServices\FileSystem\Objects\DirectoryInfo.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class DirectoryInfo - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports System.Runtime.InteropServices -Imports System.Runtime.Serialization - -Namespace FileSystem - - ''' - ''' 表示本地或者远程文件系统对象上面的一个目录对象 - ''' - Public Class DirectoryInfo - - Sub New(info As System.IO.DirectoryInfo) - - End Sub - - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Objects/DriveInfo.vb b/ComputingServices/FileSystem/Objects/DriveInfo.vb deleted file mode 100644 index 555989f..0000000 --- a/ComputingServices/FileSystem/Objects/DriveInfo.vb +++ /dev/null @@ -1,173 +0,0 @@ -#Region "Microsoft.VisualBasic::9ef10319ded16d07938b6505bba5683c, ComputingServices\FileSystem\Objects\DriveInfo.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class DriveInfo - ' - ' Properties: AvailableFreeSpace, DriveFormat, DriveType, IsReady, Name - ' RootDirectory, TotalFreeSpace, TotalSize, VolumeLabel - ' - ' Constructor: (+2 Overloads) Sub New - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports System.Runtime.InteropServices -Imports System.Runtime.Serialization -Imports Microsoft.VisualBasic.Language - -Namespace FileSystem - - ''' - ''' Provides access to information on a drive. - ''' - Public NotInheritable Class DriveInfo - - Sub New(info As System.IO.DriveInfo) - Me.AvailableFreeSpace = info.AvailableFreeSpace - Me.DriveFormat = info.DriveFormat - Me.DriveType = info.DriveType - Me.IsReady = info.IsReady - Me.Name = info.Name - Me.RootDirectory = info.RootDirectory - Me.TotalFreeSpace = info.TotalFreeSpace - Me.TotalSize = info.TotalSize - Me.VolumeLabel = info.VolumeLabel - End Sub - - Sub New() - End Sub - - ' Exceptions: - ' T:System.UnauthorizedAccessException: - ' Access to the drive information is denied. - ' - ' T:System.IO.IOException: - ' An I/O error occurred (for example, a disk error or a drive was not ready). - ''' - ''' Indicates the amount of available free space on a drive, in bytes. - ''' - ''' The amount of free space available on the drive, in bytes. - Public Property AvailableFreeSpace As Long - - ' Exceptions: - ' T:System.UnauthorizedAccessException: - ' Access to the drive information is denied. - ' - ' T:System.IO.DriveNotFoundException: - ' The drive does not exist or is not mapped. - ' - ' T:System.IO.IOException: - ' An I/O error occurred (for example, a disk error or a drive was not ready). - ''' - ''' Gets the name of the file system, such as NTFS or FAT32. - ''' - ''' The name of the file system on the specified drive. - Public Property DriveFormat As String - - ''' - ''' Gets the drive type, such as CD-ROM, removable, network, or fixed. - ''' - ''' One of the enumeration values that specifies a drive type. - Public Property DriveType As DriveType - - ''' - ''' Gets a value that indicates whether a drive is ready. - ''' - ''' true if the drive is ready; false if the drive is not ready. - Public Property IsReady As Boolean - - ''' - ''' Gets the name of a drive, such as C:\. - ''' - ''' The name of the drive. - Public Property Name As String - - ''' - ''' Gets the root directory of a drive. - ''' - ''' An object that contains the root directory of the drive. - Public Property RootDirectory As System.IO.DirectoryInfo - - ' Exceptions: - ' T:System.UnauthorizedAccessException: - ' Access to the drive information is denied. - ' - ' T:System.IO.DriveNotFoundException: - ' The drive is not mapped or does not exist. - ' - ' T:System.IO.IOException: - ' An I/O error occurred (for example, a disk error or a drive was not ready). - ''' - ''' Gets the total amount of free space available on a drive, in bytes. - ''' - ''' The total free space available on a drive, in bytes. - Public Property TotalFreeSpace As Long - - ' Exceptions: - ' T:System.UnauthorizedAccessException: - ' Access to the drive information is denied. - ' - ' T:System.IO.DriveNotFoundException: - ' The drive is not mapped or does not exist. - ' - ' T:System.IO.IOException: - ' An I/O error occurred (for example, a disk error or a drive was not ready). - ''' - ''' Gets the total size of storage space on a drive, in bytes. - ''' - ''' The total size of the drive, in bytes. - Public Property TotalSize As Long - - ' Exceptions: - ' T:System.IO.IOException: - ' An I/O error occurred (for example, a disk error or a drive was not ready). - ' - ' T:System.IO.DriveNotFoundException: - ' The drive is not mapped or does not exist. - ' - ' T:System.Security.SecurityException: - ' The caller does not have the required permission. - ' - ' T:System.UnauthorizedAccessException: - ' The volume label is being set on a network or CD-ROM drive.-or-Access to the - ' drive information is denied. - ''' - ''' Gets or sets the volume label of a drive. - ''' - ''' The volume label. - Public Property VolumeLabel As String - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/FileHandle.vb b/ComputingServices/FileSystem/Protocols/FileHandle.vb deleted file mode 100644 index 4c69d79..0000000 --- a/ComputingServices/FileSystem/Protocols/FileHandle.vb +++ /dev/null @@ -1,87 +0,0 @@ -#Region "Microsoft.VisualBasic::29565e0839a1e3ff54d3cf4e55191e31, ComputingServices\FileSystem\Protocols\FileHandle.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class FileHandle - ' - ' Properties: FileName, Handle, HashCode - ' - ' Constructor: (+2 Overloads) Sub New - ' Function: ToString - ' - ' - ' /********************************************************************************/ - -#End Region - -Namespace FileSystem.Protocols - - ''' - ''' The file handle object on the remote server machine. - ''' (在远端服务器上面的文件句柄对象) - ''' - Public Class FileHandle - - ''' - ''' The file location on the remote file system. - ''' - ''' - Public Property FileName As String - ''' - ''' The hash code value on the remote services program. - ''' - ''' - Public Property HashCode As Integer - - Sub New() - End Sub - - Sub New(handle As FileHandle) - Me.FileName = handle.FileName - Me.HashCode = handle.HashCode - End Sub - - Public Overrides Function ToString() As String - Return Handle - End Function - - ''' - ''' 远程机器上面唯一标示的文件句柄值 - ''' - ''' - Public ReadOnly Property Handle As String - Get - Return $"{HashCode}+{FileName.ToFileURL}" - End Get - End Property - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/FileOpen.vb b/ComputingServices/FileSystem/Protocols/FileOpen.vb deleted file mode 100644 index b14a636..0000000 --- a/ComputingServices/FileSystem/Protocols/FileOpen.vb +++ /dev/null @@ -1,232 +0,0 @@ -#Region "Microsoft.VisualBasic::769f9f41ca2ca1d564d4532002c6307d, ComputingServices\FileSystem\Protocols\FileOpen.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class RenameArgs - ' - ' Properties: [New], old - ' - ' Class DeleteArgs - ' - ' Properties: [option], obj - ' - ' Class FileOpen - ' - ' Properties: Access, Mode - ' - ' Function: OpenHandle, ToString - ' - ' Class ReadBuffer - ' - ' Properties: length, offset - ' - ' Constructor: (+2 Overloads) Sub New - ' Function: (+2 Overloads) CreateBuffer - ' - ' Interface IReadWriteBuffer - ' - ' Properties: length, offset - ' - ' Class WriteStream - ' - ' Properties: buffer, Handle, length, offset - ' - ' Constructor: (+2 Overloads) Sub New - ' Function: CreateBuffer, Serialize - ' - ' Class FileStreamPosition - ' - ' Properties: Position - ' - ' Constructor: (+2 Overloads) Sub New - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports System.Text -Imports Microsoft.VisualBasic.Language -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Serialization.JSON - -Namespace FileSystem.Protocols - - Public Class RenameArgs - Public Property old As String - Public Property [New] As String - End Class - - Public Class DeleteArgs - Public Property obj As String - Public Property [option] As Integer - End Class - - ''' - ''' Initializes a new instance of the System.IO.FileStream class with the specified - ''' path and creation mode. - ''' - Public Class FileOpen : Inherits FileHandle - - ''' - ''' Specifies how the operating system should open a file. - ''' - ''' - Public Property Mode As Integer - Public Property Access As Integer = FileAccess.Read - - Public Overrides Function ToString() As String - Return $"[{DirectCast(Mode, FileMode).ToString }] " & FileName.ToFileURL - End Function - - ''' - ''' Initializes a new instance of the System.IO.FileStream class with the specified - ''' path and creation mode. - ''' - Public Function OpenHandle() As FileStream - Dim mode As FileMode = DirectCast(Me.Mode, FileMode) - Dim access As FileAccess = DirectCast(Me.Access, FileAccess) - Return New FileStream(FileName, mode, access) - End Function - End Class - - Public Class ReadBuffer : Inherits FileHandle - Implements IReadWriteBuffer - - Public Property offset As Integer Implements IReadWriteBuffer.offset - ''' - ''' 输入的参数的长度 - ''' - ''' - Public Property length As Integer Implements IReadWriteBuffer.length - - Sub New() - End Sub - - Sub New(handle As FileHandle) - Call MyBase.New(handle) - End Sub - - Public Function CreateBuffer() As Byte() - Return CreateBuffer(Me) - End Function - - Public Shared Function CreateBuffer(op As IReadWriteBuffer) As Byte() - Dim buffer As Byte() = New Byte(op.length + op.offset - 1) {} - Return buffer - End Function - End Class - - Public Interface IReadWriteBuffer - Property offset As Integer - Property length As Integer - End Interface - - Public Class WriteStream : Inherits RawStream - Implements IReadWriteBuffer - - Public Property Handle As FileHandle - Public Property length As Integer Implements IReadWriteBuffer.length - Public Property offset As Integer Implements IReadWriteBuffer.offset - Public Property buffer As Byte() - - Sub New() - End Sub - - Sub New(raw As Byte()) - Dim buf As Byte() = New Byte(INT32 - 1) {} - Dim p As VBInteger = Scan0 - Dim handleLen As Integer - Dim bufferLen As Integer - - Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : length = BitConverter.ToInt32(buf, Scan0) - Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : offset = BitConverter.ToInt32(buf, Scan0) - Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : handleLen = BitConverter.ToInt32(buf, Scan0) - Call Array.ConstrainedCopy(raw, p + INT32, buf, Scan0, INT32) : bufferLen = BitConverter.ToInt32(buf, Scan0) - - buf = New Byte(handleLen - 1) {} - Call Array.ConstrainedCopy(raw, p + handleLen, buf, Scan0, handleLen) - Dim json As String = Encoding.UTF8.GetString(buf) - Handle = json.LoadJSON(Of FileHandle) - buffer = New Byte(bufferLen - 1) {} - Call Array.ConstrainedCopy(raw, p, buffer, Scan0, bufferLen) - End Sub - - Public Overrides Function Serialize() As Byte() - Dim handle As Byte() = System.Text.Encoding.UTF8.GetBytes(Me.Handle.GetJson) - Dim length As Byte() = BitConverter.GetBytes(Me.length) - Dim offset As Byte() = BitConverter.GetBytes(Me.offset) - Dim chunkBuffer As Byte() = New Byte(INT32 + ' length - INT32 + ' offset - INT32 + ' handle length - INT32 + ' buffer length - handle.Length + - buffer.Length - 1) {} - Dim p As VBInteger = Scan0 - Dim handleLen As Byte() = BitConverter.GetBytes(handle.Length) - Dim bufferLen As Byte() = BitConverter.GetBytes(buffer.Length) - - Call Array.ConstrainedCopy(length, Scan0, chunkBuffer, p + INT32, INT32) - Call Array.ConstrainedCopy(offset, Scan0, chunkBuffer, p + INT32, INT32) - Call Array.ConstrainedCopy(handleLen, Scan0, chunkBuffer, p + INT32, INT32) - Call Array.ConstrainedCopy(bufferLen, Scan0, chunkBuffer, p + INT32, INT32) - Call Array.ConstrainedCopy(handle, Scan0, chunkBuffer, p + handle.Length, handle.Length) - Call Array.ConstrainedCopy(buffer, Scan0, chunkBuffer, p, buffer.Length) - - Return chunkBuffer - End Function - - Public Function CreateBuffer() As Byte() - Return ReadBuffer.CreateBuffer(Me) - End Function - End Class - - Public Class FileStreamPosition : Inherits FileHandle - - Public Const [GET] As Long = -100 - - ''' - ''' -100表示获取 - ''' - ''' - Public Property Position As Long = [GET] - - Sub New(handle As FileHandle) - Call MyBase.New(handle) - End Sub - - Sub New() - - End Sub - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/FileStreamInfo.vb b/ComputingServices/FileSystem/Protocols/FileStreamInfo.vb deleted file mode 100644 index 3b80a42..0000000 --- a/ComputingServices/FileSystem/Protocols/FileStreamInfo.vb +++ /dev/null @@ -1,135 +0,0 @@ -#Region "Microsoft.VisualBasic::972387fdd3296832e8c2ce0ad5d79fe5, ComputingServices\FileSystem\Protocols\FileStreamInfo.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class FileStreamInfo - ' - ' Properties: CanRead, CanSeek, CanWrite, FileHandle, IsAsync - ' - ' Constructor: (+1 Overloads) Sub New - ' Function: GetInfo - ' - ' Class SeekArgs - ' - ' Properties: offset, origin - ' - ' Constructor: (+2 Overloads) Sub New - ' Function: Seek - ' - ' Class LockArgs - ' - ' Properties: length, Lock, position - ' - ' Constructor: (+2 Overloads) Sub New - ' Sub: LockOrNot - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Protocols.Reflection -Imports Microsoft.VisualBasic.Serialization - -Namespace FileSystem.Protocols - - Public Class FileStreamInfo : Inherits FileHandle - - Public Property CanRead As Boolean - Public Property CanSeek As Boolean - Public Property CanWrite As Boolean - Public Property FileHandle As IntPtr - Public Property IsAsync As Boolean - - Sub New() - - End Sub - - Public Shared Function GetInfo(file As FileStream) As FileStreamInfo -#Disable Warning - Dim handle As New FileStreamInfo With { - .HashCode = file.GetHashCode, - .CanRead = file.CanRead, - .CanSeek = file.CanSeek, - .CanWrite = file.CanWrite, - .FileHandle = file.Handle, - .IsAsync = file.IsAsync - } ' 可能会出现重复的文件名,所以使用这个句柄对象来进行唯一标示 -#Enable Warning - Return handle - End Function - End Class - - Public Class SeekArgs : Inherits FileHandle - - Public Property offset As Long - Public Property origin As Integer - - Sub New(handle As FileHandle) - Call MyBase.New(handle) - End Sub - - Sub New() - - End Sub - - Public Function Seek(stream As System.IO.FileStream) As Long - Dim ori As SeekOrigin = CType(origin, SeekOrigin) - Return stream.Seek(offset, ori) - End Function - End Class - - Public Class LockArgs : Inherits FileHandle - - Public Property Lock As Boolean - Public Property position As Long - Public Property length As Long - - Sub New(handle As FileHandle) - Call MyBase.New(handle) - End Sub - - Sub New() - - End Sub - - Public Sub LockOrNot(stream As System.IO.FileStream) - If Lock Then - Call stream.Lock(position, length) - Else - Call stream.Unlock(position, length) - End If - End Sub - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/FileSystemAPI.vb b/ComputingServices/FileSystem/Protocols/FileSystemAPI.vb deleted file mode 100644 index 0369ca2..0000000 --- a/ComputingServices/FileSystem/Protocols/FileSystemAPI.vb +++ /dev/null @@ -1,789 +0,0 @@ -#Region "Microsoft.VisualBasic::25a2e448b3ecd884a4b8878d797fe957, ComputingServices\FileSystem\Protocols\FileSystemAPI.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Enum FileSystemAPI - ' - ' CloseHandle, CombinePath, CopyDirectory, CopyFile, CreateDirectory - ' CurrentDirectory, DeleteDirectory, DeleteFile, DirectoryExists, Drives - ' FileExists, FilePosition, FileStreamLength, FindInFiles, Flush - ' GetDirectories, GetDirectoryInfo, GetDriveInfo, GetFileInfo, GetFiles - ' GetFileStreamInfo, GetName, GetParentPath, GetTempFileName, MoveDirectory - ' MoveFile, OpenHandle, ReadBuffer, RenameDirectory, RenameFile - ' StreamLock, StreamSeek, WriteBuffer - ' - ' - ' - ' - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports Microsoft.VisualBasic.Net.Protocols.Reflection - -Namespace FileSystem.Protocols - - ''' - ''' 文件系统协议 - ''' - Public Enum FileSystemAPI As Long - - ''' - ''' 在服务器上面打开一个文件句柄 - ''' - OpenHandle - GetFileStreamInfo - ''' - ''' 获取或者得到文件流里面的指针的位置 - ''' - FilePosition - FileStreamLength - StreamSeek - StreamLock - ''' - ''' Reads a block of bytes from the stream and writes the data in a given buffer. - ''' - ReadBuffer - WriteBuffer - CloseHandle - Flush - ''' - ''' Gets or sets the current directory. - ''' - CurrentDirectory - - ''' - ''' Returns a read-only collection of all available drive names. - ''' - Drives - - ' - ' Summary: - ' Copies the contents of a directory to another directory. - ' - ' Parameters: - ' sourceDirectoryName: - ' The directory to be copied. - ' - ' destinationDirectoryName: - ' The location to which the directory contents should be copied. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The new name specified for the directory contains a colon (:) or slash (\ or - ' /). - ' - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' destinationDirectoryName or sourceDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The source directory does not exist. - ' - ' T:System.IO.IOException: - ' The source directory is a root directory - ' - ' T:System.IO.IOException: - ' The combined path points to an existing file. - ' - ' T:System.IO.IOException: - ' The source path and target path are the same. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A folder name in the path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' A destination file exists but cannot be accessed. - ''' - ''' Copies the contents of a directory to another directory. - ''' - CopyDirectory - - ' - ' Summary: - ' Copies a file to a new location. - ' - ' Parameters: - ' sourceFileName: - ' The file to be copied. - ' - ' destinationFileName: - ' The location to which the file should be copied. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' The system could not retrieve the absolute path. - ' - ' T:System.ArgumentException: - ' destinationFileName contains path information. - ' - ' T:System.ArgumentNullException: - ' destinationFileName or sourceFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The combined path points to an existing directory. - ' - ' T:System.IO.IOException: - ' The user does not have sufficient permissions to access the file. - ' - ' T:System.IO.IOException: - ' A file in the target directory with the same name is in use. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - CopyFile - - ' - ' Summary: - ' Creates a directory. - ' - ' Parameters: - ' directory: - ' Name and location of the directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The directory name is malformed. For example, it contains illegal characters - ' or is only white space. - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The directory name is too long. - ' - ' T:System.NotSupportedException: - ' The directory name is only a colon (:). - ' - ' T:System.IO.IOException: - ' The parent directory of the directory to be created is read-only - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have permission to create the directory. - CreateDirectory - ' - ' Summary: - ' Deletes a directory. - ' - ' Parameters: - ' directory: - ' Directory to be deleted. - ' - ' onDirectoryNotEmpty: - ' Specifies what should be done when a directory that is to be deleted contains - ' files or directories. Default is DeleteDirectoryOption.DeleteAllContents. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is a zero-length string, is malformed, contains only white space, or - ' contains invalid characters (including wildcard characters). The path is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist or is a file. - ' - ' T:System.IO.IOException: - ' The directory is not empty, and onDirectoryNotEmpty is set to ThrowIfDirectoryNonEmpty. - ' - ' T:System.IO.IOException: - ' The user does not have permission to delete the directory or subdirectory. - ' - ' T:System.IO.IOException: - ' A file in the directory or subdirectory is in use. - ' - ' T:System.NotSupportedException: - ' The directory name contains a colon (:). - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.Security.SecurityException: - ' The user does not have required permissions. - ' - ' T:System.OperationCanceledException: - ' The user cancels the operation or the directory cannot be deleted. - DeleteDirectory - - - ' - ' Summary: - ' Deletes a file. - ' - ' Parameters: - ' file: - ' Name and path of the file to be deleted. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; it has a trailing - ' slash where a file must be specified; or it is a device path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' file is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.IO.IOException: - ' The file is in use. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.IO.FileNotFoundException: - ' The file does not exist. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have permission to delete the file or the file is read-only. - DeleteFile - - ' - ' Summary: - ' Moves a directory from one location to another. - ' - ' Parameters: - ' sourceDirectoryName: - ' Path of the directory to be moved. - ' - ' destinationDirectoryName: - ' Path of the directory to which the source directory is being moved. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.ArgumentNullException: - ' sourceDirectoryName or destinationDirectoryName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' The source is a root directory or The source path and the target path are the - ' same. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.InvalidOperationException: - ' The operation is cyclic. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - MoveDirectory - ' - ' Summary: - ' Moves a file to a new location. - ' - ' Parameters: - ' sourceFileName: - ' Path of the file to be moved. - ' - ' destinationFileName: - ' Path of the directory into which the file should be moved. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\); it ends with a trailing slash. - ' - ' T:System.ArgumentNullException: - ' destinationFileName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The source file is not valid or does not exist. - ' - ' T:System.IO.IOException: - ' The file is in use by another process, or an I/O error occurs. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - MoveFile - ' - ' Summary: - ' Renames a directory. - ' - ' Parameters: - ' directory: - ' Path and name of directory to be renamed. - ' - ' newName: - ' New name for directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' newName contains path information. - ' - ' T:System.ArgumentNullException: - ' directory is Nothing.-or-newName is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' There is an existing file or directory with the name specified in newName. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds 248 characters. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - RenameDirectory - ' - ' Summary: - ' Renames a file. - ' - ' Parameters: - ' file: - ' File to be renamed. - ' - ' newName: - ' New name of file. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' newName contains path information or ends with a backslash (\). - ' - ' T:System.ArgumentNullException: - ' file is Nothing.-or-newName is Nothing or an empty string. - ' - ' T:System.IO.FileNotFoundException: - ' The directory does not exist. - ' - ' T:System.IO.IOException: - ' There is an existing file or directory with the name specified in newName. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user does not have required permission. - RenameFile - - ' - ' Summary: - ' Combines two paths and returns a properly formatted path. - ' - ' Parameters: - ' baseDirectory: - ' String. First path to be combined. - ' - ' relativePath: - ' String. Second path to be combined. - ' - ' Returns: - ' The combination of the specified paths. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' baseDirectory or relativePath are malformed paths. - CombinePath - ' - ' Summary: - ' Returns True if the specified directory exists. - ' - ' Parameters: - ' directory: - ' Path of the directory. - ' - ' Returns: - ' True if the directory exists; otherwise False. - DirectoryExists - ' - ' Summary: - ' Returns True if the specified file exists. - ' - ' Parameters: - ' file: - ' Name and path of the file. - ' - ' Returns: - ' Returns True if the file exists; otherwise this method returns False. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The name of the file ends with a backslash (\). - FileExists - ' - ' Summary: - ' Returns a read-only collection of strings representing the names of files containing - ' the specified text. - ' - ' Parameters: - ' directory: - ' The directory to be searched. - ' - ' containsText: - ' The search text. - ' - ' ignoreCase: - ' True if the search should be case-sensitive; otherwise False. Default is True. - ' - ' searchType: - ' Whether to include subfolders. Default is SearchOption.SearchTopLevelOnly. - ' - ' Returns: - ' Read-only collection of the names of files containing the specified text.. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The specified directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - FindInFiles - - ' - ' Summary: - ' Returns a collection of strings representing the path names of subdirectories - ' within a directory. - ' - ' Parameters: - ' directory: - ' Name and path of directory. - ' - ' Returns: - ' Read-only collection of the path names of subdirectories within the specified - ' directory.. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The specified directory does not exist. - ' - ' T:System.IO.IOException: - ' The specified directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - GetDirectories - - ' - ' Summary: - ' Returns a System.IO.DirectoryInfo object for the specified path. - ' - ' Parameters: - ' directory: - ' String. Path of directory. - ' - ' Returns: - ' System.IO.DirectoryInfo object for the specified path. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' The directory path contains a colon (:) or is in an invalid format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path - GetDirectoryInfo - ' - ' Summary: - ' Returns a System.IO.DriveInfo object for the specified drive. - ' - ' Parameters: - ' drive: - ' Drive to be examined. - ' - ' Returns: - ' System.IO.DriveInfo object for the specified drive. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' drive is Nothing or an empty string. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path - GetDriveInfo - ' - ' Summary: - ' Returns a System.IO.FileInfo object for the specified file. - ' - ' Parameters: - ' file: - ' Name and path of the file. - ' - ' Returns: - ' System.IO.FileInfo object for the specified file - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path name is malformed. For example, it contains invalid characters or is - ' only white space. The file name has a trailing slash mark. - ' - ' T:System.ArgumentNullException: - ' file is Nothing or an empty string. - ' - ' T:System.NotSupportedException: - ' The path contains a colon in the middle of the string. - ' - ' T:System.IO.PathTooLongException: - ' The path is too long. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks ACL (access control list) access to the file. - GetFileInfo - ' - ' Summary: - ' Returns a read-only collection of strings representing the names of files within - ' a directory. - ' - ' Parameters: - ' directory: - ' Directory to be searched. - ' - ' Returns: - ' Read-only collection of file names from the specified directory. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentNullException: - ' directory is Nothing. - ' - ' T:System.IO.DirectoryNotFoundException: - ' The directory to search does not exist. - ' - ' T:System.IO.IOException: - ' directory points to an existing file. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - ' - ' T:System.Security.SecurityException: - ' The user lacks necessary permissions to view the path. - ' - ' T:System.UnauthorizedAccessException: - ' The user lacks necessary permissions. - GetFiles - - ' - ' Summary: - ' Parses the file name out of the path provided. - ' - ' Parameters: - ' path: - ' Required. Path to be parsed. String. - ' - ' Returns: - ' The file name from the specified path. - GetName - ' - ' Summary: - ' Returns the parent path of the provided path. - ' - ' Parameters: - ' path: - ' Path to be examined. - ' - ' Returns: - ' The parent path of the provided path. - ' - ' Exceptions: - ' T:System.ArgumentException: - ' The path is not valid for one of the following reasons: it is a zero-length string; - ' it contains only white space; it contains invalid characters; or it is a device - ' path (starts with \\.\). - ' - ' T:System.ArgumentException: - ' Path does not have a parent path because it is a root path. - ' - ' T:System.ArgumentNullException: - ' path is Nothing. - ' - ' T:System.IO.PathTooLongException: - ' The path exceeds the system-defined maximum length. - ' - ' T:System.NotSupportedException: - ' A file or directory name in the path contains a colon (:) or is in an invalid - ' format. - GetParentPath - ' - ' Summary: - ' Creates a uniquely named zero-byte temporary file on disk and returns the full - ' path of that file. - ' - ' Returns: - ' String containing the full path of the temporary file. - GetTempFileName - End Enum -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/FileURI.vb b/ComputingServices/FileSystem/Protocols/FileURI.vb deleted file mode 100644 index 1f702c7..0000000 --- a/ComputingServices/FileSystem/Protocols/FileURI.vb +++ /dev/null @@ -1,133 +0,0 @@ -#Region "Microsoft.VisualBasic::ea59a5e11880b4d0f4759ad740bb81fe, ComputingServices\FileSystem\Protocols\FileURI.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class FileURI - ' - ' Properties: EntryPoint, File, IsLocal - ' - ' Constructor: (+3 Overloads) Sub New - ' - ' Function: ToString - ' - ' Sub: FileStreamParser - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.Text.RegularExpressions -Imports Microsoft.VisualBasic.Net - -Namespace FileSystem.Protocols - - ''' - ''' Represents a local file or remote file its location on the network. - ''' (表示一个本地文件或者网络上面的文件的位置) - ''' - Public Class FileURI - - ''' - ''' The services portal of this remote filesystem object. - ''' (远程文件服务对象的服务接口) - ''' - ''' - Public Property EntryPoint As IPEndPoint - ''' - ''' The reference location of this file system object on the target machine. - ''' (目标机器()上面的文件系统的引用的位置) - ''' - ''' - Public Property File As String - - ''' - ''' Is this file system object is a local file?.(是否为本地文件) - ''' - ''' - Public ReadOnly Property IsLocal As Boolean - Get - Return EntryPoint Is Nothing - End Get - End Property - - Sub New(uri As String) - Dim addr As String = Regex.Match(uri, "^\d+@\d+(\.\d+){3}[:]\/\/").Value - If String.IsNullOrEmpty(addr) Then '本地文件 - File = uri - EntryPoint = Nothing - Else ' 远程文件 - File = uri.Replace(addr, "") - Dim Tokens As String() = addr.Split(":"c).First.Split("@"c) - EntryPoint = New IPEndPoint(Tokens(1), Scripting.CTypeDynamic(Of Integer)(Tokens(Scan0))) - End If - End Sub - - Sub New(path As String, portal As IPEndPoint) - File = path - EntryPoint = portal - End Sub - - Sub New() - End Sub - - ''' - ''' {port}@{ipaddress}://C:\xxx\xxx.file - ''' - ''' - Public Overrides Function ToString() As String - If EntryPoint Is Nothing Then - Return File - Else - Return $"{EntryPoint.Port}@{EntryPoint.IPAddress}://{File}" - End If - End Function - - ''' - ''' port@remote_IP://hash+<path> - ''' - ''' - ''' - ''' - Public Shared Sub FileStreamParser(uri As String, ByRef remote As IPEndPoint, ByRef handle As FileHandle) - Dim file As New FileURI(uri) - remote = file.EntryPoint - uri = file.File - Dim hash As String = Regex.Match(uri, "^\d+\+").Value - uri = Mid(uri, hash.Length + 1) - handle = New FileHandle With { - .FileName = uri, - .HashCode = Scripting.CTypeDynamic(Of Integer)(hash) - } - End Sub - End Class -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/NetTransfer.vb b/ComputingServices/FileSystem/Protocols/NetTransfer.vb deleted file mode 100644 index edaac0d..0000000 --- a/ComputingServices/FileSystem/Protocols/NetTransfer.vb +++ /dev/null @@ -1,90 +0,0 @@ -#Region "Microsoft.VisualBasic::1c9ceb1759fb47880f8050db75993dff, ComputingServices\FileSystem\Protocols\NetTransfer.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Module NetTransfer - ' - ' Sub: Download, Transfer, Upload - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports System.Text.RegularExpressions -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Protocols.Reflection -Imports Microsoft.VisualBasic.Serialization - -Namespace FileSystem.Protocols - - Public Module NetTransfer - - ''' - ''' 从本地上传文件 - ''' - ''' - ''' - ''' - Public Sub Upload(local As String, destination As String, remote As IPEndPoint) - Using file As New IO.RemoteFileStream(destination, FileMode.OpenOrCreate, remote) - Dim localFile As New FileStream(local, FileMode.Open) - Call Transfer(localFile, file, 1024 * 1024) - End Using - End Sub - - Public Sub Transfer(source As Stream, target As Stream, bufLen As Integer) - Dim buffer As Byte() = New Byte(bufLen - 1) {} - - Do While source.Position < source.Length - Dim d As Integer = (source.Length - source.Position) - buffer.Length - - If d < 0 Then ' 注意:d 是负值的 - buffer = New Byte(-d - 1) {} - End If - - Call source.Read(buffer, Scan0, buffer.Length) - Call target.Write(buffer, Scan0, buffer.Length) - Call target.Flush() - Loop - End Sub - - Public Sub Download(destination As String, local As String, remote As IPEndPoint) - Using file As New IO.RemoteFileStream(destination, FileMode.OpenOrCreate, remote) - Dim localFile As New FileStream(local, FileMode.OpenOrCreate) - Call Transfer(file, localFile, 1024 * 1024) - End Using - End Sub - End Module -End Namespace diff --git a/ComputingServices/FileSystem/Protocols/Protocols.vb b/ComputingServices/FileSystem/Protocols/Protocols.vb deleted file mode 100644 index d356591..0000000 --- a/ComputingServices/FileSystem/Protocols/Protocols.vb +++ /dev/null @@ -1,92 +0,0 @@ -#Region "Microsoft.VisualBasic::aca05c9a4d4b828005757006ecd85b3b, ComputingServices\FileSystem\Protocols\Protocols.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Module API - ' - ' Properties: ProtocolEntry - ' - ' Function: GetSetLength, GetSetReadPosition, OpenHandle - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.IO -Imports System.Text.RegularExpressions -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Protocols.Reflection -Imports Microsoft.VisualBasic.Serialization - -Namespace FileSystem.Protocols - - ''' - ''' - ''' - Public Module API - - Public ReadOnly Property ProtocolEntry As Long = - New Protocol(GetType(FileSystemAPI)).EntryPoint - - Public Function OpenHandle(file As String, mode As FileMode, access As FileAccess) As RequestStream - Dim params As New FileOpen With { - .FileName = file, - .Mode = mode, - .Access = access - } - Return RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.OpenHandle, params) - End Function - - ''' - ''' - ''' - ''' -100表示set - ''' - ''' - Public Function GetSetReadPosition(pos As Long, handle As FileHandle) As RequestStream - Dim args As New FileStreamPosition(handle) With {.Position = pos} - Return RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.FilePosition, args) - End Function - - ''' - ''' - ''' - ''' - ''' - Public Function GetSetLength(length As Long, handle As FileHandle) As RequestStream - Dim args As New FileStreamPosition(handle) With {.Position = length} - Return RequestStream.CreateProtocol(ProtocolEntry, FileSystemAPI.FileStreamLength, args) - End Function - End Module -End Namespace diff --git a/ComputingServices/SharedMemory/HashValue.vb b/ComputingServices/SharedMemory/HashValue.vb deleted file mode 100644 index 9ecef0f..0000000 --- a/ComputingServices/SharedMemory/HashValue.vb +++ /dev/null @@ -1,125 +0,0 @@ -#Region "Microsoft.VisualBasic::c58483be8460f06ce344738ca838bb24, ComputingServices\SharedMemory\HashValue.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class HashValue - ' - ' Properties: Identifier, Type, value - ' - ' Constructor: (+1 Overloads) Sub New - ' Function: GetValueJson, ToString - ' - ' Structure Argv - ' - ' Properties: Identifier, value - ' - ' Constructor: (+1 Overloads) Sub New - ' Function: ToString - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic -Imports Microsoft.VisualBasic.Scripting.MetaData -Imports Microsoft.VisualBasic.Serialization -Imports Microsoft.VisualBasic.Serialization.JSON - -Namespace SharedMemory - - ''' - ''' The shared variable on the remote machine. - ''' - Public Class HashValue : Implements INamedValue - - ''' - ''' The variable name - ''' - ''' - Public Property Identifier As String Implements INamedValue.Key - ''' - ''' variable value - ''' - ''' - Public Property value As Object - ''' - ''' Simple type information - ''' - ''' - Public Property Type As TypeInfo - - Sub New(name As String, x As Object) - Identifier = name - value = x - Type = New TypeInfo(x.GetType) - End Sub - - ''' - ''' Json serialization for the network transfer. - ''' - ''' - Public Function GetValueJson() As String - Return JsonContract.GetObjectJson(value, Type.GetType(True)) - End Function - - Public Overrides Function ToString() As String - Return $"Dim {Identifier} As {Type.ToString} = {JsonContract.GetObjectJson(value, Type.GetType(True))}" - End Function - End Class - - ''' - ''' Variable value for the network transfer - ''' - Public Structure Argv : Implements INamedValue - - ''' - ''' The variable name - ''' - ''' - Public Property Identifier As String Implements INamedValue.Key - ''' - ''' Json value, and the type information is also included in this property. - ''' - ''' - Public Property value As TaskHost.Argv - - Sub New(name As String, x As Object) - Identifier = name - value = New TaskHost.Argv(x) - End Sub - - Public Overrides Function ToString() As String - Return Me.GetJson - End Function - End Structure -End Namespace diff --git a/ComputingServices/SharedMemory/MemoryServices.vb b/ComputingServices/SharedMemory/MemoryServices.vb deleted file mode 100644 index bc6f717..0000000 --- a/ComputingServices/SharedMemory/MemoryServices.vb +++ /dev/null @@ -1,149 +0,0 @@ -#Region "Microsoft.VisualBasic::f1497ae2c071750c405e5def5d49cd13, ComputingServices\SharedMemory\MemoryServices.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class MemoryServices - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' Function: [TypeOf], Allocate, GetValue, IsCompatible, Run - ' SetValue, ToString - ' - ' Sub: (+2 Overloads) Dispose - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports Microsoft.VisualBasic.ComponentModel -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Serialization.JSON - -Namespace SharedMemory - - ''' - ''' Shared the memory with the remote machine. - ''' - Public Class MemoryServices : Implements IDisposable - Implements ITaskDriver - - ''' - ''' Gets the memory data from remote machine. - ''' - ''' - ''' 建议使用NameOf来设置或者获取参数值 - ''' - Public Function GetValue(Of T)(name As String) As T - Return __remote.ReadValue(Of T)(name) - End Function - - ''' - ''' - ''' - ''' - ''' 建议使用NameOf来设置或者获取参数值 - ''' - ''' - Public Function SetValue(Of T)(name As String, value As T) As Boolean - Return __remote.WriteValue(name, value) - End Function - - Public Function [TypeOf](name As String) As Type - Return __remote.TypeOf(name) - End Function - - Public Function IsCompatible(Of T)(name As String, x As T) As Boolean - Dim type As Type = [TypeOf](name) - Dim ref As Type = GetType(T) - Return type.Equals(ref) OrElse ref.IsInheritsFrom(type) - End Function - - ReadOnly __remote As IPEndPoint - ReadOnly __localSvr As SharedSvr - - ''' - ''' - ''' - ''' - ''' local services port that provides to the remote - Sub New(remote As IPEndPoint, local As Integer) - __remote = remote - __localSvr = New SharedSvr(local) - End Sub - - Public Function Allocate(name As String, value As Object, Optional [overrides] As Boolean = False) As Boolean - Return __localSvr.Allocate(name, value, [overrides]) - End Function - - Public Overrides Function ToString() As String - Return __remote.GetJson - End Function - - Public Function Run() As Integer Implements ITaskDriver.Run - Return __localSvr.Run - End Function - -#Region "IDisposable Support" - Private disposedValue As Boolean ' To detect redundant calls - - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - ' TODO: dispose managed state (managed objects). - Call __localSvr.Dispose() - End If - - ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. - ' TODO: set large fields to null. - End If - Me.disposedValue = True - End Sub - - ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. - 'Protected Overrides Sub Finalize() - ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ' Dispose(False) - ' MyBase.Finalize() - 'End Sub - - ' This code added by Visual Basic to correctly implement the disposable pattern. - Public Sub Dispose() Implements IDisposable.Dispose - ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - Dispose(True) - ' TODO: uncomment the following line if Finalize() is overridden above. - ' GC.SuppressFinalize(Me) - End Sub -#End Region - End Class -End Namespace diff --git a/ComputingServices/SharedMemory/Protocols.vb b/ComputingServices/SharedMemory/Protocols.vb deleted file mode 100644 index 4028cca..0000000 --- a/ComputingServices/SharedMemory/Protocols.vb +++ /dev/null @@ -1,111 +0,0 @@ -#Region "Microsoft.VisualBasic::cd447f9172100e00081232e47d07a5e3, ComputingServices\SharedMemory\Protocols.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Module Protocols - ' - ' - ' Enum MemoryProtocols - ' - ' [TypeOf], Read, Write - ' - ' - ' - ' - ' - ' Properties: ProtocolEntry - ' - ' Function: [TypeOf], (+3 Overloads) ReadValue, (+2 Overloads) WriteValue - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports System.Runtime.CompilerServices -Imports Microsoft.VisualBasic.Net -Imports Microsoft.VisualBasic.Net.Http -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Protocols.Reflection -Imports Microsoft.VisualBasic.Net.Tcp -Imports Microsoft.VisualBasic.Scripting.MetaData -Imports Microsoft.VisualBasic.Serialization.JSON - -Namespace SharedMemory - - Module Protocols - - Public Enum MemoryProtocols - Read - Write - [TypeOf] - End Enum - - Public ReadOnly Property ProtocolEntry As Long = New Protocol(GetType(MemoryProtocols)).EntryPoint - - - Public Function [TypeOf](remote As IPEndPoint, name As String) As Type - Dim req As New RequestStream(ProtocolEntry, MemoryProtocols.TypeOf, name) - Dim ref As TypeInfo = req.LoadObject(Of TypeInfo) - Return ref.GetType(True) - End Function - - Public Function ReadValue(name As String) As RequestStream - Return New RequestStream(ProtocolEntry, MemoryProtocols.Read, name) - End Function - - Public Function WriteValue(name As String, value As Object) As RequestStream - Dim json As New Argv(name, value) - Dim req As New RequestStream(ProtocolEntry, MemoryProtocols.Write, json.GetJson) - Return req - End Function - - - Public Function ReadValue(remote As IPEndPoint, name As String, type As Type) As Object - Dim req As RequestStream = ReadValue(name) - Dim rep As RequestStream = New TcpRequest(remote).SendMessage(req) - Return JsonContract.LoadObject(rep.GetUTF8String, type) - End Function - - - Public Function ReadValue(Of T)(remote As IPEndPoint, name As String) As T - Return DirectCast(remote.ReadValue(name, GetType(T)), T) - End Function - - - Public Function WriteValue(remote As IPEndPoint, name As String, value As Object) As Boolean - Dim req As RequestStream = WriteValue(name, value) - Dim rep As RequestStream = New TcpRequest(remote).SendMessage(req) - Return rep.Protocol = HTTP_RFC.RFC_OK - End Function - End Module -End Namespace diff --git a/ComputingServices/SharedMemory/SharedSvr.vb b/ComputingServices/SharedMemory/SharedSvr.vb deleted file mode 100644 index d8e0f5d..0000000 --- a/ComputingServices/SharedMemory/SharedSvr.vb +++ /dev/null @@ -1,179 +0,0 @@ -#Region "Microsoft.VisualBasic::82604e6c81155abbea4b93f4ca4eb7ca, ComputingServices\SharedMemory\SharedSvr.vb" - - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class SharedSvr - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' Function: __typeOf, Allocate, Read, Run, ToString - ' Write - ' - ' Sub: (+2 Overloads) Dispose - ' - ' - ' /********************************************************************************/ - -#End Region - -Imports Microsoft.VisualBasic.ComponentModel -Imports Microsoft.VisualBasic.ComponentModel.Collection -Imports Microsoft.VisualBasic.Net.Http -Imports Microsoft.VisualBasic.Net.Protocols -Imports Microsoft.VisualBasic.Net.Protocols.Reflection -Imports Microsoft.VisualBasic.Net.Tcp -Imports Microsoft.VisualBasic.Scripting.MetaData -Imports Microsoft.VisualBasic.Serialization.JSON - -Namespace SharedMemory - - ''' - ''' Memory shared services. - ''' - ''' - - Public Class SharedSvr : Implements IDisposable - Implements ITaskDriver - - ReadOnly __localSvr As TcpServicesSocket - ''' - ''' 这个是提供给远程主机读取使用的 - ''' - ReadOnly __variables As New Dictionary(Of HashValue) - - Sub New(local As Integer) - __localSvr = New TcpServicesSocket(local) - __localSvr.Responsehandler = AddressOf New ProtocolHandler(Me).HandleRequest - End Sub - - ''' - ''' - ''' - ''' - ''' - ''' If the value type is not equals, overrides the exists value? - ''' Write or update the memory success? - Public Function Allocate(name As String, value As Object, Optional [overrides] As Boolean = False) As Boolean - If __variables.ContainsKey(name) Then - Dim x As HashValue = __variables ^ name - Dim type As Type = value.GetType - If type.Equals(x.value.GetType) Then - x.value = value - Else - If [overrides] Then - x.value = value - Else - Return False - End If - End If - Else - __variables.Add(name, New HashValue(name, value)) - End If - - Return True - End Function - - - Private Function __typeOf(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim name As String = args.GetUTF8String - Dim type As TypeInfo - - If __variables.ContainsKey(name) Then - type = __variables(name).Type - Else - type = New TypeInfo(GetType(Void)) - End If - - Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_OK, type.GetJson) - End Function - - - Private Function Read(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim name As String = args.GetUTF8String - - If __variables.ContainsKey(name) Then - Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_OK, __variables(name).GetValueJson) - Else - Return New RequestStream(HTTP_RFC.RFC_OK, HTTP_RFC.RFC_OK, "null") - End If - End Function - - - Private Function Write(CA As Long, args As RequestStream, remote As System.Net.IPEndPoint) As RequestStream - Dim value As Argv = args.LoadObject(Of Argv) - Dim b As Long = If(Allocate(value.Identifier, value.value.GetValue), HTTP_RFC.RFC_OK, HTTP_RFC.RFC_INTERNAL_SERVER_ERROR) - Return New RequestStream(b, b, CStr(b)) - End Function - - Public Overrides Function ToString() As String - Return __localSvr.ToString - End Function - - Public Function Run() As Integer Implements ITaskDriver.Run - Return __localSvr.Run - End Function - -#Region "IDisposable Support" - Private disposedValue As Boolean ' To detect redundant calls - - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - ' TODO: dispose managed state (managed objects). - Call __localSvr.Dispose() - Call __variables.Clear() - End If - - ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. - ' TODO: set large fields to null. - End If - Me.disposedValue = True - End Sub - - ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. - 'Protected Overrides Sub Finalize() - ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ' Dispose(False) - ' MyBase.Finalize() - 'End Sub - - ' This code added by Visual Basic to correctly implement the disposable pattern. - Public Sub Dispose() Implements IDisposable.Dispose - ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - Dispose(True) - ' TODO: uncomment the following line if Finalize() is overridden above. - ' GC.SuppressFinalize(Me) - End Sub -#End Region - End Class -End Namespace