Пример #1
0
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));
}
Пример #2
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;
 }
Пример #3
0
  static ModuleInfo findModuleInFs(const std::string& name) {
    //lookup for module in
    const qi::Path p(qi::path::findData("qi/module", name + ".mod"));

    //TODO: throwing seriously?
    if (!p.isRegularFile())
      throw std::runtime_error("no module found: '" + name + "'");

    ModuleInfo mi;
    mi.name = name;
    boost::filesystem::ifstream is(p);
    is >> mi.type;

    qiLogVerbose() << "type: '" << mi.type << "'";
    return mi;
  }
Пример #4
0
 void symlink(const qi::Path& source, const qi::Path& destination)
 {
   bfs::create_symlink(bfs::path(source.str(), qi::unicodeFacet()), bfs::path(destination.str(), qi::unicodeFacet()));
 }