19 #ifndef KALDI_UTIL_KALDI_CYGWIN_IO_INL_H_ 20 #define KALDI_UTIL_KALDI_CYGWIN_IO_INL_H_ 23 #error This is a Windows-compatibility file. Something went wery wrong. 45 static bool prefixp(
const std::string& pfx,
const std::string& str) {
46 return pfx.length() <= str.length() &&
47 std::equal(pfx.begin(), pfx.end(), str.begin());
50 static std::string
cygprefix(
"/cygdrive/");
58 if (filename ==
"/dev/null")
60 if (
prefixp(
"/dev/", filename)) {
61 KALDI_ERR <<
"Unable to resolve path '" << filename
62 <<
"' - only have /dev/null here.";
63 return "\\\\.\\invalid";
67 int preflen = cygprefix.size();
68 if (
prefixp(cygprefix, filename)
69 && filename.size() >= preflen + 1 && isalpha(filename[preflen])
70 && (filename.size() == preflen + 1 || filename[preflen + 1] ==
'/')) {
71 return std::string() + filename[preflen] +
':' +
72 (filename.size() > preflen + 1 ? filename.substr(preflen + 1) :
"/");
75 KALDI_WARN <<
"Unable to resolve path '" << filename
76 <<
"' - cannot map unix prefix. " 77 <<
"Will go on, but breakage will likely ensue.";
84 if (filename !=
"/tmp" && !
prefixp(
"/tmp/", filename)) {
87 char *tmpdir = std::getenv(
"TMP");
88 if (tmpdir ==
nullptr)
89 tmpdir = std::getenv(
"TEMP");
90 if (tmpdir ==
nullptr) {
91 KALDI_ERR <<
"Unable to resolve path '" << filename
92 <<
"' - unable to find temporary directory. Set TMP.";
114 const char* bash_exe = std::getenv(
"BASH_EXE");
115 std::string qcmd(bash_exe !=
nullptr ? bash_exe :
"bash.exe");
117 for (; *command; ++command) {
118 if (*command ==
'\"')
124 return _popen(qcmd.c_str(), mode);
129 #endif // KALDI_UTIL_KALDI_CYGWIN_IO_INL_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
static FILE * CygwinCompatPopen(const char *command, const char *mode)
static std::string MapCygwinPathNoTmp(const std::string &filename)
std::string MapCygwinPath(const std::string &filename)
static std::string cygprefix("/cygdrive/")
static bool prefixp(const std::string &pfx, const std::string &str)