* Reads the whole file in the memory. The file should contain little endian * 16bits unsigned integers. It is converted to host byte ordering if needed. * * @param filename The name of the file to open. * @param mallocFlags The type of memory to allocate. * @return The pointer to allocated memory where the file has been read. */
| 926 | * @return The pointer to allocated memory where the file has been read. |
| 927 | */ |
| 928 | uint16 *File_ReadWholeFileLE16(const char *filename) |
| 929 | { |
| 930 | uint8 index; |
| 931 | uint32 count; |
| 932 | uint16 *buffer; |
| 933 | #if __BYTE_ORDER == __BIG_ENDIAN |
| 934 | uint32 i; |
| 935 | #endif |
| 936 | |
| 937 | index = File_Open(filename, FILE_MODE_READ); |
| 938 | count = File_GetSize(index) / sizeof(uint16); |
| 939 | |
| 940 | buffer = malloc(count * sizeof(uint16)); |
| 941 | if (File_Read(index, buffer, count * sizeof(uint16)) != count * sizeof(uint16)) { |
| 942 | free(buffer); |
| 943 | return NULL; |
| 944 | } |
| 945 | |
| 946 | File_Close(index); |
| 947 | |
| 948 | #if __BYTE_ORDER == __BIG_ENDIAN |
| 949 | for(i = 0; i < count; i++) { |
| 950 | buffer[i] = LETOH16(buffer[i]); |
| 951 | } |
| 952 | #endif |
| 953 | |
| 954 | return buffer; |
| 955 | } |
| 956 | |
| 957 | /** |
| 958 | * Reads the whole file into buffer. |
no test coverage detected