CFtpClient::NormalizeUrl Method  
 
INT NormalizeUrl(
  LPCTSTR lpszUrl,  
  LPTSTR lpszNormalized,  
  INT nMaxLength,  
);
INT NormalizeUrl(
  LPCTSTR lpszUrl,  
  CString& strNormalized  
);

The NormalizeUrl method returns a normalized FTP URL.

Parameters

lpszUrl
A null-terminated string which specifies an FTP URL. This parameter cannot be NULL.
lpszNormalized
A null-terminated string buffer which will contain the normalized URL when the method returns. The buffer must be large enough to contain the entire URL including the terminating null character. If this parameter is NULL it will be ignored and the method will return the length of the normalized URL without copying any characters. An alternate version of this method accepts a reference to a CString object which will contain the normalized URL when the method returns.
nMaxLength
An integer value which specifies the maximum number of characters which can be copied into the string buffer. If this value is zero, the lpszNormalized parameter is ignored and the method will return the length of the normalized URL without copying any characters.

Return Value

This method returns the number of characters copied into the string buffer, not including the terminating null character. If the lpszNormalized parameter is NULL, it will return the length of the normalized URL but will not copy any characters. If the method fails, it will return FTP_ERROR. To get extended error information, call GetLastError.

Remarks

This method will accept a standard FTP, FTPS or SFTP URL and return a normalized version of that URL. Normalization will remove extraneous path delimiters and collapse the path if there are references to parent directories. If non-standard port numbers are included in the URL, they will be preserved. For example, if the following URL is provided to the method:

ftps://ftp.example.com:21/file/..//data/filename.txt

It will return the following as the normalized URL:

ftpes://ftp.example.com/data/filename.txt

Because the original URL specified a secure connection on port 21, this is inferred to mean the connection will use explicit TLS and not an implicit connection. This is why the scheme is changed from ftps:// to ftpes:// and the port number is removed, since port 21 is the default port for an explicit TLS connection. In addition, the path is collapsed and the extraneous path delimiters are removed.

This method is primarily intended to normalize URLs which may be entered by a user or read from a configuration file. It is not necessary to call this method prior to calling ConnectUrl because it will always be normalized internally prior to the connection being established. If you wish to check a URL to ensure it is valid and the server name can be resolved to an IP address, use the ValidateUrl method.

If you need to normalize a remote file path, use the NormalizePath method.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csftpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also