libssh2_sftp_rename_ex(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ libssh2_sftp_rename_ex β€” rename an SFTP file ✨

okay bestie, welcome to the libssh2 manual, page libssh2_sftp_rename_ex(3). this is the glow-up your remote filenames have been waiting for πŸ’…


🌸 NAME 🌸

libssh2_sftp_rename_ex β€” rename an SFTP file


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libssh2.h>
#include <libssh2_sftp.h>

int
libssh2_sftp_rename_ex(LIBSSH2_SFTP *sftp,
                       const char *source_filename,
                       unsigned int source_filename_len,
                       const char *dest_filename,
                       unsigned int dest_filename_len,
                       long flags);

int
libssh2_sftp_rename_ex(LIBSSH2_SFTP *sftp,
                       const char *source_filename,
                       const char *dest_filename);

two whole flavours, and you get to pick. iconic of them tbh 🫢


πŸ’– DESCRIPTION πŸ’–

  • sftp β€” the SFTP instance, as returned by libssh2_sftp_init(3). yes, you gotta have one, it's the whole vibe.
  • sourcefile β€” path and name of the existing filesystem entry. the thing that's currently sitting there being itself.
  • sourcefile_len β€” length of the path and name of the existing filesystem entry.
  • destfile β€” path and name of the target filesystem entry. where it's headed, main character relocation.
  • destfile_len β€” length of the path and name of the target filesystem entry.
  • flags β€” a bitmask of flags made up of the LIBSSH2_SFTP_RENAME_* constants.

so like. this renames a filesystem object on the remote filesystem. the semantics of this command typically include the ability to move a filesystem object between folders and/or filesystem mounts β€” so it's not just a lil rename, it can literally relocate across mounts, no cap.

🚨 if the LIBSSH2_SFTP_RENAME_OVERWRITE flag is not set and the destfile entry already exists, the operation will fail. periodt. it's not gonna quietly clobber anything for you.

and the other two flags? using them is a preference, not a requirement β€” they signal you'd like the remote end to perform an atomic rename operation and/or use native system calls when possible. it's giving "asking nicely", not "demanding". πŸ™ˆ


⭐ RETURN VALUE ⭐

returns 0 on success, or a negative number on failure. it returns LIBSSH2_ERROR_EAGAIN when it would otherwise block.

and listen β€” while LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se. it's just the "not right now bestie, try again later" of error codes. don't panic. πŸ’œ


πŸ’€ ERRORS πŸ’€

  • LIBSSH2_ERROR_ALLOC β€” an internal memory allocation call failed.
  • LIBSSH2_ERROR_SOCKET_SEND β€” unable to send data on socket.
  • LIBSSH2_ERROR_SOCKET_TIMEOUT β€”
  • LIBSSH2_ERROR_SFTP_PROTOCOL β€” an invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server.

(yes the timeout one is just vibes and a dash, that's literally all the original gives us, we do not make things up here πŸŽ€)


🌈 SEE ALSO 🌈


and that's the whole page, bestie β€” go forth and rename things with confidence πŸ¦‹βœ¨

libssh2 0.15 Β· 1 Jun 2007 β€” yeah she's vintage, she's a classic, she still slays πŸ’…πŸ‘‘