home *** CD-ROM | disk | FTP | other *** search
/ ftp.ncftp.com / ftp.ncftp.com.zip / ftp.ncftp.com / ncftp / older_versions / ncftp-3.2.2-src.tar.bz2 / ncftp-3.2.2-src.tar / ncftp-3.2.2 / libncftp / c_sizemdtm.c < prev    next >
C/C++ Source or Header  |  2005-01-01  |  1KB  |  51 lines

  1. /* c_sizemdtm.c
  2.  *
  3.  * Copyright (c) 1996-2005 Mike Gleason, NcFTP Software.
  4.  * All rights reserved.
  5.  *
  6.  */
  7.  
  8. #include "syshdrs.h"
  9. #ifdef PRAGMA_HDRSTOP
  10. #    pragma hdrstop
  11. #endif
  12.  
  13. int
  14. FTPFileSizeAndModificationTime(const FTPCIPtr cip, const char *const file, longest_int *const size, const int type, time_t *const mdtm)
  15. {
  16.     MLstItem mlsInfo;
  17.     int result;
  18.  
  19.     if (cip == NULL)
  20.         return (kErrBadParameter);
  21.     if (strcmp(cip->magic, kLibraryMagic))
  22.         return (kErrBadMagic);
  23.  
  24.     if ((mdtm == NULL) || (size == NULL) || (file == NULL))
  25.         return (kErrBadParameter);
  26.  
  27.     *mdtm = kModTimeUnknown;
  28.     *size = kSizeUnknown;
  29.  
  30.     result = FTPSetTransferType(cip, type);
  31.     if (result < 0)
  32.         return (result);
  33.  
  34.     result = FTPMListOneFile(cip, file, &mlsInfo);
  35.     if (result < 0) {
  36.         /* Do it the regular way, where
  37.          * we do a SIZE and then a MDTM.
  38.          */
  39.         result = FTPFileSize(cip, file, size, type);
  40.         if (result < 0)
  41.             return (result);
  42.         result = FTPFileModificationTime(cip, file, mdtm);
  43.         return (result);
  44.     } else {
  45.         *mdtm = mlsInfo.ftime;
  46.         *size = mlsInfo.fsize;
  47.     }
  48.  
  49.     return (result);
  50. }    /* FTPFileSizeAndModificationTime */
  51.