------------------------------------------------------------------------------------------------ Open a new file with a given path.
| 119 | // ------------------------------------------------------------------------------------------------ |
| 120 | // Open a new file with a given path. |
| 121 | IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { |
| 122 | ai_assert(strFile != nullptr); |
| 123 | ai_assert(strMode != nullptr); |
| 124 | FILE *file; |
| 125 | |
| 126 | #ifdef _WIN32 |
| 127 | std::wstring name = Utf8ToWide(strFile); |
| 128 | if (name.empty()) { |
| 129 | return nullptr; |
| 130 | } |
| 131 | |
| 132 | file = ::_wfopen(name.c_str(), Utf8ToWide(strMode).c_str()); |
| 133 | #else |
| 134 | file = ::fopen(strFile, strMode); |
| 135 | #endif |
| 136 | |
| 137 | if (!file) { |
| 138 | return nullptr; |
| 139 | } |
| 140 | |
| 141 | return new DefaultIOStream(file, strFile); |
| 142 | } |
| 143 | |
| 144 | // ------------------------------------------------------------------------------------------------ |
| 145 | // Closes the given file and releases all resources associated with it. |
no test coverage detected