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_chdir.c next >
C/C++ Source or Header  |  2005-01-01  |  852b  |  44 lines

  1. /* c_chdir.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. FTPChdir(const FTPCIPtr cip, const char *const cdCwd)
  15. {
  16.     int result;
  17.  
  18.     if (cip == NULL)
  19.         return (kErrBadParameter);
  20.     if (strcmp(cip->magic, kLibraryMagic))
  21.         return (kErrBadMagic);
  22.  
  23.     if (cdCwd == NULL) {
  24.         result = kErrInvalidDirParam;
  25.         cip->errNo = kErrInvalidDirParam;
  26.     } else {
  27.         if (cdCwd[0] == '\0')    /* But allow FTPChdir(cip, ".") to go through. */
  28.             result = 2;    
  29.         else if (strcmp(cdCwd, "..") == 0)
  30.             result = FTPCmd(cip, "CDUP");
  31.         else
  32.             result = FTPCmd(cip, "CWD %s", cdCwd);
  33.         if (result >= 0) {
  34.             if (result == 2) {
  35.                 result = kNoErr;
  36.             } else {
  37.                 result = kErrCWDFailed;
  38.                 cip->errNo = kErrCWDFailed;
  39.             }
  40.         }
  41.     }
  42.     return (result);
  43. }    /* FTPChdir */
  44.