how to determine if a object dir or file is? - WeOnlyDo Discussion board

how to determine if a object dir or file is? (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Jan, Thursday, February 17, 2005, 12:00 (7018 days ago)

Hello,

I have now a list of objects created with
ListNames() method.

I must know, if a list member dir or file is.

So, I check an exception:
try
{
bDir = false;
if(!pFtpCom->CheckDir(lpTestDir))
{
bDir = true;
}
} catch(...){pFtpCom->PutLastError(0);};

if(!bDir)
try
{
pFtpCom->GetFile(vLclDir,name);
}
catch(...)
{
pFtpCom->get_LastError(&LastError);
_bstr_t err = pFtpCom->GetErrorText(LastError);
printf( ( d ) s
,LastError,(LPSTR)err);
pFtpCom->PutLastError(0);
}
}

It works with error:
If the first item found is a dir, and the next one a file,
it will be the next exception thrown. It should not!

If the first item found is a file, it will be get without any exception.

Is there any other workaround, how to determine if an list item
dir or file is?

Thanks
Jan

[:wink:]

Re: how to determine if a object dir or file is?

by wodSupport, Thursday, February 17, 2005, 13:43 (7018 days ago) @ Jan

Jan,

why don't you use DirItems.Type property for this?

Re: how to determine if a object dir or file is?

by Jan, Thursday, February 17, 2005, 14:20 (7018 days ago) @ wodSupport

why don't you use DirItems.Type property for this?

In order to access this property, I must call ListDir method first .
I do not call ListDir.
I call ListNames.

As a target I get a list of files and dirs.
So, I must reject all dir from this list.
As a rejecting result it left only some files, I can download.
It is a pitty there is not any method ListAllFilesInDir


Thanks
Jan
[:sad:]

Re: how to determine if a object dir or file is?

by wodSupport, Thursday, February 17, 2005, 14:45 (7018 days ago) @ Jan

Jan,

there can be no methods to list only files. This all depends on FTP protocol and what will server send us, we cannot create new commands and violate the protocol. You can use ListDir and perhaps set different ListParams that will cause your server to send only file names. But as I said - this all depends on the server.

Re: how to determine if a object dir or file is?

by Jan, Thursday, February 17, 2005, 14:52 (7018 days ago) @ wodSupport

Hello,

So, is there any simple method to get a type of file/dir?
If I have to names:
name1 // file
name2 // directory
get by ListNames.

How do I know what of them is dir/file ?

Many thanks!

Jan
[:smile:]

Re: how to determine if a object dir or file is?

by wodSupport, Thursday, February 17, 2005, 14:54 (7018 days ago) @ Jan

You cannot. Servers will usually add / at the end of dir, but this isn't true in all 100 cases.