Internet Direct (Indy)
Home
PreviousUpNext
TIdFTP.CRC Method

Calculates the Cyclic Redundancy Check (or CRC) for a specified file on an FTP server.

Pascal
function CRC(
    const AFIleName: String; 
    const AStartPoint: Int64 = 0; 
    const AEndPoint: Int64 = 0
): Int64;
Parameters 
Description 
AFIleName 
File name on the server for the checksum calculation.
 
AStartPoint 
Initial position in the block of data for the checksum calculation. Default value is 0 (zero).
 
AEndPoint 
Final position in the block of data for the checksum calculation. Default value is 0 (zero). 

Int64 - CRC value for the indicated file name. the FTP server.

CRC is an Int64 function that returns the Cyclic Redundancy Check (or CRC) value for a range of content in a specified file on the FTP server. CRC provides the ability for the FTP client to verify that the file has been successfully transferred to the server without corruption. 

The CRC value is a mathematical calculation on a block of data in the file specified in AFileName, and returns a number that represents the content and organization of that data. The CRC calculation returns a unique number (or "fingerprint") that uniquely identifies the data found in the offsets specified by a StartPoint and AEndPoint. 

AStartPoint and AEndPoint indicate the initial and final positions in a block of data to be used in the CRC calculation. When AStartPoint contains 0 (zero), both AStartPoint and AEndPoint are ignored and the entire contents of the file are used in the CRC calculation. When AEndPoint contains 0 (zero), the length of the indicated file is assumed as the final position in the CRC calculation. 

The return value is the 64-bit integer that represents the CRC for file on the remote server for the connection. The return value can contain the value -1 when the file does not exist or the CRC is invalid in the FTP response. 

CRC can be used when the FTP server supports the FTP XCRC extension command, and after uploading the content for the file in AFileName using the Put method. The FTP server will perform the CRC calculation on the file ( or byte range) and return the 8-byte 'fingerprint' for the specified file. 

The client application can compare this fingerprint to the CRC fingerprint which it generates locally to determine if the file has been modified, corrupted, or altered during its transfer to the server. Use TIdHashCRC32 or a comparable component to perform the local CRC calculation for the files content. 

Please note that the FTP XCRC extension commands is not widely supported in FTP server implementations at the current time. Use the Capabilities property to determine if the command is supported on the FTP server for the current connection.

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.