MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / _File_Init_AddFileInRootDir

Function _File_Init_AddFileInRootDir

src/file.c:331–349  ·  view source on GitHub ↗

* Memorize a file from the data/ directory. * * @param filename The name of the file. * @param filesize The size of the file. * @return A pointer to the newly created FileInfo. */

Source from the content-addressed store, hash-verified

329 * @return A pointer to the newly created FileInfo.
330 */
331static FileInfo *_File_Init_AddFileInRootDir(const char *filename, uint32 filesize)
332{
333 FileInfoLinkedElem *new;
334 size_t size;
335 size = sizeof(FileInfoLinkedElem) + strlen(filename);
336 new = malloc(size);
337 if (new == NULL) {
338 Error("cannot allocate %u bytes of memory\n", size);
339 return NULL;
340 }
341 new->next = s_files_in_root;
342 memset(&new->info, 0, sizeof(FileInfo));
343 memcpy(new->filenamebuffer, filename, strlen(filename) + 1);
344 new->info.filename = new->filenamebuffer;
345 new->info.fileSize = filesize;
346 new->info.filePosition = 0;
347 s_files_in_root = new;
348 return &new->info;
349}
350
351/**
352 * Memorize a file inside a PAK file.

Callers 1

_File_Init_CallbackFunction · 0.85

Calls 1

ErrorFunction · 0.50

Tested by

no test coverage detected