SFTP OnDirectoryList compile error using BCB5

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
gw
Posts: 16
Joined: Fri 05 Nov 2010 12:55

SFTP OnDirectoryList compile error using BCB5

Post by gw » Tue 15 Mar 2011 18:22

Hi!

here is my 'OnDirectoryList' event function that i can't compile. The frame was autogenerated by BCB5, and i just added one line of code:

Code: Select all

void __fastcall TSftpForm::ScSFTPClientDirectoryList(TObject *Sender,
      const AnsiString Path, const TBytes Handle,
      TScSFTPFileInfo *FileInfo, bool EOF)
{
  FilenameList->Add(FileInfo->Filename);
}
Borland C++Builder 5 (Enterprise) won't compile the line with the function implementation: Error: E2451 Undefined symbol 'TObject'.

My 'OnError'-event function compiles well, instead:

Code: Select all

void __fastcall TSftpForm::ScSFTPClientError(TObject *Sender,
      TScSFTPOperation Operation, const AnsiString FileName,
      const TBytes Handle, int ErrorCode, const AnsiString ErrorMessage,
      bool &Fail)
{
  AnsiString Msg;

  switch (Operation) {
    case opMakingDirectory: Msg = LoadStr(FTP_MKDIR_ERROR); break;
    case opRemovingFile: Msg = LoadStr(FTP_DEL_ERROR); break;
    case opRemovingDirectory: Msg = LoadStr(FTP_RMDIR_ERROR); break;
    case opRenamingFile: Msg = LoadStr(FTP_REN_ERROR); break;
    default: Msg = ""; break;
  }
  if (Msg != "")
    AddMessage(Msg,(TColor) FTP_MEMO_COLOR_FAILURE);
  FtpError = true;
  Fail = true;
}
Any idea what is wrong? Any help how to solve? Are there any more/better examples/demos written in C++ to check?

thanks
/gw

gw
Posts: 16
Joined: Fri 05 Nov 2010 12:55

Update

Post by gw » Wed 16 Mar 2011 12:35

The problem also seems to have to do with the 'EOF' statement (see my other post 'SFTP ReadDirectory/EOF compile error using BCB5').
If i rename it to 'xEOF' (see updated code below) it compiles well.
My includes are (among others): and . May this be a problem?

Code: Select all

void __fastcall TSftpForm::ScSFTPClientDirectoryList(TObject *Sender, 
      const AnsiString Path, const TBytes Handle, 
      TScSFTPFileInfo *FileInfo, bool xEOF) 
{ 
  FilenameList->Add(FileInfo->Filename); 
}
Hope to get some good ideas soon ;)

Thanks
/gw

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 28 Mar 2011 09:54

To solve the problem you can add the following lines in the beginning of your cpp unit:

Code: Select all

#ifdef EOF
#undef EOF
#endif

gw
Posts: 16
Joined: Fri 05 Nov 2010 12:55

Post by gw » Wed 06 Apr 2011 08:47

Hi!

I changed code to this:

Code: Select all

#ifdef EOF 
#undef EOF 
#endif

Scclrclasses::TBytes Handle; 

Handle = ScSFTPClient->OpenDirectory("Test"); 
try 
{ 
  do 
  { 
     ScSFTPClient->ReadDirectory(Handle); 
  } while (!(ScSFTPClient->EOF)); 
__finally { 
  ScSFTPClient->CloseHandle(Handle); 
}

void __fastcall TSftpForm::ScSFTPClientDirectoryList(TObject *Sender, 
      const AnsiString Path, const TBytes Handle, 
      TScSFTPFileInfo *FileInfo, bool EOF) 
{ 
  FilenameList->Add(FileInfo->Filename); 
}
Now it compiles without error, but when executed i get an runtime error in the 'ScSFTPClientDirectoryList' function.

I have it running with my workaround, just want to give a reply that there still seems to be a problem.

/gw

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 06 Apr 2011 14:25

Please do not duplicate topics. We have answered you in other thread.

Post Reply