File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
paddle/fluid/inference/api Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1515#pragma once
1616#include < glog/logging.h>
1717#include < sys/stat.h>
18-
18+ #ifdef _WIN32
19+ #include < windows.h>
20+ #include < codecvt>
21+ #endif
1922#include < fstream>
2023#if !defined(_WIN32)
2124#include < sys/time.h>
@@ -425,20 +428,34 @@ static void PrintTime(int batch_size,
425428}
426429
427430static bool IsFileExists (const std::string &path) {
428- std::ifstream file (path);
431+ #ifdef _WIN32
432+ std::wstring_convert<std::codecvt_utf8_utf16<wchar_t >> converter;
433+ std::wstring wpath = converter.from_bytes (path);
434+ std::ifstream file (wpath, std::ios::binary);
435+ #else
436+ std::ifstream file (path, std::ios::binary);
437+ #endif
429438 bool exists = file.is_open ();
430439 file.close ();
431440 return exists;
432441}
433442
434443static bool IsDirectory (const std::string &path) {
444+ #ifdef _WIN32
445+ std::wstring_convert<std::codecvt_utf8_utf16<wchar_t >> converter;
446+ std::wstring wpath = converter.from_bytes (path);
447+ DWORD attr = GetFileAttributesW (wpath.c_str ());
448+ if (attr == INVALID_FILE_ATTRIBUTES) return false ;
449+ return (attr & FILE_ATTRIBUTE_DIRECTORY);
450+ #else
435451 struct stat info;
436452 if (stat (path.c_str (), &info) != 0 ) {
437453 return false ;
438454 } else if (info.st_mode & S_IFDIR) {
439455 return true ;
440456 }
441457 return false ;
458+ #endif
442459}
443460
444461void RegisterAllCustomOperator (bool use_pir);
You can’t perform that action at this time.
0 commit comments