libssh2_sftp_seek64(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_seek64 πŸ’–

okay so bestie, this is a page from the libssh2 manual, and today's main character is libssh2_sftp_seek64 β€” the little function that sets the read/write position inside a file. no cap, that's the whole job. let's get into it 🫢


✨ NAME ✨

libssh2_sftp_seek64 β€” set the read/write position within a file


🌸 SYNOPSIS 🌸

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

void
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle,
                    libssh2_uint64_t offset);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea on the arguments, bestie:

  • handle β€” an SFTP File Handle, the kind you get back from libssh2_sftp_open_ex(3). that's your lil ticket to the file πŸŽ€
  • offset β€” how many bytes from the beginning of the file you wanna seek to. count them from the top, starting at zero-ish energy ✨

what it does: it moves the file handle's internal pointer to any arbitrary location you want. it's giving "teleport but for file positions" πŸ’…

and here's the cute design detail β€” libssh2 implements file pointers as a localized concept, purely so that file access looks and feels more POSIX-like. it's all for the vibe, okay? and the best part: no packets are exchanged with the server during a seek operation. zero. none. the server literally doesn't hear about it. the localized file pointer just sits there being a convenient offset for your read/write operations later. iconic behavior honestly πŸ‘‘

🚨 BIG WARNING, FR FR, READ THIS TWICE 🚨 You MUST NOT seek during writing or reading a file with SFTP. like, don't. the internals are out here juggling outstanding packets, and changing the "file position" while stuff is in transit will result in badness. not the cute kind of badness. the actual kind. πŸ’€

⭐ AVAILABILITY ⭐

Added in 1.0 β€” so she's been around a minute, an OG fr fr 🌈


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page!! this one's from the libssh2 manual, dated 22 Dec 2008 β€” yeah, 2008, she's vintage and still slaying πŸ’œ mwah, go read the docs, ily πŸ«ΆπŸ’–