PowerPlant FTP transfer

PowerPlant FTP transfer

Post by petteri.kampp.. » Tue, 01 Sep 1998 04:00:00

Hi all!

I _need_ help writing an application that fetches files with FTP.
I'm using CW Pro 1. It's a really small app, almost no user interface.
It needs to get a couple of files from a FTP server. I'm looking for the
simplest way to do this. I thought PowerPlant's Internet Classes
would be really simple, almost just call FTPConnection.GetFile().
Well, they are, but the thread stuff confuses me.

Could someone tell me what's wrong with this code, or offer me
a simpler solution to do simple FTP transfers.

I do this in my main, and never get to GetFile. Connect crashes
every time.

        LThread *mainThread = new UMainThread;
        LSimpleThread   *theThread = new LSimpleThread(GetFileFromFTP,

void GetFileFromFTP(LThread& inThread, void* arg)
        FSSpec  theFile;
        GetApplicationFSSpec(&theFile);     // Make file in the same directory as the app
        GetIndString(theFile.name, kFileNamesAndPaths, kAllFiles);      // Get file name
        LFile   allfilesTxt(theFile);
        cout << "Created file\n";

        LFTPConnection  ftp(inThread);
        cout << "Created ftp connection\n";

        cout << "Connected to ftp.funet.fi\n";

        ftp.GetFile(FTPImageXfer, "/pub/mac/info-mac/help/all-files.txt",
&allfilesTxt, false);
        cout << "Received file\n";

        cout << "Disconnected\n";


OSErr GetApplicationFSSpec(FSSpec *theFS)
        OSErr                           oe;
        ProcessSerialNumber     psn;
        ProcessInfoRec          info;

        if (oe==noErr)
                oe=GetProcessInformation(&psn, &info);

        return oe;


Thanks in advance, I'd really appreciate an answer.



PowerPlant FTP transfer

Post by petteri.kampp.. » Thu, 03 Sep 1998 04:00:00

I discovered what was wrong. Or actually missing. I needed a event loop.
The code I used was in a SIOUX app, and the thread got destroyed before
the FTP functions had time to complete and that was crashing the machine.
Well, anyway, thanks for Metrowerks for PowerPlant. It saved my day!



1. ftp transfer with powerplant

I am new to Mac programming(used to comand line unix) and c++ and need
to do a palm conduit for Macs to sync with our university web
calendar. As part of the conduit, I need to ftp a xml file from and to
a unix server. The file name is always the same name so I don't need
any GUI interface, just download in the background. I tried to modify
the example code that came with PowerPlant and it seems to work until
tryingto access the server. The program doesn't crash but looking at
the server logs, it never attempts to connect. Could someone please
look at my code and tell me what's wrong.

Code follows:
#include <LFTPConnection.h>
#include <fstream.h>
#include <iostream.h>
#include <string.h>

class CFTPThread : public LThread
        virtual void* Run();

                : LThread(false,
thread_DefaultStack,threadOption_Default, nil)


void * CFTPThread::Run()

 EFTPTransferType       typeCode = FTPASCIIXfer;

 Str63 theFileName = "\ptest";
 LFile theSaveFile;

 FSSpec aSpec;
 OSErr theFSSpecErr = ::FSMakeFSSpec(0,0,theFileName, &aSpec);

//creates this file
 theSaveFile.CreateNewDataFile('????', 'TEXT');

 LFTPConnection ftp(*this);

//prints this line
 cout << "Created ftp connection\n";


 ftp.GetFile( "\ptesting.here.now,"test", "qwaszx", "",FTPASCIIXfer,
LString::PToCStr(theFileName), &theSaveFile);

//never prints this line
 cout << "Received file\n";

 return nil;

 void main()
 LThread *mainThread = new UMainThread;

 CFTPThread     theApp;

Thanks for the help

2. Need Windows Admin, Netwok Admin, Storage Admin, Dallas TX

3. multiple FTP transfers

4. Select not producing desired results

5. ftp using powerplant

6. Multiple packages

7. PowerPlant FTP Site?

8. HELP! Monitor Setup...

9. Mac to UNIX file transfer

10. DLL Debugging Mac -> Windows, automatic transfer of DLL?

11. DMA SCSI transfers

12. Problem opening transferred file

13. infrared transferring