Skip to content

Commit

Permalink
feat(DmSegment): add getters for GUID and name
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed May 3, 2024
1 parent 693e5ff commit 726c829
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/dmusic.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ DMAPI void DmSegment_release(DmSegment* slf);
/// \retval #DmResult_MEMORY_EXHAUSTED A dynamic memory allocation failed.
DMAPI DmResult DmSegment_download(DmSegment* slf, DmLoader* loader);

/// \brief Get the GUID of the given segment.
/// \note The returned pointer is only valid for as long as a strong reference to the segment is held.
/// \param slf[in] The segment to get the GUID of.
/// \return A read-only pointer to the segment's GUID.
DMAPI DmGuid const* DmSegment_getGuid(DmSegment const* slf);

/// \brief Get the name of the given segment.
/// \note The returned pointer is only valid for as long as a strong reference to the segment is held.
/// \param slf[in] The segment to get the name of.
/// \return A read-only pointer to the segment's name in UTF-8.
DMAPI char const* DmSegment_getName(DmSegment const* slf);

/// \}

/// \defgroup DmLoaderGroup Loader
Expand Down
16 changes: 16 additions & 0 deletions src/Segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,19 @@ DmResult DmSegment_download(DmSegment* slf, DmLoader* loader) {
slf->downloaded = true;
return rv;
}

DmGuid const* DmSegment_getGuid(DmSegment const* slf) {
if (slf == NULL) {
return NULL;
}

return &slf->guid;
}

char const* DmSegment_getName(DmSegment const* slf) {
if (slf == NULL) {
return NULL;
}

return slf->info.unam;
}

0 comments on commit 726c829

Please sign in to comment.