GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’… GOLF(2gg) β€” the file-position glow-up ✨

okay bestie so this is a page from the GOLF(2gg) manual, in the Development section, and it's about file-position. it's giving "let's find out where we are in a file, or yeet ourselves to a new spot" energy. no cap. πŸŽ€


✨ NAME ✨

file-position β€” (files) πŸ—‚οΈ


🎯 PURPOSE 🎯

set a position, or get the current position, for a file that's already open. that's it, that's the whole vibe. πŸ’–


πŸ“œ SYNTAX πŸ“œ

file-position file-id <file id> \
    ( set <position> ) | ( get <position> ) \
    [ status <status> ]

🌸 DESCRIPTION 🌸

file-position will set or get the position for a file that you opened with open-file, where <file id> is an open file identifier. 🫢

  • if the "set" clause is used, the file position gets set to <position> (and yes, 0 is the first byte, we start counting at zero like the little gremlins we are πŸ“)
  • if the "get" clause is used, the file position gets obtained into <position> (again, 0 is the first byte πŸ‘‘)

the <status> number in the "status" clause will be GG_OKAY if the set/get succeeded, GG_ERR_OPEN if the file isn't open, or GG_ERR_POSITION if not. lowkey a whole mood board of outcomes. πŸ’€

⚠️ okay important one, bestie: setting the position past the last byte of the file is okay for writing β€” in this case the bytes between the end of file and the <position> are filled with null-bytes when the write operation occurs. so like, it works, but the gap is just a lil void of null-bytes. 🌈

πŸ’« EXAMPLES πŸ’«

open the file "testwrite", set the file byte position to 100, then obtain it later:

open-file "testwrite" file-id nf
file-position file-id nf set 100
...
file-position file-id nf get pos

See also open-file. πŸ¦‹


πŸ‘€ SEE ALSO πŸ‘€

Files 🌸

change-mode close-file copy-file delete-file file-position file-storage file-uploading lock-file open-file read-file read-line rename-file stat-file temporary-file uniq-file unlock-file write-file β€” See all documentation πŸ”₯


and that's the whole page, periodt. πŸ’… this one's from $DATE, version $VERSION, out of the GOLF(2gg) manual β€” tysm for reading, ily, go set some file positions responsibly πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from