/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
namespace Opc.Ua.Client.FileSystem
{
///
/// Configuration knobs for FileSystemClient,
/// UaFileStream and TemporaryFileTransferClient.
///
public sealed class FileSystemClientOptions
{
///
/// Default chunk size (in bytes) used by
/// UaFileStream.ReadAsync /
/// UaFileStream.WriteAsync when streaming to or from the
/// server. Honours the per-file
/// MaxByteStringLength property when known (clamped down
/// at open time). Default: 64 KiB.
///
public int ChunkSize { get; set; } = 64 * 1024;
///
/// Cap on the number of bytes a single
/// ReadAllBytesAsync / ReadAllTextAsync call may
/// load into memory. Reads that would exceed this size throw a
/// with
/// . Default:
/// 16 MiB.
///
public long MaxBufferedReadSize { get; set; } = 16 * 1024 * 1024;
///
/// Maximum number of resolved
/// (parent NodeId, browse name) → child NodeId entries
/// cached on the client. Set to zero to disable caching.
/// Default: 1024.
///
public int PathCacheSize { get; set; } = 1024;
///
/// When listing directory children, controls whether subtypes of
/// FileType (e.g. TrustListType,
/// AddressSpaceFileType) count as files. Default
/// true.
///
public bool IncludeFileTypeSubtypes { get; set; } = true;
///
/// When listing directory children, controls whether subtypes of
/// FileDirectoryType count as directories. Default
/// true.
///
public bool IncludeFileDirectoryTypeSubtypes { get; set; } = true;
///
/// Returns a deep copy of these options.
///
/// A new with the
/// same values.
public FileSystemClientOptions Clone()
{
return new FileSystemClientOptions
{
ChunkSize = ChunkSize,
MaxBufferedReadSize = MaxBufferedReadSize,
PathCacheSize = PathCacheSize,
IncludeFileTypeSubtypes = IncludeFileTypeSubtypes,
IncludeFileDirectoryTypeSubtypes = IncludeFileDirectoryTypeSubtypes
};
}
internal void Validate()
{
if (ChunkSize <= 0)
{
throw new ArgumentOutOfRangeException(
nameof(ChunkSize),
ChunkSize,
"ChunkSize must be positive.");
}
if (MaxBufferedReadSize <= 0)
{
throw new ArgumentOutOfRangeException(
nameof(MaxBufferedReadSize),
MaxBufferedReadSize,
"MaxBufferedReadSize must be positive.");
}
if (PathCacheSize < 0)
{
throw new ArgumentOutOfRangeException(
nameof(PathCacheSize),
PathCacheSize,
"PathCacheSize must be non-negative.");
}
}
}
}