コード例 #1
0
ファイル: Utils.cpp プロジェクト: CueMol/cuemol2
bool isFileReadable(const LString &strpath)
{
#ifdef _WIN32
  U16Char *pwcs;

  try {
    // conv pathname
    pwcs = qlib::UTF8toUCS16(strpath);
  }
  catch (const LException &ex) {
    // conversion error
    // --> file is not readable
    //return false;

    LString msg = LString::format("isFileReadable: cannot convert UTF8 file name <%s>", strpath.c_str());
    LOG_DPRINTLN(msg);
    MB_THROW(RuntimeException, msg);
    return NULL;
  }
  
  struct _stat buf;
  int result = _wstat( (wchar_t *)pwcs, &buf );
  delete [] pwcs;
  if (result==0 && (buf.st_mode&_S_IFREG))
    return true;
#else
  fs::path path(strpath);

  if (fs::exists(path) &&
      fs::is_regular_file(path))
    return true;
#endif

  return false;
}
コード例 #2
0
 virtual int skip(int len) {
   MB_THROW(FileFormatException, "skip() not supported");
   return super_t::skip(len);
 }