]>
git.bts.cx Git - benzene.git/blob - src_platform/playdate/bz/resources/resource.c
1 #include <bz/resources/resource.h>
3 #include <bz/memory/allocator.h>
4 #include <bz/resources/identifier.h>
5 #include <playdate/entrypoint.h>
8 struct BZResource
{ SDFile
*unused
; };
10 BZResourceID
bzResourcesOpenResource(const char *type
, const char *identifierFmt
, ...) {
11 bzMakeIdentifier(identifier
, identifierFmt
);
12 bzLog("Trying to load: %s", identifier
);
14 BZResourceID resource
= (BZResourceID
)playdate
->file
->open(identifier
, kFileRead
);
18 extern void bzResourcesCloseResource(BZResourceID resource
) {
19 SDFile
*handle
= (SDFile
*)resource
;
20 playdate
->file
->close(handle
);
23 size_t bzResourcesFileLength(BZResourceID resource
) {
24 SDFile
*handle
= (SDFile
*)resource
;
28 reset
= playdate
->file
->tell(handle
);
29 playdate
->file
->seek(handle
, 0, SEEK_END
);
30 size
= playdate
->file
->tell(handle
);
31 playdate
->file
->seek(handle
, reset
, SEEK_SET
);
36 size_t bzResourcesTell(BZResourceID resource
) {
37 SDFile
*handle
= (SDFile
*)resource
;
38 return playdate
->file
->tell(handle
);
41 size_t bzResourcesSeek(BZResourceID resource
, size_t position
) {
42 SDFile
*handle
= (SDFile
*)resource
;
43 return playdate
->file
->seek(handle
, position
, SEEK_SET
);
46 size_t bzResourcesReadBytes(BZResourceID resource
, void *outputBuffer
, size_t numBytes
) {
47 SDFile
*handle
= (SDFile
*)resource
;
48 return playdate
->file
->read(handle
, outputBuffer
, numBytes
);