NFSClient Component
Properties Methods Events Config Settings Errors
This component is used to create a Network File System (NFS) client based on NFS version 4.0.
Syntax
TipnNFSClient
Remarks
This component provides a simple way to create a Network File System (NFS) client, enabling seamless connection and access to files hosted on an NFS server.
Getting Started
To begin, the RemoteHost and RemotePort properties should first be set to the host and port of the NFS server. By default, the RemotePort property is set to 2049. The LocalHost and LocalPort properties may also be set to specify the name of the local host or user-assigned IP interface through which connections are initiated. Note that NFS exports may require that requests originate from a port less than 1024 (IPPORT_RESERVED). In this case, LocalPort should be manually specified.
The SecurityMechanism (and other related properties) may also be set beforehand. Please refer to the security section below for additional details.
Once set, the Connect method should be called to initiate a connection to the server. For example:
component.RemoteHost = "10.0.1.123";
component.RemotePort = 2049;
component.Connect();
Once the connection is successful (or fails), the Connected event will fire accordingly, with details regarding the connection status. Assuming the connection was successful, the Connected property will be set to True.
After successfully connecting to the NFS server, the RemotePath will always be set to the root from the components perspective, /.
If the server exports a specific directory (e.g., /mnt/mynfs), the component may need to navigate to this export manually by calling ChangeRemotePath with the relevant export path.
In some server-side configurations, the client may already start in the exported directory upon a connection, allowing immediate access without additional navigation.
Security
Before connecting to the server, the SecurityMechanism should be set accordingly. This property may be set to one of the following mechanisms:
Mechanism | Description |
none | No authentication is required to establish a connection to the server (AUTH_NONE or AUTH_NULL). |
sys | System authentication is required to establish a connection to the server (AUTH_SYS or AUTH_UNIX). |
krb5 | Kerberos v5 with client authentication only. |
krb5i | Kerberos v5 with client authentication and integrity protection. |
krb5p | Kerberos v5 with client authentication, integrity protection, and encryption. |
System Authentication
By default, SecurityMechanism is set to sys, enabling RPC system authentication (AUTH_SYS). In this case, the RPCUid and RPCGid properties are used to specify the UID and GID the component should perform the request as. These properties are set to 0 by default, indicating root access.
Note: This mechanism is not secure. Network packets are still transferred in plaintext. This mechanism is only recommended for systems operating over a local network.
Kerberos Authentication
For additional security, the SecurityMechanism may be set to krb5, krb5i, or krb5p to enable RPC Kerberos authentication (RPCSEC_GSS).
It is important to note the differences between the listed Kerberos security mechanisms. If krb5 is utilized, Kerberos will only be used to perform client authentication.
If krb5i is utilized, Kerberos will be used to perform client authentication and integrity protection, ensuring that incoming and outgoing packets are untampered. However, packets remain unencrypted, making sensitive data potentially visible to anyone monitoring the network.
If krb5p is utilized, Kerberos will be used to perform client authentication, integrity protection, and packet encryption, making this the most secure option.
If the security mechanism is set to any of the Kerberos security mechanisms, the following properties must also be set accordingly:
For example, connecting with a Kerberos security mechanism may look like:
// Configure general settings
nfsclient.RemoteHost = "10.0.1.223";
nfsclient.RemotePort = 2049;
nfsclient.SecurityMechanism = "krb5p";
// Configure kerberos settings
nfsclient.KDCHost = "10.0.1.226";
nfsclient.User = "nfsclient@EXAMPLE.COM";
nfsclient.SPN = "nfs/nfs-server.example.com";
nfsclient.KeytabFile = "C:\\nfsclient.keytab"; // alternative to 'Password'
nfsclient.Connect();
Navigating the Server
As mentioned previously, upon successfully connecting to the NFS server, the RemotePath will always be set to the root from the components perspective, /. ChangeRemotePath may or may not need to be called to navigate to the relevant server-side export.
Regardless, many methods operate based on the current working directory of the component as identified by RemotePath. For example, when calling ListDirectory, the directory contents of the current RemotePath will be listed.
As such, the ChangeRemotePath method can be used to change the current working directory of the component to some specified path. Both relative and absolute paths are supported with this method.
Absolute Paths
If the path begins with a /, it is considered an absolute path and must specify the entire path from the root of the server. For example:
component.ChangeRemotePath("/home/testuser/myfolder");
Relative Paths
If the path does not begin with a /, it is considered a relative path and is resolved in relation to the current directory. For instance, a value of myfolder will indicate a subfolder of the current directory. The special value .. refers to the parent directory of the current path. For example:
//Change to the 'myfolder' sub-directory
component.ChangeRemotePath("myfolder");
//Navigate up two levels and then into the 'another/folder' path.
component.ChangeRemotePath("../../another/folder");
Note that absolute and relative paths are supported for almost every component method that takes a file name and path as a parameter. Additionally, absolute and relative paths are supported by the RemoteFile property, which many methods make use of. For more information, please refer to the below section and individual method descriptions.
Managing Files and Directories
This section describes many different operations that can be performed on the NFS server. Before going into additional details, it is important to note that the behavior of many methods here operate depending on whether the specified RemoteFile or method parameter is an absolute or relative path.
If the specified RemoteFile or method parameter is an absolute path, the current RemotePath will be ignored in favor of the absolute path. However, if the specified RemoteFile or method parameter is a relative path, the operation will be performed relative to the current RemotePath.
File Lookup
To check whether a file or directory exists in the NFS server, the CheckFileExists method may be used. This method will search for the object specified by RemoteFile. For example:
// Relative Path
component.ChangeRemotePath("/home/testuser/myfolder");
component.RemoteFile = "test.txt";
// Checks for test.txt in /home/testuser/myfolder
if(component.CheckFileExists()) {
component.Download();
}
// Absolute Path
component.RemoteFile = "/home/test/test.txt";
// Checks for test.txt in /home/test
if(component.CheckFileExists()) {
component.Download();
}
Listing Directories
To list the contents of a directory, the ListDirectory method should be called to retrieve the entries of the current working directory (as indicated by the current RemotePath).
The DirList event will fire for each entry in the current directory. The RemoteFile property may be used to specify a file mask for filtering the entries returned via DirList.
For example:
// List all text files in /home/test
component.OnDirList += (o, e) => {
Console.WriteLine("Dir Entry: " + e.FileName);
};
component.ChangeRemotePath("/home/test");
component.RemoteFile = "*.txt";
component.ListDirectory();
Note: Because RemoteFile acts as a file mask, to retrieve a complete directory listing RemoteFile should be set to an empty string (or a mask like "*").
For more information about using RemoteFile as a filemask, please refer to the RemoteFile or ListDirectory documentation.
Create and Delete Objects
Files and directories may be created using CreateFile and MakeDirectory, respectively. Note that CreateFile is used to create a new file containing no data. To create a new file with content, please refer to the Upload method. For example:
// Create directory
component.MakeDirectory("testdir");
// Create empty file in new directory
component.ChangeRemotePath("testdir");
component.CreateFile("test.txt");
Files and directories may be deleted using DeleteFile and RemoveDirectory, respectively. For example (based on the previous directory structure in the last example):
// Remove file created previously
component.ChangeRemotePath("testdir");
component.DeleteFile("test.txt");
// Navigate out of directory
component.ChangeRemotePath("../");
component.RemoveDirectory("testdir");
Uploading Files
As mentioned, CreateFile may be used to create a new, empty file. To upload a file with content, the Upload method should be used. The RemoteFile property will specify the remote location to upload the local data to. If the RemoteFile exists and Overwrite is set to false, an error will occur while uploading.
The component can either upload the specified LocalFile, or upload the contents of a stream, which can be set via SetUploadStream. When uploading via a stream, the CloseStreamAfterTransfer config may be set to determine whether or not to close the stream after the transfer (enabled by default).
As an alternative to Upload, the UploadRange method may be used to upload a specified number of bytes to a given position in the RemoteFile. This method can also be used to append data to the end of a file, however, the Append method may be also be used for this purpose. For specific examples, please refer to the documentation for each method.
Downloading Files
To download the content of a file hosted on the server, the Download method should be used. The RemoteFile property should be set to the remote file to download. The LocalFile property can be used to specify a local file to download the specified remote file to. If the LocalFile already exists and Overwrite is false, an error will occur.
The component can either download the remote file contents to the specified LocalFile, or download the contents to a stream, which can be set via SetDownloadStream. When downloading via a stream, the CloseStreamAfterTransfer config may be set to determine whether or not to close the stream after the transfer (enabled by default).
As an alternative to Download, the DownloadRange method may be used to download a specified number of bytes to some local buffer.
Lastly, as an alternative to LocalFile or SetDownloadStream, the downloaded file contents are also available in the Transfer event. Note the Transfer event will always fire containing the transferred data, so data may be retrieved here even if LocalFile is set or SetDownloadStream is called. For specific examples, please refer to the documentation for each method.
Creating and Reading Links
The component supports creating hard links and symbolic links using the CreateLink method.
CreateLink takes three parameters, the name of the link to be created, the target of the link, and the type of link (hard link or symbolic link). Please see below for a simple example:
nfs.ChangeRemotePath("/nfs");
// Create symlink.txt in /nfs pointing to existing_file.txt in the same directory
nfs.CreateLink("symlink.txt", "existing_file.txt", 0);
// Create hardlink.txt in /nfs pointing to existing_file.txt in the same directory
nfs.CreateLink("hardlink.txt", "existing_file.txt", 1);
To read a hard link, you can set the RemoteFile property to the name of the hard link, and call Download (with the relevant local file or stream set).
However, reading a symbolic link requires some additional steps. First, the ReadLink method should be called, which will return a byte array containing the contents of the symbolic link as stored on the server. Typically, the contents are a file name that the link points to. Before going into detail, please see below for a simple example:
nfs.ChangeRemotePath("/nfs");
// Create symlink.txt in /nfs pointing to existing_file.txt in the same directory
nfs.CreateLink("symlink.txt", "existing_file.txt", 0);
// Read link
byte[] linkData = nfs.ReadLink("symlink.txt");
string file = Encoding.UTF8.GetString(linkData);
nfs.RemoteFile = file;
nfs.LocalFile = "temp.txt";
nfs.Download();
In NFS v4.0, the contents of a symbolic link are treated as opaque (binary data) at the protocol level. The server stores this opaque data and returns this to the client when requested, meaning it is up to the client to interpret the link data.
Most of the time, the opaque data will represent the file the symbolic link is pointing to relative to the position of the symbolic link, meaning it can be converted to a UTF8 string representing this file. The contents of the file should then be downloaded by setting RemoteFile (and possibly RemotePath) accordingly and calling Download.
Handling File Attributes
The component provides a couple of ways to handle file attributes. As mentioned previously, when calling ListDirectory, the DirList event will fire for each directory entry. During this event, the FileAttributes collection will be populated with the attributes of the associated directory entry. Note that the attributes are only meant to be retrieved during this event, rather than set.
Outside of DirList, the QueryFileAttributes method must be called to retrieve a file's attributes. After doing so, the FileAttributes property will be populated accordingly.
To update relevant file attributes, the FileAttributes property can be modified, and UpdateFileAttributes can be called to make those changes remotely. Note that not all attributes are able to be modified. Please see below for a simple example:
// First, query attributes
component.RemoteFile = "/home/test/test.txt";
component.QueryFileAttributes();
// Update OwnerId and OwnerGroupId of file
component.FileAttributes.OwnerId = "1000";
component.FileAttributes.OwnerGroupId = "1000";
component.UpdateFileAttributes();
Property List
The following is the full list of the properties of the component with short descriptions. Click on the links for further details.
Connected | Whether the component is connected. |
FileAttributes | The attributes of the RemoteFile . |
Firewall | A set of properties related to firewall access. |
KDCHost | Specifies domain name or IP address of the Key Distribution Center (KDC). |
KDCPort | Specifies the port for the Key Distribution Center (KDC). |
KeytabFile | Specifies the path to the Kerberos Keytab file. |
LocalFile | This is the path to a local file for download or upload. If the file exists, it is overwritten. |
LocalHost | The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
LocalPort | The TCP port in the local host where the component binds. |
Overwrite | This indicates whether the component should overwrite the local or remote file during a download or upload. |
Password | Specifies the password of the User to authenticate. |
RemoteFile | This is the name of the remote file for uploading, downloading, and performing other operations. |
RemoteHost | Specifies the address of the NFS server. |
RemotePath | Specifies the current path in the NFS server. |
RemotePort | Specifies the port the NFS server is listening on. |
RPCGid | Specifies the group identifier (GID) associated with requests during RPC system authentication. |
RPCUid | Specifies the user identifier (UID) associated with requests during RPC system authentication. |
SecurityMechanism | Specifies the RPC security mechanism the client should use when connecting to the NFS Server. |
SPN | Specifies the Service Principal Name (SPN). |
StartByte | The offset in bytes at which to begin the Upload or Download. |
Timeout | This property includes the timeout for the component. |
User | Specifies the name and domain of the user to authenticate. |
Method List
The following is the full list of the methods of the component with short descriptions. Click on the links for further details.
Abort | Aborts the current upload or download. |
Append | Appends data from LocalFile to a remote file RemoteFile on a NFS server. |
ChangeRemotePath | Changes the current path on the server. |
CheckFileExists | Checks whether the file specified by RemoteFile exists on the server. |
Config | Sets or retrieves a configuration setting. |
Connect | This method connects to the NFS server. |
CreateFile | Creates a file on the NFS server. |
CreateLink | Creates a hard link or symbolic link on the server. |
DeleteFile | This method removes a file specified by FileName from the server. |
Disconnect | This method disconnects from the NFS server. |
DoEvents | This method processes events from the internal message queue. |
Download | This method downloads a remote file from the NFS server. |
DownloadRange | This method downloads a specific segment of a remote file from a NFS server. |
ListDirectory | This method lists the current working directory on the NFS server. |
MakeDirectory | This method is used to create a directory on the NFS server. |
QueryFileAttributes | This method queries the server for the file attributes of the specified RemoteFile . |
ReadLink | Reads a symbolic link on the server. |
RemoveDirectory | This removes a directory specified by DirName from the NFS server. |
RenameFile | This changes the name of RemoteFile to NewName . |
Reset | This method will reset the component. |
SetDownloadStream | This method sets the stream to which the downloaded data from the server will be written. |
SetUploadStream | This method sets the stream from which the component will read data to upload to the server. |
UpdateFileAttributes | This method updates the FileAttributes for the current RemoteFile . |
Upload | This method uploads a file to the NFS server. |
UploadRange | This method uploads a specific segment of data into a remote file on the NFS server. |
Event List
The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.
Connected | Fired immediately after a connection completes (or fails). |
DirList | This event fires when a directory entry is received. |
Disconnected | This event is fired when a connection is closed. |
EndTransfer | This event is fired when a file finishes uploading or downloading. |
Error | Fired when information is available about errors during data delivery. |
Log | This event is fired once for each log message. |
StartTransfer | This event is fired when a file starts uploading or downloading. |
Transfer | This event is fired during the file download or upload. |
Config Settings
The following is a list of config settings for the component with short descriptions. Click on the links for further details.
AppendToLocalFile | Whether to append downloaded files to a local file. |
ClientIDSeek | Specifies some identifier used when creating the client ID associated with the current connection. |
DirCountSize | Specifies the maximum number of bytes that may be returned in a single READDIR request. |
FileTimeFormat | Specifies the format to use when returning filetime strings. |
MaxReadBytes | Indicates the maximum number of bytes that will be returned in one READ operation. |
MaxWriteBytes | Indicates the maximum number of bytes that will be written in one WRITE operation. |
OpenOwner | Specifies an opaque string representing the client when opening a file. |
RPCAuxiliaryGids | Specifies the Auxiliary GIDs (or groups) the client is a part of. |
RPCHostname | Specifies the host (or machine) name of the client. |
STMask | Specifies the default file mode (or permission) bits to exclude when creating a file. |
UsePlatformKerberosAPI | Whether to use the platform Kerberos API. |
XAttrCountSize | Specifies the maximum number of bytes that may be returned in a single LISTXATTRS request. |
BuildInfo | Information about the product's build. |
CodePage | The system code page used for Unicode to Multibyte translations. |
LicenseInfo | Information about the current license. |
MaskSensitiveData | Whether sensitive data is masked in log messages. |
UseInternalSecurityAPI | Whether or not to use the system security libraries or an internal implementation. |
Connected Property (NFSClient Component)
Whether the component is connected.
Syntax
property Connected: Boolean read get_Connected;
Default Value
false
Remarks
This property is used to determine whether or not the component is connected to the remote host. Use the Connect and Disconnect methods to manage the connection.
This property is read-only and not available at design time.
FileAttributes Property (NFSClient Component)
The attributes of the RemoteFile .
Syntax
property FileAttributes: TipnNFSFileAttributes read get_FileAttributes write set_FileAttributes;
Remarks
This property holds the attributes for the file specified by RemoteFile. Before querying this property, first call QueryFileAttributes to retrieve the attributes from the server.
To modify the attributes of the file, you may set FileAttributes and then call UpdateFileAttributes.
Note that this property will also be populated during the ListDirectory operation, and are made temporarily available within the DirList event.
This property is not available at design time.
Please refer to the NFSFileAttributes type for a complete list of fields.Firewall Property (NFSClient Component)
A set of properties related to firewall access.
Syntax
property Firewall: TipnFirewall read get_Firewall write set_Firewall;
Remarks
This is a Firewall-type property, which contains fields describing the firewall through which the component will attempt to connect.
Please refer to the Firewall type for a complete list of fields.KDCHost Property (NFSClient Component)
Specifies domain name or IP address of the Key Distribution Center (KDC).
Syntax
property KDCHost: String read get_KDCHost write set_KDCHost;
Default Value
''
Remarks
This property specifies the domain name or IP address of the Key Distribution Center (KDC).
If this property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, this property is set to the corresponding address. If the search is not successful, an error is returned.
Note that this property is only applicable when SecurityMechanism is set to krb5, krb5i, or krb5p.
KDCPort Property (NFSClient Component)
Specifies the port for the Key Distribution Center (KDC).
Syntax
property KDCPort: Integer read get_KDCPort write set_KDCPort;
Default Value
88
Remarks
This property specifies the port for the Key Distribution Center (KDC). The default value is 88.
Note that this property is only applicable when SecurityMechanism is set to krb5, krb5i, or krb5p.
KeytabFile Property (NFSClient Component)
Specifies the path to the Kerberos Keytab file.
Syntax
property KeytabFile: String read get_KeytabFile write set_KeytabFile;
Default Value
''
Remarks
This property specifies the path to a Kerberos Keytab file.
If specified, the credentials for a specific User are read from this file, assuming an entry for the user exists in the file. The Password should not be specified if using a Keytab file.
Note that this property is only applicable when SecurityMechanism is set to krb5, krb5i, or krb5p.
LocalFile Property (NFSClient Component)
This is the path to a local file for download or upload. If the file exists, it is overwritten.
Syntax
property LocalFile: String read get_LocalFile write set_LocalFile;
Default Value
''
Remarks
This property is used by the Upload and Download methods to specify the path to a local file to be downloaded or uploaded. See the method descriptions for more information.
Example (Setting LocalFile)
// Download remotefile.txt to C:\\localfile.txt
component.LocalFile = "C:\\localfile.txt";
component.RemoteFile = "remotefile.txt";
component.Download();
// Upload C:\\localfile2.txt to folder/remotefile2.txt
component.LocalFile = "C:\\localfile2.txt";
component.RemoteFile = "folder/remotefile2.txt";
component.Upload();
LocalHost Property (NFSClient Component)
The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
Syntax
property LocalHost: String read get_LocalHost write set_LocalHost;
Default Value
''
Remarks
This property contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.
In multihomed hosts (machines with more than one IP interface) setting LocalHost to the IP address of an interface will make the component initiate connections (or accept in the case of server components) only through that interface. It is recommended to provide an IP address rather than a hostname when setting this property to ensure the desired interface is used.
If the component is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).
Note: LocalHost is not persistent. You must always set it in code, and never in the property window.
LocalPort Property (NFSClient Component)
The TCP port in the local host where the component binds.
Syntax
property LocalPort: Integer read get_LocalPort write set_LocalPort;
Default Value
0
Remarks
This property must be set before a connection is attempted. It instructs the component to bind to a specific port (or communication endpoint) in the local machine.
Setting this property to 0 (default) enables the system to choose an open port at random. The chosen port will be returned by the LocalPort property after the connection is established.
LocalPort cannot be changed once a connection is made. Any attempt to set this property when a connection is active will generate an error.
This property is useful when trying to connect to services that require a trusted port on the client side.
Note: NFS exports may require that requests originate from a port less than 1024 (IPPORT_RESERVED). In this case, this property should be manually specified.
Overwrite Property (NFSClient Component)
This indicates whether the component should overwrite the local or remote file during a download or upload.
Syntax
property Overwrite: Boolean read get_Overwrite write set_Overwrite;
Default Value
false
Remarks
This property indicates whether the component should overwrite any local or remote files when calling Download, Upload, or CreateFile.
When uploading and Overwrite is false, an error will be thrown if the specified RemoteFile exists. When true, the RemoteFile will be overwritten.
When downloading and Overwrite is false, an error will be thrown if the specified LocalFile exists. When true, the LocalFile will be overwritten.
Password Property (NFSClient Component)
Specifies the password of the User to authenticate.
Syntax
property Password: String read get_Password write set_Password;
Default Value
''
Remarks
This property specifies the password of the User to authenticate.
Note that this property is only applicable when SecurityMechanism is set to krb5, krb5i, or krb5p.
RemoteFile Property (NFSClient Component)
This is the name of the remote file for uploading, downloading, and performing other operations.
Syntax
property RemoteFile: String read get_RemoteFile write set_RemoteFile;
Default Value
''
Remarks
This property contains the name of the remote file to be uploaded or downloaded and is either an absolute file path or a relative path based on the remote path set by calling ChangeRemotePath.
A number of methods use RemoteFile as an argument.
Example 1. Setting RemoteFile:
component.LocalFile = "C:\\localfile.txt";
component.RemoteFile = "remotefile.txt";
component.Download();
component.LocalFile = "C:\\localfile2.txt";
component.RemoteFile = "folder/remotefile2.txt";
component.Download();
Note: This property will also act as a file mask when calling ListDirectory.
Example 2. Using RemoteFile as a file mask:
component.RemoteFile = "*.txt"
component.ListDirectory()
The following special characters are supported for pattern matching:
? | Any single character. |
* | Any characters or no characters (e.g., C*t matches Cat, Cot, Coast, Ct). |
[,-] | A range of characters (e.g., [a-z], [a], [0-9], [0-9,a-d,f,r-z]). |
\ | The slash is ignored and exact matching is performed on the next character. |
If these characters need to be used as a literal in a pattern, then they must be escaped by surrounding them with brackets []. Note: "]" and "-" do not need to be escaped. See below for the escape sequences:
Character | Escape Sequence |
? | [?] |
* | [*] |
[ | [[] |
\ | [\] |
For example, to match the value [Something].txt, specify the pattern [[]Something].txt.
RemoteHost Property (NFSClient Component)
Specifies the address of the NFS server.
Syntax
property RemoteHost: String read get_RemoteHost write set_RemoteHost;
Default Value
''
Remarks
This property specifies the IP address (IP number in dotted internet format) or the domain name of the NFS server. It is set before a connection is attempted and should not be changed once a connection is established.
RemotePath Property (NFSClient Component)
Specifies the current path in the NFS server.
Syntax
property RemotePath: String read get_RemotePath;
Default Value
''
Remarks
This property specifies the current working directory on the NFS server. The ChangeRemotePath method can be used to change the working directory to an absolute path or to a relative path with respect to the current value of RemotePath.
Example. Changing Directory:
component.RemoteHost = "nfs.server.net";
component.RemotePort = 2049;
component.Connect();
component.ChangeRemotePath("/home/user");
Console.WriteLine(component.RemotePath); // Outputs "/home/user"
This property is read-only.
RemotePort Property (NFSClient Component)
Specifies the port the NFS server is listening on.
Syntax
property RemotePort: Integer read get_RemotePort write set_RemotePort;
Default Value
2049
Remarks
This property specifies the port the NFS server is listening on (i.e., the port the component will connect to).By default, this value is 2049.
A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed once a connection is established. Any attempt to change this property while connected will fail with an error.
This property is not available at design time.
RPCGid Property (NFSClient Component)
Specifies the group identifier (GID) associated with requests during RPC system authentication.
Syntax
property RPCGid: Integer read get_RPCGid write set_RPCGid;
Default Value
0
Remarks
This property specifies the group identifier (GID) associated with requests during RPC system authentication (AUTH_SYS).
The specified GID will be sent in all outgoing requests in order to identify the relevant primary group of the user making the request. The user can be identified by the RPCUid property.
Note this property is only applicable when SecurityMechanism is set to sys.
RPCUid Property (NFSClient Component)
Specifies the user identifier (UID) associated with requests during RPC system authentication.
Syntax
property RPCUid: Integer read get_RPCUid write set_RPCUid;
Default Value
0
Remarks
This property specifies the user identifier (UID) associated with requests during RPC system authentication (AUTH_SYS).
The specified UID will be sent in all outgoing requests in order to identify the user making the request.
Note this property is only applicable when SecurityMechanism is set to sys.
SecurityMechanism Property (NFSClient Component)
Specifies the RPC security mechanism the client should use when connecting to the NFS Server.
Syntax
property SecurityMechanism: String read get_SecurityMechanism write set_SecurityMechanism;
Default Value
'sys'
Remarks
This property specifies the RPC security mechanism the client should use when connecting to the NFS server.
This property may be set to one of the following mechanisms:
Mechanism | Description |
none | No authentication is required to establish a connection to the server (AUTH_NONE or AUTH_NULL). |
sys | System authentication is required to establish a connection to the server (AUTH_SYS or AUTH_UNIX). |
krb5 | Kerberos v5 with client authentication only. |
krb5i | Kerberos v5 with client authentication and integrity protection. |
krb5p | Kerberos v5 with client authentication, integrity protection, and encryption. |
By default, this property is set to sys, and only system authentication is supported. When set to sys, the following properties may be set to specify the UID and GID the component should perform the request as:
Kerberos Security Mechanisms
It is important to note the differences between the listed Kerberos security mechanisms. If krb5 is utilized, Kerberos will only be used to perform client authentication.
If krb5i is utilized, Kerberos will be used to perform client authentication and integrity protection, ensuring that incoming and outgoing packets are untampered. However, packets remain unencrypted, making sensitive data potentially visible to anyone monitoring the network.
If krb5p is utilized, Kerberos will be used to perform client authentication, integrity protection, and packet encryption, making this the most secure option.
If the security mechanism is set to any of the Kerberos security mechanisms, the following properties must also be set accordingly:
For example, connecting with a Kerberos security mechanism may look like:
// Configure general settings
nfsclient.RemoteHost = "10.0.1.223";
nfsclient.RemotePort = 2049;
nfsclient.SecurityMechanism = "krb5p";
// Configure kerberos settings
nfsclient.KDCHost = "10.0.1.226";
nfsclient.User = "nfsclient@EXAMPLE.COM";
nfsclient.SPN = "nfs/nfs-server.example.com";
nfsclient.KeytabFile = "C:\\nfsclient.keytab"; // alternative to 'Password'
nfsclient.Connect();
SPN Property (NFSClient Component)
Specifies the Service Principal Name (SPN).
Syntax
property SPN: String read get_SPN write set_SPN;
Default Value
''
Remarks
This property specifies the Service Principal Name (SPN) that the User is attempting to access. This should be set to the SPN of the remote NFS Server, if applicable.
Note that this property is only applicable when SecurityMechanism is set to krb5, krb5i, or krb5p.
StartByte Property (NFSClient Component)
The offset in bytes at which to begin the Upload or Download.
Syntax
property StartByte: Int64 read get_StartByte write set_StartByte;
Default Value
0
Remarks
The StartByte property is used by the Upload and Download methods to determine at what offset to begin the transfer. This allows for resuming both uploads and downloads. The value of this property is reset to 0 after a successful transfer.
When downloading a file, this property specifies both the starting position in the RemoteFile to read from, as well as the starting position in the LocalFile (or stream, if using SetDownloadStream) to write to.
When uploading a file, this property specifies both the starting position in the LocalFile (or stream, if using SetUploadStream) to read from, as well as the starting position in the RemoteFile to write to.
Please see below for a simple example of resuming an upload:
long bytesTransferred = 0;
component.OnTransfer += (o, e) => {
bytesTransferred = e.BytesTransferred;
};
component.LocalFile = "C:\nfs\test.txt";
component.RemoteFile = "test.txt";
bool uploadSuccessful = false;
int maxRetries = 5;
int retryCount = 0;
while (!uploadSuccessful) {
try {
component.StartByte = bytesTransferred; // 0 initially, updated by Transfer event as necessary
component.Upload();
uploadSuccessful = true;
} catch (NFSSDKException ex) {
retryCount++;
if (retryCount >= maxRetries) {
Console.WriteLine("Max retry attempts reached. Upload failed.");
throw ex;
}
}
}
Timeout Property (NFSClient Component)
This property includes the timeout for the component.
Syntax
property Timeout: Integer read get_Timeout write set_Timeout;
Default Value
60
Remarks
If the Timeout property is set to 0, all operations return immediately, potentially failing with a WOULDBLOCK error if data cannot be sent immediately.
If Timeout is set to a positive value, data is sent in a blocking manner and the component will wait for the operation to complete before returning control. The component will handle any potential WOULDBLOCK errors internally and automatically retry the operation for a maximum of Timeout seconds.
The component will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not freeze and remains responsive.
If Timeout expires, and the operation is not yet complete, the component raises an exception.
Note: By default, all timeouts are inactivity timeouts, that is, the timeout period is extended by Timeout seconds when any amount of data is successfully sent or received.
The default value for the Timeout property is 60 seconds.
User Property (NFSClient Component)
Specifies the name and domain of the user to authenticate.
Syntax
property User: String read get_User write set_User;
Default Value
''
Remarks
This property specifies the name and realm/domain of the user to authenticate.
The value specified must be in one of the following formats:
- user@domain
- domain/user
Note that this property is only applicable when SecurityMechanism is set to krb5, krb5i, or krb5p.
Abort Method (NFSClient Component)
Aborts the current upload or download.
Syntax
procedure Abort();
Remarks
This method is used to abort the current upload or download.
Append Method (NFSClient Component)
Appends data from LocalFile to a remote file RemoteFile on a NFS server.
Syntax
procedure Append();
Remarks
This method is similar to the Upload method, but the local file specified by LocalFile is appended to RemoteFile on the server as opposed to replacing it as with the Upload method. RemoteFile is either an absolute path on the server or a path relative to RemotePath. The server will create a file with that name if it does not already exist (similar to upload).
ChangeRemotePath Method (NFSClient Component)
Changes the current path on the server.
Syntax
procedure ChangeRemotePath(RemotePath: String);
Remarks
This method changes the current path on the server to the specified RemotePath parameter. When called, the component will issue a command to the server to change the directory. The RemotePath parameter may hold an absolute or relative path.
The current path on the server can be found by querying the RemotePath property.
Absolute Paths
If the path begins with a /, it is considered an absolute path and must specify the entire path from the root of the server. For example:
component.ChangeRemotePath("/home/testuser/myfolder");
Relative Paths
If the path does not begin with a /, it is considered a relative path and is resolved in relation to the current directory. For instance, a value of myfolder will indicate a subfolder of the current directory. The special value .. refers to the parent directory of the current path. For example:
//Change to the 'myfolder' sub-directory
component.ChangeRemotePath("myfolder");
//Navigate up two levels and then into the 'another/folder' path.
component.ChangeRemotePath("../../another/folder");
CheckFileExists Method (NFSClient Component)
Checks whether the file specified by RemoteFile exists on the server.
Syntax
function CheckFileExists(): Boolean;
Remarks
This method checks whether the file specified by RemoteFile exists on the server. If the file exists, this method returns True, otherwise it returns False. RemoteFile must be specified before calling this method.
The RemoteFile can either specify the absolute path to the file, or a relative path based on the current working directory (indicated by the RemotePath property). For instance:
// Relative Path
component.ChangeRemotePath("/home/testuser/myfolder");
component.RemoteFile = "test.txt";
// Checks for test.txt in /home/testuser/myfolder
if(component.CheckFileExists()) {
component.Download();
}
// Absolute Path
component.RemoteFile = "/home/test/test.txt";
// Checks for test.txt in /home/test
if(component.CheckFileExists()) {
component.Download();
}
Config Method (NFSClient Component)
Sets or retrieves a configuration setting.
Syntax
function Config(ConfigurationString: String): String;
Remarks
Config is a generic method available in every component. It is used to set and retrieve configuration settings for the component.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
Connect Method (NFSClient Component)
This method connects to the NFS server.
Syntax
procedure Connect();
Remarks
This method establishes a connection with the NFS server specified by RemoteHost and RemotePort.
Prior to calling this method, the SecurityMechanism should be set appropriately, along with properties relevant to the specified mechanism. For example:
component.RemoteHost = "10.0.1.67";
component.RemotePort = 2049;
component.Connect();
CreateFile Method (NFSClient Component)
Creates a file on the NFS server.
Syntax
procedure CreateFile(FileName: String);
Remarks
This method creates an empty file on the server with the name specified by the FileName parameter.
If the specified FileName already exists, and Overwrite is false, an error will be thrown.
To upload a file with content, use Upload instead.
CreateLink Method (NFSClient Component)
Creates a hard link or symbolic link on the server.
Syntax
procedure CreateLink(LinkName: String; LinkTarget: String; LinkType: Integer);
Remarks
This method is used to create a hard link or symbolic link on the server.
The LinkName parameter is the name of the link to create, and is either an absolute path on the server or a path relative to RemotePath.
The LinkTarget parameter specifies the target of the link.
The LinkType parameter indicates what type of link the component should attempt to create. Possible values are 0 or 1.
If specified as 0, the component will attempt to create a symbolic link pointing to the data (typically a file name) specified by the LinkTarget parameter.
If specified as 1, the component will attempt to create a hard link pointing to the file name specified by the LinkTarget parameter. Note that in this case, the LinkTarget is either an absolute path on the server or a path relative to RemotePath. Please see below for a simple example.
nfs.ChangeRemotePath("/nfs");
// Create symlink.txt in /nfs pointing to existing_file.txt in the same directory
nfs.CreateLink("symlink.txt", "existing_file.txt", 0);
// Create hardlink.txt in /nfs pointing to existing_file.txt in the same directory
nfs.CreateLink("hardlink.txt", "existing_file.txt", 1);
DeleteFile Method (NFSClient Component)
This method removes a file specified by FileName from the server.
Syntax
procedure DeleteFile(FileName: String);
Remarks
This method is used to remove a file specified by FileName from the server. The remote file or directory specified by FileName is deleted.
The FileName parameter is either an absolute path on the server, or a path relative to remote path set by ChangeRemotePath. For example:
// Delete test.txt in /home/test directory
component.ChangeRemotePath("/home/test");
component.DeleteFile("test.txt");
// Alternatively...
component.DeleteFile("/home/test/test.txt");
Disconnect Method (NFSClient Component)
This method disconnects from the NFS server.
Syntax
procedure Disconnect();
Remarks
This method is used to disconnect from the NFS server.
DoEvents Method (NFSClient Component)
This method processes events from the internal message queue.
Syntax
procedure DoEvents();
Remarks
The method checks for events to process, such as incoming data, and fires corresponding events as necessary. If there are no events to process, the method waits for a time specified by the SelectWaitMillis configuration setting before returning.
Windows: By default, the server socket uses Windows messages, and DoEvents dispatches Windows messages internally. It is not necessary to call DoEvents from Windows GUI applications as these applications have an internal message dispatch loop. When called, this method must be called in the same thread or task in which the StartListening and StopListening methods are called.
To avoid using Windows messages and a dispatch loop, set UseWindowsMessages to False. The application still needs to call this DoEvents method to let the component handle socket updates, but when Windows messages are not used, DoEvents and StopListening may be called from a separate thread or task.
Linux: The method may be called from any worker thread, and events will fire in this thread.
macOS: In GUI applications, it is not necessary to call this method as the component registers itself in the main message loop. In other applications, the method may be called from any worker thread, and events will fire in this thread.
Download Method (NFSClient Component)
This method downloads a remote file from the NFS server.
Syntax
procedure Download();
Remarks
This method is used to download a remote file, specified by RemoteFile, from the NFS server.
The LocalFile property can be used to specify a local file to download the specified remote file to. If the LocalFile already exists and Overwrite is false, an error will occur.
Alternatively, the SetDownloadStream method can be called to download the file contents to the specified stream. In this case, calling SetDownloadStream will automatically reset the value of LocalFile.
As an alternative to setting LocalFile or calling SetDownloadStream, the downloaded file contents are also available in the Transfer event. Note that the downloaded data is always available via Transfer, regardless of whether the data is downloaded to a stream or file (or neither).
For example:
// Using LocalFile
component.RemoteFile = "/home/test/test.txt";
component.LocalFile = "C:\\nfsdir\\test.txt";
component.Download();
// Using SetDownloadStream
FileStream fs = new FileStream("C:\\nfsdir\\test.txt", FileMode.Open);
component.RemoteFile = "/home/test/test.txt";
component.SetDownloadStream(fs);
component.Download();
DownloadRange Method (NFSClient Component)
This method downloads a specific segment of a remote file from a NFS server.
Syntax
function DownloadRange(Path: String; FileName: String; StartByte: Int64; Count: Integer; var Buffer: TBytes): Integer;
Remarks
This method is used to download a specific segment of a remote file specified by Path and FileName.
StartByte is the offset (in bytes) relative to the beginning of the file from where to start reading, and Count is the number of bytes to read into the specified Buffer.
This functionality is particularly useful for efficient management of large files and targeted data retrieval within them. This method will return the total number of bytes read into the buffer.
Note: If the requested range extends beyond the end of the file, only the available bytes will be returned.
For example:
// E.g., downloading first 5 bytes of file
byte[] downloadBuffer = new byte[5];
component.DownloadRange("/home/test", "test.txt", 0, downloadBuffer.Length, downloadBuffer);
ListDirectory Method (NFSClient Component)
This method lists the current working directory on the NFS server.
Syntax
procedure ListDirectory();
Remarks
This method is used to list the current working directory on the NFS server, as indicated by the current RemotePath.
The DirList event will fire for each entry in the current directory. The RemoteFile property may be used to specify a file mask for filtering the entries returned via DirList.
For example:
// List all text files in /home/test
component.OnDirList += (o, e) => {
Console.WriteLine("Dir Entry: " + e.FileName);
};
component.ChangeRemotePath("/home/test");
component.RemoteFile = "*.txt";
component.ListDirectory();
Note: Because RemoteFile acts as a file mask, to retrieve a complete directory listing RemoteFile should be set to an empty string (or a mask like "*").
The following special characters are supported for pattern matching:
? | Any single character. |
* | Any characters or no characters (e.g., C*t matches Cat, Cot, Coast, Ct). |
[,-] | A range of characters (e.g., [a-z], [a], [0-9], [0-9,a-d,f,r-z]). |
\ | The slash is ignored and exact matching is performed on the next character. |
If these characters need to be used as a literal in a pattern, then they must be escaped by surrounding them with brackets []. Note: "]" and "-" do not need to be escaped. See below for the escape sequences:
Character | Escape Sequence |
? | [?] |
* | [*] |
[ | [[] |
\ | [\] |
For example, to match the value [Something].txt, specify the pattern [[]Something].txt.
MakeDirectory Method (NFSClient Component)
This method is used to create a directory on the NFS server.
Syntax
procedure MakeDirectory(NewDir: String);
Remarks
This method is used to create a directory with a path specified by NewDir on the NFS server.
NewDir is either an absolute path on the server, or a path relative to the RemotePath that is set by calling ChangeRemotePath.
QueryFileAttributes Method (NFSClient Component)
This method queries the server for the file attributes of the specified RemoteFile .
Syntax
procedure QueryFileAttributes();
Remarks
This method is used to query the server for file attributes of the specified RemoteFile. After calling this method, the FileAttributes property will be populated with the values returned by the server.
To update attributes, modify the desired values in FileAttributes and call UpdateFileAttributes. Please see below for a simple example:
// First, query attributes
component.RemoteFile = "/home/test/test.txt";
component.QueryFileAttributes();
// Update OwnerId and OwnerGroupId of file
component.FileAttributes.OwnerId = "1000";
component.FileAttributes.OwnerGroupId = "1000";
component.UpdateFileAttributes();
ReadLink Method (NFSClient Component)
Reads a symbolic link on the server.
Syntax
function ReadLink(LinkName: String): TBytes;
Remarks
This method is used to read a symbolic link on the server.
The LinkName parameter specifies the name of the symbolic link, and is either an absolute path on the server or a path relative to RemotePath.
This method will return a byte array containing the contents of the symbolic link as stored on the server. In NFS v4.0, the contents of a symbolic link are treated as opaque (binary data) at the protocol level. The server simply stores this opaque data, and returns this to the client when requested, meaning it is up to the client to interpret the link data.
Most of the time, the opaque data will represent the file the symbolic link is pointing to relative to the position of the symbolic link, meaning it can be converted to a UTF8 string representing this file. The contents of the file should then be downloaded by setting RemoteFile (and possibly RemotePath) accordingly and calling Download.
Please see below for a simple example of reading the contents of a symbolic link, and reading the file pointed to by the symbolic link.
nfs.ChangeRemotePath("/nfs");
// Create symlink.txt in /nfs pointing to existing_file.txt in the same directory
nfs.CreateLink("symlink.txt", "existing_file.txt", 0);
// Read link
byte[] linkData = nfs.ReadLink("symlink.txt");
string file = Encoding.UTF8.GetString(linkData);
nfs.RemoteFile = file;
nfs.LocalFile = "temp.txt";
nfs.Download();
RemoveDirectory Method (NFSClient Component)
This removes a directory specified by DirName from the NFS server.
Syntax
procedure RemoveDirectory(DirName: String);
Remarks
This method is used to remove a directory with path specified by DirName from the NFS server. DirName is either an absolute path on the server, or a path relative to the RemotePath that is set by calling ChangeRemotePath.
RenameFile Method (NFSClient Component)
This changes the name of RemoteFile to NewName .
Syntax
procedure RenameFile(NewName: String);
Remarks
This method is used to change the name of a remote file, specified by RemoteFile, to NewName. RemoteFile and NewName are either absolute paths on the server, or a path relative to RemotePath that is set by calling ChangeRemotePath.
Reset Method (NFSClient Component)
This method will reset the component.
Syntax
procedure Reset();
Remarks
This method will reset the component's properties to their default values.
SetDownloadStream Method (NFSClient Component)
This method sets the stream to which the downloaded data from the server will be written.
Syntax
procedure SetDownloadStream(DownloadStream: TStream);
Remarks
This method is used to set the stream to which the downloaded data from the server will be written. If a download stream is set before the Download method is called, the downloaded data will be written to the stream. The stream should be open and normally set to position 0.
The component will automatically close this stream if CloseStreamAfterTransfer is True (default). If the stream is closed, you need to call SetDownloadStream again before calling Download again.
The downloaded content will be written starting at the current position in the stream. If StartByte is a non-zero value, the server will be instructed to skip those bytes before starting to send the content of the file. In that case, it is up to you to build the stream appropriately.
Note: SetDownloadStream will reset LocalFile.
SetUploadStream Method (NFSClient Component)
This method sets the stream from which the component will read data to upload to the server.
Syntax
procedure SetUploadStream(UploadStream: TStream);
Remarks
This method is used to set the stream from which the component will read data to upload to the server. If an upload stream is set before the Upload method is called, the content of the stream will be read by the component and uploaded to the server. The stream should be open and normally set to position 0.
The component will automatically close this stream if CloseStreamAfterTransfer is True (default). If the stream is closed, you need to call SetUploadStream again before calling Upload again.
The content of the stream will be read from the current position all the way to the end, and no bytes will be skipped even if StartByte is set to a non-zero value (although the server will be instructed to skip those bytes in its file).
Note: SetUploadStream will reset LocalFile.
UpdateFileAttributes Method (NFSClient Component)
This method updates the FileAttributes for the current RemoteFile .
Syntax
procedure UpdateFileAttributes();
Remarks
This method is used to update the FileAttributes for the current RemoteFile. After calling this method, the component will send any set FileAttributes to the server.
For example:
// First, query attributes
component.RemoteFile = "/home/test/test.txt";
component.QueryFileAttributes();
// Update OwnerId and OwnerGroupId of file
component.FileAttributes.OwnerId = "1000";
component.FileAttributes.OwnerGroupId = "1000";
component.UpdateFileAttributes();
Upload Method (NFSClient Component)
This method uploads a file to the NFS server.
Syntax
procedure Upload();
Remarks
This method is used to upload a file to the NFS server.
The RemoteFile property is used to specify the remote location to upload the local data to. If the RemoteFile already exists and Overwrite is false, an error will occur while uploading.
The LocalFile property can be used to specify a local file to upload to the specified remote location.
Alternatively, the SetUploadStream method can be called to upload the contents of a given stream. In this case, calling SetUploadStream will automatically reset the value of LocalFile.
The uploaded data will be made available in the Transfer event. Please see below for a simple example.
// Using LocalFile
component.LocalFile = "C:\\nfsdir\\test.txt";
component.RemoteFile = "/home/test/test.txt";
component.Upload();
// Using SetDownloadStream
FileStream fs = new FileStream("C:\\nfsdir\\test.txt", FileMode.Open);
component.SetUploadStream(fs);
component.RemoteFile = "/home/test/test.txt";
component.Upload();
UploadRange Method (NFSClient Component)
This method uploads a specific segment of data into a remote file on the NFS server.
Syntax
procedure UploadRange(Path: String; FileName: String; StartByte: Int64; Count: Integer; Buffer: TBytes);
Remarks
This method is used to upload a specific segment of data into a remote file specified by Path and FileName. Count bytes will be updated from the provided Buffer starting in the remote file at the StartByte offset.
This functionality enables precise control over the insertion of data into a remote file, allowing for targeted modifications, overwriting, or additions starting from a specific position within the file.
Note: If the offset specified is beyond the file length, empty bytes will be created between the last file byte and the uploaded buffer.
For example:
// E.g., appending data to EOF
component.RemoteFile = "/home/test/test.txt";
component.QueryFileAttributes();
int startByte = component.FileAttributes.Size;
byte[] buffer = Encoding.Default.GetBytes("Upload these bytes");
component.UploadRange("/home/test", "test.txt", startByte, buffer.Length, buffer);
Connected Event (NFSClient Component)
Fired immediately after a connection completes (or fails).
Syntax
type TConnectedEvent = procedure ( Sender: TObject; StatusCode: Integer; const Description: String ) of Object;
property OnConnected: TConnectedEvent read FOnConnected write FOnConnected;
Remarks
If the connection is made normally, StatusCode is 0 and Description is 'OK'.
If the connection fails, StatusCode has the error code returned by the Transmission Control Protocol (TCP)/IP stack. Description contains a description of this code. The value of StatusCode is equal to the value of the error.
Please refer to the Error Codes section for more information.
DirList Event (NFSClient Component)
This event fires when a directory entry is received.
Syntax
type TDirListEvent = procedure ( Sender: TObject; const DirEntry: String; const FileName: String; IsDir: Boolean; FileSize: Int64; const FileTime: String; IsSymlink: Boolean ) of Object;
property OnDirList: TDirListEvent read FOnDirList write FOnDirList;
Remarks
The DirList events are fired when a directory listing is received as a response to a ListDirectory call.
The StartTransfer and EndTransfer events mark the beginning and end of the event stream.
The DirEntry parameter contains the filename when ListDirectory is called and includes extended file information when ListDirectoryLong is called.
The component tries to fill out the FileName, IsDir, FileSize, and FileTime parameters when calling the ListDirectoryLong method. Except for FileName, these parameters are empty when a short "List Directory" is performed.
In Unix systems, the date is given in two types of formats: If the date is in the past 12 months the exact time is specified and the year is omitted. Otherwise, only the date and the year, but not hours or minutes, are given.
Disconnected Event (NFSClient Component)
This event is fired when a connection is closed.
Syntax
type TDisconnectedEvent = procedure ( Sender: TObject; StatusCode: Integer; const Description: String ) of Object;
property OnDisconnected: TDisconnectedEvent read FOnDisconnected write FOnDisconnected;
Remarks
This event is fired when a connection is closed.
If the connection is broken normally, StatusCode is 0 and Description is "OK".
If the connection is broken for any other reason, StatusCode will be non-zero, and the Description parameter will contain a description of this code.
EndTransfer Event (NFSClient Component)
This event is fired when a file finishes uploading or downloading.
Syntax
type TEndTransferEvent = procedure ( Sender: TObject; Direction: Integer ) of Object;
property OnEndTransfer: TEndTransferEvent read FOnEndTransfer write FOnEndTransfer;
Remarks
This event is fired when a file is finished uploading or downloading.
This occurs when a file is finished transferring after calling Upload, UploadRange, Download, and DownloadRange.
The Direction parameter shows whether the client (0) or the server (1) is sending the data.
Error Event (NFSClient Component)
Fired when information is available about errors during data delivery.
Syntax
type TErrorEvent = procedure ( Sender: TObject; ErrorCode: Integer; const Description: String ) of Object;
property OnError: TErrorEvent read FOnError write FOnError;
Remarks
The Error event is fired in case of exceptional conditions during message processing. Normally the component raises an exception.
The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
Log Event (NFSClient Component)
This event is fired once for each log message.
Syntax
type TLogEvent = procedure ( Sender: TObject; LogLevel: Integer; const Message: String; const LogType: String ) of Object;
property OnLog: TLogEvent read FOnLog write FOnLog;
Remarks
This event fires once for each log message generated by the component. The verbosity is controlled by the LogLevel configuration.
LogLevel indicates the detail level of the message. Possible values are:
0 (None) | No messages are logged. |
1 (Info - Default) | Informational events are logged. |
2 (Verbose) | Detailed data is logged. |
3 (Debug) | Debug data including all sent and received NFS operations are logged. |
Message is the log message.
LogType identifies the type of log entry. Possible values are as follows:
- NFS
StartTransfer Event (NFSClient Component)
This event is fired when a file starts uploading or downloading.
Syntax
type TStartTransferEvent = procedure ( Sender: TObject; Direction: Integer ) of Object;
property OnStartTransfer: TStartTransferEvent read FOnStartTransfer write FOnStartTransfer;
Remarks
This event is fired when a file starts uploading or downloading.
This occurs immediately before a file starts transferring after calling Upload, UploadRange, Download, and DownloadRange.
The Direction parameter shows whether the client (0) or the server (1) is sending the data.
Transfer Event (NFSClient Component)
This event is fired during the file download or upload.
Syntax
type TTransferEvent = procedure ( Sender: TObject; Direction: Integer; BytesTransferred: Int64; PercentDone: Integer; const Text: String; const TextB: TBytes ) of Object;
property OnTransfer: TTransferEvent read FOnTransfer write FOnTransfer;
Remarks
One or more Transfer events are fired during file transfer. The BytesTransferred parameter shows the number of bytes transferred since the beginning of the transfer.
Text contains the portion of the file data being delivered.
The Direction parameter shows whether the client (0) or the server (1) is sending the data.
The PercentDone parameter shows the progress of the transfer in the corresponding direction. If PercentDone can not be calculated the value will be -1.
Note: Events are not re-entrant. Performing time-consuming operations within this event will prevent it from firing again in a timely manner and may affect overall performance.
Firewall Type
The firewall the component will connect through.
Remarks
When connecting through a firewall, this type is used to specify different properties of the firewall, such as the firewall Host and the FirewallType.
Fields
AutoDetect
Boolean
Default Value: False
Whether to automatically detect and use firewall system settings, if available.
FirewallType
TipnFirewallTypes
Default Value: 0
The type of firewall to connect through. The applicable values are as follows:
fwNone (0) | No firewall (default setting). |
fwTunnel (1) | Connect through a tunneling proxy. Port is set to 80. |
fwSOCKS4 (2) | Connect through a SOCKS4 Proxy. Port is set to 1080. |
fwSOCKS5 (3) | Connect through a SOCKS5 Proxy. Port is set to 1080. |
fwSOCKS4A (10) | Connect through a SOCKS4A Proxy. Port is set to 1080. |
Host
String
Default Value: ""
The name or IP address of the firewall (optional). If a Host is given, the requested connections will be authenticated through the specified firewall when connecting.
If this property is set to a Domain Name, a DNS request is initiated. Upon successful termination of the request, this property is set to the corresponding address. If the search is not successful, the component raises an exception.
Password
String
Default Value: ""
A password if authentication is to be used when connecting through the firewall. If Host is specified, the User and Password properties are used to connect and authenticate to the given firewall. If the authentication fails, the component raises an exception.
Port
Integer
Default Value: 0
The Transmission Control Protocol (TCP) port for the firewall Host. See the description of the Host property for details.
Note: This property is set automatically when FirewallType is set to a valid value. See the description of the FirewallType property for details.
User
String
Default Value: ""
A username if authentication is to be used when connecting through a firewall. If Host is specified, this property and the Password property are used to connect and authenticate to the given Firewall. If the authentication fails, the component raises an exception.
Constructors
constructor Create();
NFSFileAttributes Type
Includes a set of attributes for a file existing on an Network File System (NFS) server.
Remarks
This type describes a file residing on an SFTP server.
- AccessTime
- AccessTimeNanos
- AllocationSize
- CreationTime
- CreationTimeNanos
- FileType
- IsDir
- IsSymlink
- LinkCount
- MIMEType
- Mode
- ModifiedTime
- ModifiedTimeNanos
- OwnerGroupId
- OwnerId
- Size
Fields
AccessTime
Int64
Default Value: 0
Contains the number of seconds since 12:00:00 AM, January 1, 1970, when this file was last accessed.
AccessTimeNanos
Integer
Default Value: 0
Contains a subsecond value associated with this file's AccessTime.
AllocationSize
Int64 (read-only)
Default Value: 0
Number of file system bytes allocated to this file object.
CreationTime
Int64 (read-only)
Default Value: 0
Specifies the number of seconds since 12:00:00 AM, January 1, 1970, when this file was created.
CreationTimeNanos
Integer (read-only)
Default Value: 0
Contains a subsecond value associated with this file's CreationTime.
FileType
TipnNFSFileTypes (read-only)
Default Value: 0
The type of file. FileType may be one of the following values:
1 (nfsREG - default) | A regular file. |
2 (NFS4DIR) | A directory. |
3 (NF4BLK) | The file is a block device special file. |
4 (NF4CHR) | The file type is a character device special file. |
5 (NF4LNK) | The file type is a symbolic link. |
6 (NF4SOCK) | The file handle is a named socket special file. |
7 (NF4FIFO) | The file handle is a fifo special file. |
8 (NF4ATTRDIR) | The file handle is a named attribute directory. |
9 (NF4NAMEDATTR) | The file handle is a named attribute. |
IsDir
Boolean (read-only)
Default Value: False
Specifies whether or not the file represented by these attributes is a directory.
IsSymlink
Boolean (read-only)
Default Value: False
Specifies whether or not the file or directory represented by these attributes is a symbolic link.
LinkCount
Integer (read-only)
Default Value: 0
Number of hard links to this object.
MIMEType
String (read-only)
Default Value: ""
Specifies a value that can be used in the Content-Type header for a MIME entity part containing this file.
Mode
Integer
Default Value: 0
Mode of a file
ModifiedTime
Int64
Default Value: 0
Specifies the number of seconds since 12:00:00 AM, January 1, 1970, that this file was last modified.
ModifiedTimeNanos
Integer
Default Value: 0
Includes a subsecond value associated with this file's ModifiedTime.
OwnerGroupId
String
Default Value: ""
The string name of the group ownership of this object.
OwnerId
String
Default Value: ""
The string name of the owner of this object.
Size
Int64
Default Value: 0
Specifies the total size, in bytes, of this file.
Config Settings (NFSClient Component)
The component accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, access to these internal properties is provided through the Config method.NfsClient Config Settings
To clarify, when connecting to a server, the client must send a client ID to identify itself. The component automatically creates an ID based on the LocalHost, LocalPort, RemoteHost, and RemotePort, as recommended by RFC 7530.
This could cause problems on the server-side if multiple clients are running on the exact same machine, or by chance have the same client ID. If this is the case, this config can be set to some unique string identifier for the client, which will be appended to the existing client ID, to ensure no server-side collisions.
When calling ListDirectory, this config is utilized to inform the server of the maximum number of bytes that should be returned in a single READDIR request.
Larger values will result in fewer READDIR requests for the given ListDirectory operation, but the READDIR results from the server-side could potentially be much larger. Smaller values will result in smaller READDIR responses from the server, but increase the frequency of READDIR requests to the server.
Note this config is read-only.
Note this config is read-only.
By default, this config is an empty string. It is automatically assigned upon the clients first read or write operation (e.g., via Upload or Download). Upon the first read or write operation, the component sets this value to the number of milliseconds elapsed since the epoch (January 1, 1970 UTC), and it remains unchanged for the lifetime of the client. In most cases, it is not necessary to set this config.
This config must be specified as a comma-separated list of such GIDs, for example: 4,24,27,30,46,110,1000
By default, this is set to the ORed value of S_IWGRP and S_IWOTH, meaning the new file will not include write permissions for the group or others. For reference, this config may be set to a combination of the following permission bits, as defined in the UNIX standard sys/stat.h header:
S_IRUSR | 0x100 | Read permission, owner. |
S_IWUSR | 0x080 | Write permission, owner. |
S_IXUSR | 0x040 | Execute permission, owner. |
S_IRGRP | 0x020 | Read permission, group. |
S_IWGRP | 0x010 | Write permission, group. |
S_IXGRP | 0x008 | Execute permission, group. |
S_IROTH | 0x004 | Read permission, others. |
S_IWOTH | 0x002 | Write permission, others. |
S_IXOTH | 0x001 | Execute permission, others. |
For example, to deny write permissions only for others, you can set this like so:
int stMask = S_IWOTH; // 0x0002
component.Config("STMask=" + stMask);
component.Remotefile = "remote.txt";
component.CreateFile();
Note: This functionality is only available on Windows.
Base Config Settings
The following is a list of valid code page identifiers:
Identifier | Name |
037 | IBM EBCDIC - U.S./Canada |
437 | OEM - United States |
500 | IBM EBCDIC - International |
708 | Arabic - ASMO 708 |
709 | Arabic - ASMO 449+, BCON V4 |
710 | Arabic - Transparent Arabic |
720 | Arabic - Transparent ASMO |
737 | OEM - Greek (formerly 437G) |
775 | OEM - Baltic |
850 | OEM - Multilingual Latin I |
852 | OEM - Latin II |
855 | OEM - Cyrillic (primarily Russian) |
857 | OEM - Turkish |
858 | OEM - Multilingual Latin I + Euro symbol |
860 | OEM - Portuguese |
861 | OEM - Icelandic |
862 | OEM - Hebrew |
863 | OEM - Canadian-French |
864 | OEM - Arabic |
865 | OEM - Nordic |
866 | OEM - Russian |
869 | OEM - Modern Greek |
870 | IBM EBCDIC - Multilingual/ROECE (Latin-2) |
874 | ANSI/OEM - Thai (same as 28605, ISO 8859-15) |
875 | IBM EBCDIC - Modern Greek |
932 | ANSI/OEM - Japanese, Shift-JIS |
936 | ANSI/OEM - Simplified Chinese (PRC, Singapore) |
949 | ANSI/OEM - Korean (Unified Hangul Code) |
950 | ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) |
1026 | IBM EBCDIC - Turkish (Latin-5) |
1047 | IBM EBCDIC - Latin 1/Open System |
1140 | IBM EBCDIC - U.S./Canada (037 + Euro symbol) |
1141 | IBM EBCDIC - Germany (20273 + Euro symbol) |
1142 | IBM EBCDIC - Denmark/Norway (20277 + Euro symbol) |
1143 | IBM EBCDIC - Finland/Sweden (20278 + Euro symbol) |
1144 | IBM EBCDIC - Italy (20280 + Euro symbol) |
1145 | IBM EBCDIC - Latin America/Spain (20284 + Euro symbol) |
1146 | IBM EBCDIC - United Kingdom (20285 + Euro symbol) |
1147 | IBM EBCDIC - France (20297 + Euro symbol) |
1148 | IBM EBCDIC - International (500 + Euro symbol) |
1149 | IBM EBCDIC - Icelandic (20871 + Euro symbol) |
1200 | Unicode UCS-2 Little-Endian (BMP of ISO 10646) |
1201 | Unicode UCS-2 Big-Endian |
1250 | ANSI - Central European |
1251 | ANSI - Cyrillic |
1252 | ANSI - Latin I |
1253 | ANSI - Greek |
1254 | ANSI - Turkish |
1255 | ANSI - Hebrew |
1256 | ANSI - Arabic |
1257 | ANSI - Baltic |
1258 | ANSI/OEM - Vietnamese |
1361 | Korean (Johab) |
10000 | MAC - Roman |
10001 | MAC - Japanese |
10002 | MAC - Traditional Chinese (Big5) |
10003 | MAC - Korean |
10004 | MAC - Arabic |
10005 | MAC - Hebrew |
10006 | MAC - Greek I |
10007 | MAC - Cyrillic |
10008 | MAC - Simplified Chinese (GB 2312) |
10010 | MAC - Romania |
10017 | MAC - Ukraine |
10021 | MAC - Thai |
10029 | MAC - Latin II |
10079 | MAC - Icelandic |
10081 | MAC - Turkish |
10082 | MAC - Croatia |
12000 | Unicode UCS-4 Little-Endian |
12001 | Unicode UCS-4 Big-Endian |
20000 | CNS - Taiwan |
20001 | TCA - Taiwan |
20002 | Eten - Taiwan |
20003 | IBM5550 - Taiwan |
20004 | TeleText - Taiwan |
20005 | Wang - Taiwan |
20105 | IA5 IRV International Alphabet No. 5 (7-bit) |
20106 | IA5 German (7-bit) |
20107 | IA5 Swedish (7-bit) |
20108 | IA5 Norwegian (7-bit) |
20127 | US-ASCII (7-bit) |
20261 | T.61 |
20269 | ISO 6937 Non-Spacing Accent |
20273 | IBM EBCDIC - Germany |
20277 | IBM EBCDIC - Denmark/Norway |
20278 | IBM EBCDIC - Finland/Sweden |
20280 | IBM EBCDIC - Italy |
20284 | IBM EBCDIC - Latin America/Spain |
20285 | IBM EBCDIC - United Kingdom |
20290 | IBM EBCDIC - Japanese Katakana Extended |
20297 | IBM EBCDIC - France |
20420 | IBM EBCDIC - Arabic |
20423 | IBM EBCDIC - Greek |
20424 | IBM EBCDIC - Hebrew |
20833 | IBM EBCDIC - Korean Extended |
20838 | IBM EBCDIC - Thai |
20866 | Russian - KOI8-R |
20871 | IBM EBCDIC - Icelandic |
20880 | IBM EBCDIC - Cyrillic (Russian) |
20905 | IBM EBCDIC - Turkish |
20924 | IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol) |
20932 | JIS X 0208-1990 & 0121-1990 |
20936 | Simplified Chinese (GB2312) |
21025 | IBM EBCDIC - Cyrillic (Serbian, Bulgarian) |
21027 | Extended Alpha Lowercase |
21866 | Ukrainian (KOI8-U) |
28591 | ISO 8859-1 Latin I |
28592 | ISO 8859-2 Central Europe |
28593 | ISO 8859-3 Latin 3 |
28594 | ISO 8859-4 Baltic |
28595 | ISO 8859-5 Cyrillic |
28596 | ISO 8859-6 Arabic |
28597 | ISO 8859-7 Greek |
28598 | ISO 8859-8 Hebrew |
28599 | ISO 8859-9 Latin 5 |
28605 | ISO 8859-15 Latin 9 |
29001 | Europa 3 |
38598 | ISO 8859-8 Hebrew |
50220 | ISO 2022 Japanese with no halfwidth Katakana |
50221 | ISO 2022 Japanese with halfwidth Katakana |
50222 | ISO 2022 Japanese JIS X 0201-1989 |
50225 | ISO 2022 Korean |
50227 | ISO 2022 Simplified Chinese |
50229 | ISO 2022 Traditional Chinese |
50930 | Japanese (Katakana) Extended |
50931 | US/Canada and Japanese |
50933 | Korean Extended and Korean |
50935 | Simplified Chinese Extended and Simplified Chinese |
50936 | Simplified Chinese |
50937 | US/Canada and Traditional Chinese |
50939 | Japanese (Latin) Extended and Japanese |
51932 | EUC - Japanese |
51936 | EUC - Simplified Chinese |
51949 | EUC - Korean |
51950 | EUC - Traditional Chinese |
52936 | HZ-GB2312 Simplified Chinese |
54936 | Windows XP: GB18030 Simplified Chinese (4 Byte) |
57002 | ISCII Devanagari |
57003 | ISCII Bengali |
57004 | ISCII Tamil |
57005 | ISCII Telugu |
57006 | ISCII Assamese |
57007 | ISCII Oriya |
57008 | ISCII Kannada |
57009 | ISCII Malayalam |
57010 | ISCII Gujarati |
57011 | ISCII Punjabi |
65000 | Unicode UTF-7 |
65001 | Unicode UTF-8 |
Identifier | Name |
1 | ASCII |
2 | NEXTSTEP |
3 | JapaneseEUC |
4 | UTF8 |
5 | ISOLatin1 |
6 | Symbol |
7 | NonLossyASCII |
8 | ShiftJIS |
9 | ISOLatin2 |
10 | Unicode |
11 | WindowsCP1251 |
12 | WindowsCP1252 |
13 | WindowsCP1253 |
14 | WindowsCP1254 |
15 | WindowsCP1250 |
21 | ISO2022JP |
30 | MacOSRoman |
10 | UTF16String |
0x90000100 | UTF16BigEndian |
0x94000100 | UTF16LittleEndian |
0x8c000100 | UTF32String |
0x98000100 | UTF32BigEndian |
0x9c000100 | UTF32LittleEndian |
65536 | Proprietary |
- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.
This setting only works on these components: AS3Receiver, AS3Sender, Atom, Client(3DS), FTP, FTPServer, IMAP, OFTPClient, SSHClient, SCP, Server(3DS), Sexec, SFTP, SFTPServer, SSHServer, TCPClient, TCPServer.
Setting this configuration setting to True tells the component to use the internal implementation instead of using the system security libraries.
This setting is set to False by default on all platforms.
Trappable Errors (NFSClient Component)
NFSCLIENT Errors
500 | Invalid state error. Please see the error description for further details. |
550 | An unsupported attribute was encountered. |
551 | An error was encountered changing the remote path. |
553 | The remote file could not be found before performing an upload or download operation. |
554 | The local file could not be found before performing an upload or download operation. |
555 | The current upload or download was manually aborted. |
557 | When manually uploading or downloading a specified range, the buffer specified was empty or null. |
558 | When manually uploading or downloading a specified range, the starting byte or count was negative. |
559 | When manually uploading or downloading a specified range, the count was greater than the size of the buffer. |
560 | When downloading, this indicates the local file exists and the Overwrite property is false. |
561 | An invalid link option was specified when creating a link. Only values of 0 (symbolic link) and 1 (hard link) are supported. |
562 | When uploading, this indicates the local file could not be found. |
567 | When uploading, this indicates an error occurred opening the local file. |
568 | When uploading, this indicates an error occurred while skipping the starting bytes of the local file. |
569 | An error was encountered while uploading a file. Please see the error description for more details. |
570 | An error was encountered while downloading a file. Please see the error description for more details. |