MCPcopy Create free account
hub / github.com/defold/defold / MapFile

Function MapFile

engine/resource/src/mount/mount_android.cpp:73–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71 }
72
73 Result MapFile(const char* path, void*& out_map, uint32_t& out_size)
74 {
75 int fd = open(path, O_RDONLY);
76 if (fd < 0)
77 {
78 return RESULT_RESOURCE_NOT_FOUND;
79 }
80
81 struct stat fs;
82 if (fstat(fd, &fs))
83 {
84 close(fd);
85 return RESULT_IO_ERROR;
86 }
87
88 out_map = mmap(0, fs.st_size, PROT_READ, MAP_SHARED, fd, 0);
89 close(fd);
90
91 if (!out_map || out_map == (void*)-1)
92 {
93 return RESULT_IO_ERROR;
94 }
95
96 out_size = fs.st_size;
97
98 return RESULT_OK;
99 }
100
101 Result UnmapAsset(void*& asset, uint32_t size)
102 {

Callers 2

MountManifestFunction · 0.70
MountArchiveInternalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected