libssh2_sftp_seek(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_seek β€” setting the read/write position indicator within a file πŸ’–

okay bestie, come sit with me, we're talking about libssh2_sftp_seek from the libssh2 manual, section 3. it's giving ✨file pointer energy✨ and honestly? it's a whole mood.


✨ SYNOPSIS ✨

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

void
libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle,
                  size_t offset);

like yes, two includes, one function, zero drama (except the deprecation, we'll get there 🫣).


πŸ¦‹ DESCRIPTION πŸ¦‹

🚨 Deprecated function. Use libssh2_sftp_seek64(3) instead! not me telling you the sequel is better, but the sequel IS better. this one is the legacy queen and we respect her, but fr fr go use libssh2_sftp_seek64(3). πŸ’…

now the deets:

  • handle β€” an SFTP File Handle, exactly the kind you get handed back by libssh2_sftp_open_ex(3). it's your little ticket to the file, keep it safe πŸŽ€
  • offset β€” how many bytes from the beginning of the file you wanna seek to. literally just a byte count from the start. that's it, that's the number 🌸

so what does it actually DO? it moves the file handle's internal pointer to an arbitrary location. any spot you want in the file, it'll park the pointer there. main character chooses her own location, periodt. πŸ‘‘

but here's the tea β˜• β€” and this part is important, so don't skim it:

libssh2 implements file pointers as a localized concept. that means it's keeping that pointer right here, on your side, purely so that file access appears more POSIX like. it's cosplay. it's aesthetic. it's for your convenience. 🧚

no packets are exchanged with the server during a seek operation. none. zero. the server literally does not hear about it. πŸ™ˆ

and that localized file pointer? it gets used as a convenience offset during read/write operations. so it's not doing nothing β€” it's just doing it locally, and it matters when you go to read or write. 🌈


πŸ‘‘ SEE ALSO πŸ‘‘

(go read libssh2_sftp_seek64(3), she's the one you actually want. iykyk πŸ’œ)


πŸŽ€ a lil sign-off πŸŽ€

this page is brought to you by libssh2 1.0, dated 22 Dec 2008 β€” a vintage icon, an elder, a legend who was ahead of her time. she's been sitting here since 2008 serving localized file pointer realness and honestly? we stan. ⭐

okay that's the whole page bestie, go forth and seek responsibly, and remember: deprecated means use the other one. bye!! πŸ¦‹πŸ’–βœ¨