| 55 | } |
| 56 | |
| 57 | file_t MNNCreateFile(const char * file_name) |
| 58 | { |
| 59 | #if defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) |
| 60 | HANDLE hd = CreateFile( |
| 61 | file_name, // File Name |
| 62 | GENERIC_READ | GENERIC_WRITE, // Read and Write |
| 63 | 0, // No Sharing |
| 64 | NULL, // No Security |
| 65 | CREATE_ALWAYS, // Create the file and cover the existing file |
| 66 | FILE_ATTRIBUTE_NORMAL, // Normal Attribute |
| 67 | NULL // No Template |
| 68 | ); |
| 69 | if (hd == INVALID_HANDLE_VALUE) { |
| 70 | MNN_PRINT("Failed to create the file: %s\n", file_name); |
| 71 | return INVALID_FILE; |
| 72 | } |
| 73 | return hd; |
| 74 | #else |
| 75 | int fd = open( |
| 76 | file_name, // File Name |
| 77 | O_RDWR | O_CREAT | O_TRUNC, // Read and Write and Create the file and cover existing file |
| 78 | 0666 // Read and Write Permission for Everyone |
| 79 | ); |
| 80 | if (fd == -1) { |
| 81 | MNN_PRINT("Failed to create the file: %s\n", file_name); |
| 82 | return INVALID_FILE; |
| 83 | } |
| 84 | return fd; |
| 85 | #endif |
| 86 | } |
| 87 | |
| 88 | file_t MNNOpenFile(const char * file_name, uint32_t flags) |
| 89 | { |