PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/ncftp-3.2.5/libncftp/c_rename.c

#
C | 44 lines | 32 code | 6 blank | 6 comment | 17 complexity | 37c0d24c54b0dbfdf35b45dd605239cf MD5 | raw file
Possible License(s): AGPL-3.0
  1. /* c_rename.c
  2. *
  3. * Copyright (c) 1996-2005 Mike Gleason, NcFTP Software.
  4. * All rights reserved.
  5. *
  6. */
  7. #include "syshdrs.h"
  8. #ifdef PRAGMA_HDRSTOP
  9. # pragma hdrstop
  10. #endif
  11. int
  12. FTPRename(const FTPCIPtr cip, const char *const oldname, const char *const newname)
  13. {
  14. int result;
  15. if (cip == NULL)
  16. return (kErrBadParameter);
  17. if (strcmp(cip->magic, kLibraryMagic))
  18. return (kErrBadMagic);
  19. if ((oldname == NULL) || (oldname[0] == '\0'))
  20. return (kErrBadParameter);
  21. if ((newname == NULL) || (oldname[0] == '\0'))
  22. return (kErrBadParameter);
  23. result = FTPCmd(cip, "RNFR %s", oldname);
  24. if (result < 0)
  25. return (result);
  26. if (result != 3) {
  27. cip->errNo = kErrRenameFailed;
  28. return (cip->errNo);
  29. }
  30. result = FTPCmd(cip, "RNTO %s", newname);
  31. if (result < 0)
  32. return (result);
  33. if (result != 2) {
  34. cip->errNo = kErrRenameFailed;
  35. return (cip->errNo);
  36. }
  37. return (kNoErr);
  38. } /* FTPRename */