Back to product page
- Introduction
- Overview
- License agreement
- Classes
- Enumerations
- wodSFTPdll
- Create function
- Destroy function
- Methods
- Abort
- About
- AppendData
- AppendDataLen
- AppendFile
- Connect
- DeleteFile
- DeleteFiles
- Disconnect
- ExtendedCmd
- GetAttributes
- GetData
- GetDataAt
- GetDataToBuffer
- GetDataToBufferAt
- GetFile
- GetFileAt
- GetFiles
- ListAttributes
- ListDir
- ListNames
- LoadPrivateKey
- LoopFiles
- MakeDir
- PutData
- PutDataAt
- PutDataLen
- PutDataLenAt
- PutFile
- PutFileAt
- PutFiles
- RealPath
- RemoteClose
- RemoteOpen
- RemoteRead
- RemoteWrite
- RemoveDir
- Rename
- SetAttributes
- Properties
- Authentication
- Blocking
- BufferSize
- ClientName
- Compression
- Encryption
- EncryptionList
- ErrorText
- Extensions
- FIPS
- HMacList
- Hostname
- KeyExchangeList
- KeySignatureList
- LastError
- ListItem
- LocalPath
- Login
- MaxTransferRate
- MyHostname
- MyIP
- Password
- Port
- PrivateKey
- ProxyHostname
- ProxyLogin
- ProxyPassword
- ProxyPort
- ProxyType
- RemoteIdentification
- RemotePath
- Resume
- ServerErrorCode
- ServerErrorText
- State
- StateText
- Timeout
- Timezone
- TransferMode
- TransferRate
- TransferTime
- UseIPv6
- Version
- Callbacks
- How to get support
- Using callbacks
- Technical information
- Error list
LoopItem callback
Called before wodSFTP performs operation on item from the GetFiles/PutFiles/DeleteFiles/LoopFiles sequence.
Syntax
- C
void (*LoopItem)(void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, int *Skip);
The LoopItem(void *Sftp,char *LocalFile,char *RemoteFile,DirItemTypes ItemType,int *Skip) syntax has these parts:
The LoopItem(void *Sftp,char *LocalFile,char *RemoteFile,DirItemTypes ItemType,int *Skip) syntax has these parts:
void *Sftp | Handle of the created Sftp instance. |
char *LocalFile | Holds full path to file/folder on local disk |
char *RemoteFile | Holds full path to file/folder on remote server. |
DirItemTypes ItemType | A DirItemTypes enumeration. Type of the item - file, folder, symbolic link. |
int *Skip | When set to 0 (null, false), wodSFTP continues with operation on specified file. Otherwise, file is skipped. |
Remarks
The LoopItem callback will be called as a result of the GetFiles, PutFiles, DeleteFiles and LoopFiles functions. TIt provides information about each item in the sequence (meaning file or folder) before actual operation on that item is executed - allowing you to optionally Skip the operation for this particular item. Since both LocalFile and RemoteFile arguments can be changed, you can also cause operation to be performed on completely different files than it would be in original operation. LocalFile and RemoteFile point to 32k buffer that you can overwrite with new file/folder path. For example, you can use LoopItem callback like this:void SftpLoopItem(void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, int *Skip)
{
if (ItemType == typeDirectory)
*Skip = FALSE;
else
{
int i = strlen(RemoteFile);
if (i>4)
{
if (!strcmp(&RemoteFile[i-4], ".txt"))
{
*Skip = FALSE;
return;
}
}
*Skip = TRUE;
}
}
which means that only files ending with ".txt" are copied - others are skipped (but directories are created, just in case). You can also use it like this: we will copy all ".txt" files to the same directory, no matter where they originate from:
void SftpLoopItem(void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, int *Skip)
{
int i = strlen(RemoteFile);
if (i>4)
{
if (!strcmp(&RemoteFile[i-4], ".txt"))
{
char buff[MAX_PATH];
sprintf(buff, "c:\\mytxtfiles\\file%d.txt", mycounter++);
strcpy(LocalFile, buff);
*Skip = FALSE;
return;
}
}
*Skip = TRUE;
}
above sample will not create directory structure at all - but still would copy all .txt files to differently named files on local disk. NOTE: this callback is called only if you have created an instance of the SftpEventsStruct structure, and set its LoopItem member to the function implementing it.