Exemple #1
0
 std::vector<ModuleInfo> listModules() {
   std::vector<ModuleInfo> modules;
   std::vector<std::string> ret = qi::path::listData("qi/module", "*.mod");
   for (unsigned int i = 0; i < ret.size(); ++i)
   {
     const qi::Path p(ret.at(i));
     ModuleInfo mi;
     mi.name = p.filename().substr(0, p.filename().find(".mod"));
     boost::filesystem::ifstream is(p);
     is >> mi.type;
     modules.push_back(mi);
   }
   //look for all modules in sdk/share/qi/
   return modules;
 }
TEST(QiOs, isProcessRunningRealProcessWithArgsUnicode)
{
  const std::string originalExecutable { "testlaunchloop" };
  const std::string originalExecutablePath = qi::path::findBin(originalExecutable);
  // we'll copy the originalExecutable to a unique file inside a unique direcory.
  // we re-use the unique directory name to build a unique file name.
  const qi::Path tmp = qi::Path(qi::os::mktmpdir());
  // japanese ideograms (specified by their unicode code point)
  // as an utf-8-encoded string (does not work on VS).
  //char utf8[] = u8"-\u30e6\u30cb\u30b3\u30fc\u30c9";
  // The same ideograms, specified by their utf-8 encoding
  char utf8[] = "-\xe3\x83\xa6\xe3\x83\x8b\xe3\x82\xb3\xe3\x83\xbc\xe3\x83\x89";
  const std::string executable = tmp.filename() + utf8;
  std::string executableWithExtension = executable;
#if BOOST_OS_WINDOWS && defined(NDEBUG)
    executableWithExtension += ".exe";
#elif BOOST_OS_WINDOWS && !defined(NDEBUG)
    executableWithExtension += "_d.exe";
#endif

  const qi::Path executablePathWithExtension =
          tmp / executableWithExtension;
  const qi::path::ScopedFile executableFile(executablePathWithExtension);
  boost::filesystem::copy(
        qi::Path(originalExecutablePath).bfsPath(),
        executablePathWithExtension.bfsPath());

  const std::vector<std::string> args { "nan", "mais", "allo", "quoi" };
  const ScopedProcess p{executablePathWithExtension.str(), args};
  ASSERT_TRUE(qi::os::isProcessRunning(p.pid(), executable));
}