#define kFTPFileExistsNlstTestMessage "This file was created by an FTP client program using the LibNcFTP toolkit. A temporary file needed to be created to ensure that this directory was not empty, so that the directory could be listed with the guarantee of at least one file in the listing.\r\n\r\nYou may delete this file manually if your FTP client program does not delete it for you.\r\n"
(strstr(fileList.last->line, "o Such File") == NULL) &&
(strstr(fileList.last->line, "ot Found") == NULL)
) {
/* The item existed. */
result = kNoErr;
} else {
cip->errNo = kErrNLSTFailed;
result = kErrNLSTFailed;
}
DisposeLineListContents(&fileList);
return (result);
} /* FTPFileExistsNlst*/
/* This functions goes to a great deal of trouble to try and determine if the
* remote file specified exists. Newer servers support commands that make
* it relatively inexpensive to find the answer, but older servers do not
* provide a standard way. This means we may try a whole bunch of things,
* but the good news is that the library saves information about which things
* worked so if you do this again it uses the methods that work.
*/
int
FTPFileExists2(const FTPCIPtr cip, const char *const file, const int tryMDTM, const int trySIZE, const int tryMLST, const int trySTAT, const int tryNLST)
{
int result;
time_t mdtm;
longest_int size;
MLstItem mlsInfo;
if (tryMDTM != 0) {
result = FTPFileModificationTime(cip, file, &mdtm);
if (result == kNoErr)
return (kNoErr);
if (result == kErrMDTMFailed) {
cip->errNo = kErrNoSuchFileOrDirectory;
return (kErrNoSuchFileOrDirectory);
}
/* else keep going */
}
if (trySIZE != 0) {
result = FTPFileSize(cip, file, &size, kTypeBinary);