Removed not-used file utils (#1644)

This commit is contained in:
Ilya Lavrenov 2020-08-06 06:18:48 +03:00 committed by GitHub
parent b9c3825897
commit 6f6d6f8296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 45 deletions

View File

@ -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<char*>(buffer), maxSize)) {
inputFile.close();
THROW_IE_EXCEPTION << "cannot read " << maxSize << " bytes from file " << string_file_name;
}
inputFile.close();
}
namespace InferenceEngine {
namespace {

View File

@ -121,15 +121,6 @@ inline bool fileExist(const std::basic_string<C> &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<C> fileExt(const std::basic_string<C> &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<char>::SharedLibraryExt().c_str(), FileTraits<char>::SharedLibraryExt().size());
}
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
inline std::basic_string<C> makeSharedLibraryName(const std::basic_string<C> &path, const std::basic_string<C> &input) {
std::basic_string<C> separator(1, FileTraits<C>::FileSeparator);

View File

@ -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<char*>(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<uint8_t>::Ptr weightsPtr(new TBlob<uint8_t>(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();