[2c47b73] | 1 | /** |
---|
| 2 | * @file io.h |
---|
| 3 | * @author Sheng Di |
---|
| 4 | * @date April, 2015 |
---|
| 5 | * @brief Header file for the whole io interface. |
---|
| 6 | * (C) 2015 by Mathematics and Computer Science (MCS), Argonne National Laboratory. |
---|
| 7 | * See COPYRIGHT in top-level directory. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #ifndef _IO_H |
---|
| 11 | #define _IO_H |
---|
| 12 | |
---|
| 13 | #include <stdio.h> |
---|
| 14 | #include <stdint.h> |
---|
| 15 | |
---|
| 16 | #ifdef _WIN32 |
---|
| 17 | #define PATH_SEPARATOR ';' |
---|
| 18 | #else |
---|
| 19 | #define PATH_SEPARATOR ':' |
---|
| 20 | #endif |
---|
| 21 | |
---|
| 22 | #ifdef __cplusplus |
---|
| 23 | extern "C" { |
---|
| 24 | #endif |
---|
| 25 | |
---|
| 26 | int checkFileExistance(char* filePath); |
---|
| 27 | |
---|
| 28 | float** create2DArray_float(size_t m, size_t n); |
---|
| 29 | void free2DArray_float(float** data, size_t m); |
---|
| 30 | float*** create3DArray_float(size_t p, size_t m, size_t n); |
---|
| 31 | void free3DArray_float(float*** data, size_t p, size_t m); |
---|
| 32 | double** create2DArray_double(size_t m, size_t n); |
---|
| 33 | void free2DArray_double(double** data, size_t m); |
---|
| 34 | double*** create3DArray_double(size_t p, size_t m, size_t n); |
---|
| 35 | void free3DArray_double(double*** data, size_t p, size_t m); |
---|
| 36 | size_t checkFileSize(char *srcFilePath, int *status); |
---|
| 37 | |
---|
| 38 | unsigned char *readByteData(char *srcFilePath, size_t *byteLength, int *status); |
---|
| 39 | double *readDoubleData(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 40 | int8_t *readInt8Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 41 | int16_t *readInt16Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 42 | uint16_t *readUInt16Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 43 | int32_t *readInt32Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 44 | uint32_t *readUInt32Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 45 | int64_t *readInt64Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 46 | uint64_t *readUInt64Data(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 47 | float *readFloatData(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 48 | unsigned short* readShortData(char *srcFilePath, size_t *dataLength, int *status); |
---|
| 49 | |
---|
| 50 | double *readDoubleData_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 51 | int8_t *readInt8Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 52 | int16_t *readInt16Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 53 | uint16_t *readUInt16Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 54 | int32_t *readInt32Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 55 | uint32_t *readUInt32Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 56 | int64_t *readInt64Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 57 | uint64_t *readUInt64Data_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 58 | float *readFloatData_systemEndian(char *srcFilePath, size_t *nbEle, int *status); |
---|
| 59 | |
---|
| 60 | void writeByteData(unsigned char *bytes, size_t byteLength, char *tgtFilePath, int *status); |
---|
| 61 | void writeDoubleData(double *data, size_t nbEle, char *tgtFilePath, int *status); |
---|
| 62 | void writeFloatData(float *data, size_t nbEle, char *tgtFilePath, int *status); |
---|
| 63 | void writeData(void *data, int dataType, size_t nbEle, char *tgtFilePath, int *status); |
---|
| 64 | void writeFloatData_inBytes(float *data, size_t nbEle, char* tgtFilePath, int *status); |
---|
| 65 | void writeDoubleData_inBytes(double *data, size_t nbEle, char* tgtFilePath, int *status); |
---|
| 66 | void writeShortData_inBytes(short *states, size_t stateLength, char *tgtFilePath, int *status); |
---|
| 67 | void writeUShortData_inBytes(unsigned short *states, size_t stateLength, char *tgtFilePath, int *status); |
---|
| 68 | void writeIntData_inBytes(int *states, size_t stateLength, char *tgtFilePath, int *status); |
---|
| 69 | void writeUIntData_inBytes(unsigned int *states, size_t stateLength, char *tgtFilePath, int *status); |
---|
| 70 | void writeLongData_inBytes(int64_t *states, size_t stateLength, char *tgtFilePath, int *status); |
---|
| 71 | void writeULongData_inBytes(uint64_t *states, size_t stateLength, char *tgtFilePath, int *status); |
---|
| 72 | |
---|
| 73 | void writeStrings(int nbStr, char *str[], char *tgtFilePath, int *status); |
---|
| 74 | |
---|
| 75 | //void convertToPFM_float(float *data, size_t r5, size_t r4, size_t r3, size_t r2, size_t r1, int endianType, char *tgtFilePath, int *status); |
---|
| 76 | |
---|
| 77 | void checkfilesizec_(char *srcFilePath, int *len, size_t *filesize); |
---|
| 78 | void readbytefile_(char *srcFilePath, int *len, unsigned char *bytes, size_t *byteLength); |
---|
| 79 | void readdoublefile_(char *srcFilePath, int *len, double *data, size_t *nbEle); |
---|
| 80 | void readfloatfile_(char *srcFilePath, int *len, float *data, size_t *nbEle); |
---|
| 81 | void writebytefile_(unsigned char *bytes, size_t *byteLength, char *tgtFilePath, int *len); |
---|
| 82 | void writedoublefile_(double *data, size_t *nbEle, char *tgtFilePath, int *len); |
---|
| 83 | void writefloatfile_(float *data, size_t *nbEle, char *tgtFilePath, int *len); |
---|
| 84 | |
---|
| 85 | #ifdef __cplusplus |
---|
| 86 | } |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | #endif /* ----- #ifndef _IO_H ----- */ |
---|