gd_rewrite_fragment(3)
π gd_rewrite_fragment(3) β GETDATA π
okay bestie, pull up a chair, because we're about to talk about gd_rewrite_fragment(3) from the GETDATA manual, and honestly? she's giving "quietly essential". no cap.
β¨ NAME β¨
gd_rewrite_fragment β re-write a Dirfile format specification fragment π
π¦ SYNOPSIS π¦
#include <getdata.h>
int gd_rewrite_fragment(DIRFILE *dirfile, int fragment);
πΈ DESCRIPTION πΈ
so here's the tea: gd_rewrite_fragment() writes the format specification fragment you picked β the one named by fragment β straight to disk, and it does this regardless of whether it has changed or not, just straight up overwriting the existing file. no vibe check, no "did u mean to do that", it just goes. π₯
and plot twist: fragment doesn't have to be a plain old valid fragment index. it can also be the special value GD_ALL_FRAGMENTS, which means "bestie, rewrite every single fragment", periodt.
the metadata gets written to disk using the current Standards Version as stored in the dirfile object. wanna change it or just report it? go see gd_dirfile_standards(3), she handles all of that. and uh β if your dirfile metadata conforms to no known Standards Version at all? yeah, a Standards non-compliant fragment will be written. iconic behaviour, honestly. π
π RETURN VALUE π
slay on success: zero is returned. π
on error: a negative-valued error code comes back. the possible error codes are, in order:
GD_E_ACCMODEβ the dirfile you handed over was opened in read-only mode. read-only means read-only, bestie. πGD_E_ALLOCβ the library could not allocate memory. she tried, the memory said no.GD_E_BAD_DIRFILEβ the supplied dirfile was invalid. not it. π«GD_E_BAD_INDEXβ the fragment index you supplied was out of range.GD_E_IOβ an I/O error happened while trying to write modified metadata to disk.GD_E_LINE_TOO_LONGβ while attempting to flush modified metadata to disk, a field specification line exceeded the maximum allowed length. on most platforms that maximum length is at least2**31bytes, so if you're seeing this, it typically indicates something pathological is happening. like, girl, what are you doing. π
also! the error code is stored in the DIRFILE object too, so you can grab it after this function returns by calling gd_error(3). and if you want a descriptive error string for whatever went wrong, hit up gd_error_string(3). π«Ά
π BUGS π
when writing metadata using Standards Version 4 or earlier, the reference field may change, owing to the lack of a /REFERENCE directive. the work-around is to upgrade to Standards Version 5 or later. consider this your sign to upgrade, fr fr.
π HISTORY π
- the
gd_rewrite_fragment()function appeared in GetData-0.7.0. a whole era. β - in GetData-0.10.0, the error return from this function changed from
-1to a negative-valued error code.
π SEE ALSO π
gd_close(3), gd_dirfile_standards(3), gd_error(3), gd_error_string(3), gd_flush(3), gd_metaflush(3), gd_open(3)
and that's the whole page, bestie β Version 0.10.0, dated 25 December 2016, from the gd_rewrite_fragment(3) page in the GETDATA manual. go forth and rewrite those fragments responsibly. mwah. πβ¨π§
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2010, 2011, 2014, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms