当前位置: 首页>>代码示例>>C++>>正文


C++ Directory::cd方法代码示例

本文整理汇总了C++中Directory::cd方法的典型用法代码示例。如果您正苦于以下问题:C++ Directory::cd方法的具体用法?C++ Directory::cd怎么用?C++ Directory::cd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directory的用法示例。


在下文中一共展示了Directory::cd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: command_init

void command_init (Database& db, const std::vector <std::string>& args)
{
  // Verify that root exists.
  std::string root = db._config->get ("root");
  if (root == "")
    throw std::string ("ERROR: The '--data' option is required.");

  Directory root_dir (root);
  if (!root_dir.exists ())
    throw std::string ("ERROR: The '--data' path does not exist.");

  if (!root_dir.is_directory ())
     throw std::string ("ERROR: The '--data' path is not a directory.");

  if (!root_dir.readable ())
    throw std::string ("ERROR: The '--data' directory is not readable.");

  if (!root_dir.writable ())
    throw std::string ("ERROR: The '--data' directory is not writable.");

  if (!root_dir.executable ())
    throw std::string ("ERROR: The '--data' directory is not executable.");

  // Provide some defaults and overrides.
  db._config->set ("extensions", TASKD_EXTDIR);
  db._config->setIfBlank ("log",           "/tmp/taskd.log");
  db._config->setIfBlank ("queue.size",    "10");
  db._config->setIfBlank ("pid.file",      "/tmp/taskd.pid");
  db._config->setIfBlank ("ip.log",        "on");
  db._config->setIfBlank ("request.limit", "1048576");
  db._config->setIfBlank ("confirmation",  "1");
  db._config->setIfBlank ("verbose",       "1");

  // Suggestions for missing items.
  if (db._config->get ("server") == "")
    std::cout << "You must specify the 'server' variable, for example:\n"
              << "  taskd config server localhost:53589\n"
              << "\n";

  // Create the data structure.
  Directory sub (root_dir);
  sub.cd ();
  sub += "orgs";
  if (!sub.exists ())
    if (!sub.create (0700))
      throw std::string ("ERROR: Could not create '") + sub._data + "'.";

  // Dump the config file?
  db._config->_original_file = root_dir._data + "/config";

  if (! db._config->_original_file.exists ())
    db._config->_original_file.create (0600);

  if (db._config->dirty ())
  {
    db._config->save ();
    if (db._config->getBoolean ("verbose"))
      std::cout << "Created " << std::string (db._config->_original_file) << "\n";
  }
}
开发者ID:PedroLopes,项目名称:taskd,代码行数:60,代码来源:init.cpp

示例2: command_init

void command_init (Database& db, const std::vector <std::string>& args)
{
  // Verify that root exists.
  std::string root = db._config->get ("root");
  if (root == "")
    throw std::string (STRING_INIT_DATA_REQUIRED);

  Directory root_dir (root);
  if (!root_dir.exists ())
    throw std::string (STRING_INIT_PATH_MISSING);

  if (!root_dir.is_directory ())
    throw std::string (STRING_INIT_PATH_NOT_DIR);

  if (!root_dir.readable ())
    throw std::string (STRING_INIT_PATH_NOT_READ);

  if (!root_dir.writable ())
    throw std::string (STRING_INIT_PATH_NOT_WRITE);

  if (!root_dir.executable ())
    throw std::string (STRING_INIT_PATH_NOT_EXE);

  // Provide some defaults and overrides.
  db._config->set ("extensions", TASKD_EXTDIR);
  db._config->setIfBlank ("log",           "/tmp/taskd.log");
  db._config->setIfBlank ("queue.size",    "10");
  db._config->setIfBlank ("pid.file",      "/tmp/taskd.pid");
  db._config->setIfBlank ("ip.log",        "on");
  db._config->setIfBlank ("request.limit", "1048576");
  db._config->setIfBlank ("confirmation",  "1");
  db._config->setIfBlank ("verbose",       "1");
  db._config->setIfBlank ("trust",         "strict");

  // Suggestions for missing items.
  if (db._config->get ("server") == "")
    std::cout << STRING_INIT_SERVER
              << "\n"
              << "  taskd config server localhost:53589\n"
              << "\n";

  // Create the data structure.
  Directory sub (root_dir);
  sub.cd ();
  sub += "orgs";
  if (!sub.exists ())
    if (!sub.create (0700))
      throw format (STRING_INIT_COULD_NOT_CREATE, sub._data);

  // Dump the config file?
  db._config->_original_file = root_dir._data + "/config";

  if (! db._config->_original_file.exists ())
    db._config->_original_file.create (0600);

  if (db._config->dirty ())
  {
    db._config->save ();
    if (db._config->getBoolean ("verbose"))
      std::cout << format (STRING_INIT_CREATED, db._config->_original_file)
                << "\n";
  }
}
开发者ID:goldenHairDafo,项目名称:taskd,代码行数:63,代码来源:init.cpp


注:本文中的Directory::cd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。