Here's the function that I get stuck on. Right at the closign brace:
Code:
FileBrowse::ResetFpath("recording:[000000]");
int radioState =0;
char location = 'N';
char buffer[100];
FileBrowse ConnectFile;
CString localfile;
CButton* pRadio = (CButton*)GetDlgItem(IDR_TO);
radioState = pRadio->GetCheck();
if(radioState)
location = 'T';
radioState = 0;
pRadio = (CButton*)GetDlgItem(IDR_MO);
radioState = pRadio->GetCheck();
if(radioState)
location = 'M';
radioState = 0;
pRadio = (CButton*)GetDlgItem(IDR_LO);
radioState = pRadio->GetCheck();
if(radioState)
location = 'L';
if(location == 'N')
{
wsprintf(buffer, "Please select a location of the .baf file first.");
MessageBox(buffer, NULL, MB_OK | MB_ICONEXCLAMATION);
return;
}
CInternetSession isession;
CFtpConnection* pConnect;
CString Server;
if(location == 'L')
{
CMyFileDialog FileDlg(TRUE,0,0,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,0,this);
if(FileDlg.DoModal() == IDOK)
{
localfile = FileDlg.GetPathName();
CEdit* pEditSelFile = (CEdit*)GetDlgItem(IDE_FILEPATH);
pEditSelFile->SetWindowText(localfile);
}
InBAF::SetLocation(location);
return;
}
else
{
InBAF::SetLocation(location);
InBAF::SetServerName(location);
Server = InBAF::GetServerName();
}
pConnect = isession.GetFtpConnection(_T(Server), "USER");
//CMyConnection::InitConnection(pConnect);
pConnect->SetCurrentDirectory("recording");
FILE *out = fopen("H:\\GUI\\testInet-main.txt", "w");
CFtpFileFind finder(pConnect);
CListBox* pListMain = (CListBox*)GetDlgItem(IDLB_MAINDIR);
CListBox* pListSub = (CListBox*)GetDlgItem(IDLB_SUBDIR);
// Find the first file
BOOL bWorking = finder.FindFile(NULL);
CString rfname, nfname;
// Go through the rest of the directory and designate files.
while (bWorking)
{
bWorking = finder.FindNextFile();
rfname = finder.GetFilePath();
if (strstr(rfname, ".BAF"))
{
nfname = ConnectFile.MakeName(rfname);
pListSub->AddString(nfname);
fprintf(out, "\t\t\tSub: %s\n", nfname);
}
else if(strstr(rfname, ".DIR"))
{
nfname = ConnectFile.MakeName(rfname);
pListMain->AddString(nfname);
fprintf(out, "\t\t\tMain: %s\n", nfname);
}
rfname.Empty();
nfname.Empty();
}
// Display current directory in edit box
CEdit* pEditSelFile = (CEdit*)GetDlgItem(IDE_FILEPATH);
CString filepath = FileBrowse::GetFPath();
pEditSelFile->SetWindowText(filepath);
// if the connection is open, close it
if (pConnect != NULL)
pConnect->Close();
delete pConnect;
fclose(out);
}
I know it's a visual app, but I tested that part of the code and it should be fine. The other class is this ,FileBrowse:
Code:
class FileBrowse
{
private:
static CString fpath;
public:
//CString rfname , nfname ;
void SetFPath(CString rfname)
{
char temp[8];
int index, indexn, i, k=0;
index = rfname.Find('/');
i=(index+1);
if(strstr(rfname,".DIR"))
indexn = rfname.Find(".DIR");
else if(strstr(rfname,".LSH"))
indexn = rfname.Find(".LSH");
while(i<indexn && k<8)
{
temp[k] = rfname[i];
k++; i++;
}
temp[k] = '\0';
indexn = fpath.ReverseFind(']');
fpath.SetAt(indexn, '.');
fpath= fpath + temp +']';
}
void PrintFpath(FILE* out)
{
fprintf(out, "\t\t>%s<\n", fpath);
}
static CString GetFPath()
{
return fpath;
}
CString MakeName(CString rfname)
{
char temp[14] = {0};
int index, indexn, i, k=0;
CString nfname;
index = rfname.Find('/');
i=(index+1);
if(strstr(rfname,".DIR"))
{
indexn = rfname.Find(".DIR");
while(i<(indexn) && k<14)
{
temp[k] = rfname[i];
k++; i++;
}
temp[k] = '\0';
}
else
{
indexn = rfname.Find(".BAF");
while(i<(indexn+4) && k<14)
{
temp[k] = rfname[i];
k++; i++;
}
temp[k] = '\0';
return nfname = temp;
}
nfname = fpath;
indexn = nfname.ReverseFind(']');
nfname.SetAt(indexn, '.');
nfname = nfname + temp + ']';
return nfname;
}
static ResetFpath(CString newpath)
{
fpath = newpath;
}
};
CString FileBrowse::fpath = "]";
Sorry it's so lengthy.