MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / bm_GetFileType

Function bm_GetFileType

bitmap/bitmain.cpp:680–696  ·  view source on GitHub ↗

Checks to see if this file is a kind we can read

Source from the content-addressed store, hash-verified

678}
679// Checks to see if this file is a kind we can read
680int bm_GetFileType(CFILE *infile, const char *dest) {
681 char iffcheck[4];
682 int i;
683 // First, check if its a pcx
684 i = strlen(dest);
685 if (dest[i - 4] == '.' && (dest[i - 3] == 'p' || dest[i - 3] == 'P') && (dest[i - 2] == 'c' || dest[i - 2] == 'C') &&
686 (dest[i - 1] == 'x' || dest[i - 1] == 'X'))
687 return BM_FILETYPE_PCX;
688 // How about an IFF?
689 for (i = 0; i < 4; i++)
690 iffcheck[i] = cf_ReadByte(infile);
691 cfseek(infile, 0, SEEK_SET);
692 if (!strncmp("FORM", iffcheck, 4))
693 return BM_FILETYPE_IFF;
694 // Lastly, just default to possible TGA or OGF
695 return BM_FILETYPE_TGA;
696}
697// Allocs and loads a bitmap
698// Returns the handle of the loaded bitmap
699// Returns -1 if something is wrong

Callers 1

bm_AllocLoadFileBitmapFunction · 0.85

Calls 2

cf_ReadByteFunction · 0.85
cfseekFunction · 0.85

Tested by

no test coverage detected