libssh2_sftp_rename_ex(3)
β¨ 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 bylibssh2_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 theLIBSSH2_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 theLIBSSH2_SFTP_RENAME_OVERWRITEflag is not set and thedestfileentry 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 π π
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms