diff --git a/inference-engine/src/inference_engine/file_utils.cpp b/inference-engine/src/inference_engine/file_utils.cpp index 24e4fb4d366..10a5c277454 100644 --- a/inference-engine/src/inference_engine/file_utils.cpp +++ b/inference-engine/src/inference_engine/file_utils.cpp @@ -44,25 +44,6 @@ long long FileUtils::fileSize(const char* charfilepath) { return in.tellg(); } -void FileUtils::readAllFile(const std::string& string_file_name, void* buffer, size_t maxSize) { - std::ifstream inputFile; - -#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) - std::wstring file_name = InferenceEngine::details::multiByteCharToWString(string_file_name.c_str()); -#else - std::string file_name = string_file_name; -#endif - - inputFile.open(file_name, std::ios::binary | std::ios::in); - if (!inputFile.is_open()) THROW_IE_EXCEPTION << "cannot open file " << string_file_name; - if (!inputFile.read(reinterpret_cast(buffer), maxSize)) { - inputFile.close(); - THROW_IE_EXCEPTION << "cannot read " << maxSize << " bytes from file " << string_file_name; - } - - inputFile.close(); -} - namespace InferenceEngine { namespace { diff --git a/inference-engine/src/plugin_api/file_utils.h b/inference-engine/src/plugin_api/file_utils.h index b99711c0df2..de8221b704f 100644 --- a/inference-engine/src/plugin_api/file_utils.h +++ b/inference-engine/src/plugin_api/file_utils.h @@ -121,15 +121,6 @@ inline bool fileExist(const std::basic_string &fileName) { return fileExist(fileName.c_str()); } -/** - * @brief CPP Interface function to read a file. In case of read error throws an exception. The function supports UNICODE path - * @ingroup ie_dev_api_file_utils - * @param file_name - name of the file to read - * @param buffer - buffer to read file to - * @param maxSize - maximum size in bytes to read - */ -INFERENCE_ENGINE_API_CPP(void) readAllFile(const std::string &file_name, void *buffer, size_t maxSize); - /** * @brief CPP Interface function to combint path with filename. The function supports UNICODE path * @ingroup ie_dev_api_file_utils @@ -163,22 +154,6 @@ inline std::basic_string fileExt(const std::basic_string &filename) { return filename.substr(pos + 1); } -/** - * @brief CPP Interface function to check if given fileName belongs to shared library - * @ingroup ie_dev_api_file_utils - * @param fileName A file name to check - * @return `True` if fileName is a shared library fileName - */ -inline bool isSharedLibrary(const std::string &fileName) { - return 0 == -#ifdef _WIN32 - _strnicmp -#else - strncasecmp -#endif - (fileExt(fileName).c_str(), FileTraits::SharedLibraryExt().c_str(), FileTraits::SharedLibraryExt().size()); -} - template > inline std::basic_string makeSharedLibraryName(const std::basic_string &path, const std::basic_string &input) { std::basic_string separator(1, FileTraits::FileSeparator); diff --git a/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp b/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp index 50e990f226d..8e75c133c00 100644 --- a/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp +++ b/inference-engine/src/readers/ir_reader_v7/ie_cnn_net_reader_impl.cpp @@ -67,6 +67,29 @@ StatusCode CNNNetReaderImpl::ReadNetwork(const void* model, size_t size, Respons return OK; } +namespace { + +void readAllFile(const std::string& string_file_name, void* buffer, size_t maxSize) { + std::ifstream inputFile; + +#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) + std::wstring file_name = InferenceEngine::details::multiByteCharToWString(string_file_name.c_str()); +#else + std::string file_name = string_file_name; +#endif + + inputFile.open(file_name, std::ios::binary | std::ios::in); + if (!inputFile.is_open()) THROW_IE_EXCEPTION << "cannot open file " << string_file_name; + if (!inputFile.read(reinterpret_cast(buffer), maxSize)) { + inputFile.close(); + THROW_IE_EXCEPTION << "cannot read " << maxSize << " bytes from file " << string_file_name; + } + + inputFile.close(); +} + +} // namespace + StatusCode CNNNetReaderImpl::ReadWeights(const char* filepath, ResponseDesc* resp) noexcept { OV_ITT_SCOPED_TASK(itt::domains::V7Reader, "CNNNetReaderImpl::ReadWeights"); int64_t fileSize = FileUtils::fileSize(filepath); @@ -85,7 +108,7 @@ StatusCode CNNNetReaderImpl::ReadWeights(const char* filepath, ResponseDesc* res try { TBlob::Ptr weightsPtr(new TBlob(TensorDesc(Precision::U8, {ulFileSize}, Layout::C))); weightsPtr->allocate(); - FileUtils::readAllFile(filepath, weightsPtr->buffer(), ulFileSize); + readAllFile(filepath, weightsPtr->buffer(), ulFileSize); return SetWeights(weightsPtr, resp); } catch (const InferenceEngineException& ex) { return DescriptionBuffer(resp) << ex.what();