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


C++ File::isDirectory方法代码示例

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


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

示例1: OpenAllLibraries

/** Opens all suitable DLLs on a given path.
*  @param filePath :: The filepath to the directory where the libraries are.
*  @param isRecursive :: Whether to search subdirectories.
*  @return The number of libraries opened.
*/
int LibraryManagerImpl::OpenAllLibraries(const std::string &filePath,
                                         bool isRecursive) {
  g_log.debug() << "Opening all libraries in " << filePath << "\n";
  int libCount = 0;
  // validate inputs
  Poco::File libPath;
  try {
    libPath = Poco::File(filePath);
  } catch (...) {
    return libCount;
  }
  if (libPath.exists() && libPath.isDirectory()) {
    DllOpen::addSearchDirectory(filePath);
    // Iteratate over the available files
    Poco::DirectoryIterator end_itr;
    for (Poco::DirectoryIterator itr(libPath); itr != end_itr; ++itr) {
      const Poco::Path &item = itr.path();
      if (item.isDirectory()) {
        if (isRecursive) {
          libCount += OpenAllLibraries(item.toString());
        }
      } else {
        if (skip(item.toString()))
          continue;
        if (loadLibrary(item.toString())) {
          ++libCount;
        }
      }
    }
  } else {
    g_log.error("In OpenAllLibraries: " + filePath + " must be a directory.");
  }

  return libCount;
}
开发者ID:dezed,项目名称:mantid,代码行数:40,代码来源:LibraryManager.cpp

示例2: DoExportGameScripts

    int CStatsUtil::DoExportGameScripts()
    {
        //Validate output + input paths
        Poco::Path inpath(m_inputPath);
        Poco::Path outpath;
        
        if( m_outputPath.empty() )
            outpath = inpath.absolute().makeParent().append(DefExportScriptsDir);
        else
            outpath = Poco::Path(m_outputPath).makeAbsolute();

        Poco::File fTestOut = outpath;
        if( ! fTestOut.exists() )
        {
            cout << "Created output directory \"" << fTestOut.path() <<"\"!\n";
            fTestOut.createDirectory();
        }
        else if( ! fTestOut.isDirectory() )
            throw runtime_error("CStatsUtil::DoExportGameScripts(): Output path is not a directory!");

        //Setup the script handler
        GameScripts scripts( inpath.absolute().toString() );

        //Convert to XML
        scripts.ExportScriptsToXML( outpath.toString() );

        return 0;
    }
开发者ID:SeredithM,项目名称:ppmdu,代码行数:28,代码来源:statsutil.cpp

示例3: validateDir

// ---
bool VSWAEImportContentWindow::validateDir (const QString& d)
{
	bool result = false;

	// Calculates the paths for everything: the basic dir, the definition file...
	// ...and the basic path received as parameter during the initialization.
	Poco::Path defPath;
	Poco::File defFile;
	Poco::File defDir (d.toStdString ());
	Poco::Path bPath (_basicPath.toStdString ());
	bool isDefDirADir = defDir.isDirectory (); // The directory has to be a dir (this is guarantte by the window, but just in case)
	if (isDefDirADir) 
	{
		defPath = Poco::Path (d.toStdString ());
		defFile = Poco::File ((d + QString (__PATH_SEPARATOR__) + 
			_name -> text () + QString (".xml")).toStdString ());
	}

	// If the directory is a directory, then it is needed to test whether the
	// directory is or not contained in the basic path received as parameter.
	bool isDefDirInBPath = false;
	if (isDefDirADir)
		isDefDirInBPath = ((defPath.toString () + std::string (__PATH_SEPARATOR__)).
			find (bPath.toString () + std::string (__PATH_SEPARATOR__)) != -1);

	// To determinate whether the dir is or not valid...
	result = !isDefDirADir || (isDefDirADir && isDefDirInBPath);

	return (result);
}
开发者ID:Commnets,项目名称:AdstoneCode,代码行数:31,代码来源:VSWAEImportContentWindow.cpp

示例4: openLibraries

/**
 * Opens suitable DLLs on a given path.
 *  @param libpath A Poco::File object pointing to a directory where the
 * libraries are.
 *  @param loadingBehaviour Control how libraries are searched for
 *  @param excludes If not empty then each string is considered as a substring
 * to search within each library to be opened. If the substring is found then
 * the library is not opened.
 *  @return The number of libraries opened.
 */
int LibraryManagerImpl::openLibraries(
    const Poco::File &libpath,
    LibraryManagerImpl::LoadLibraries loadingBehaviour,
    const std::vector<std::string> &excludes) {
  int libCount(0);
  if (libpath.exists() && libpath.isDirectory()) {
    // Iterate over the available files
    Poco::DirectoryIterator end_itr;
    for (Poco::DirectoryIterator itr(libpath); itr != end_itr; ++itr) {
      const Poco::File &item = *itr;
      if (item.isFile()) {
        if (shouldBeLoaded(itr.path().getFileName(), excludes))
          libCount += openLibrary(itr.path(), itr.path().getFileName());
        else
          continue;
      } else if (loadingBehaviour == LoadLibraries::Recursive) {
        // it must be a directory
        libCount += openLibraries(item, LoadLibraries::Recursive, excludes);
      }
    }
  } else {
    g_log.error("In OpenAllLibraries: " + libpath.path() +
                " must be a directory.");
  }
  return libCount;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:36,代码来源:LibraryManager.cpp

示例5: isDirectory

bool TraverseBase::isDirectory(Poco::File& file)
{
	try
	{
		return file.isDirectory();
	}
	catch (...)
	{
		return false;
	}
}
开发者ID:12307,项目名称:poco,代码行数:11,代码来源:DirectoryIteratorStrategy.cpp

示例6: unlink_directory

 void unlink_directory()
 {
     if ( directory.exists() && directory.isDirectory() )
     {
         try
         {
             directory.remove(true);
         }
         catch(Poco::Exception &e)
         {
             std::cout << e.displayText() << std::endl;
         }
     }
 }
开发者ID:douwen2000,项目名称:fix8,代码行数:14,代码来源:filePersister_test.cpp

示例7: FindBasicModules

	void Host::FindBasicModules(std::string& dir)
	{
		ScopedLock lock(&moduleMutex);

		Poco::DirectoryIterator iter = Poco::DirectoryIterator(dir);
		Poco::DirectoryIterator end;
		while (iter != end)
		{
			Poco::File f = *iter;
			if (!f.isDirectory() && !f.isHidden())
			{
				std::string fpath = iter.path().absolute().toString();
				if (IsModule(fpath))
				{
					this->LoadModule(fpath, this);
				}
				else
				{
					this->AddInvalidModuleFile(fpath);
				}
			}
			iter++;
		}
	}
开发者ID:jonnymind,项目名称:kroll,代码行数:24,代码来源:host.cpp

示例8: initialize

void BaseDaemon::initialize(Application& self)
{
	task_manager.reset(new Poco::TaskManager);
	ServerApplication::initialize(self);

	bool is_daemon = config().getBool("application.runAsDaemon", false);

	if (is_daemon)
	{
		/** При создании pid файла и поиске конфигурации, будем интерпретировать относительные пути
		  * от директории запуска программы.
		  */
		std::string path = Poco::Path(config().getString("application.path")).setFileName("").toString();
		if (0 != chdir(path.c_str()))
			throw Poco::Exception("Cannot change directory to " + path);
	}

	/// Считаем конфигурацию
	reloadConfiguration();

	/// В случае падения - сохраняем коры
	{
		struct rlimit rlim;
		if (getrlimit(RLIMIT_CORE, &rlim))
			throw Poco::Exception("Cannot getrlimit");
		/// 1 GiB. Если больше - они слишком долго пишутся на диск.
		rlim.rlim_cur = config().getUInt64("core_dump.size_limit", 1024 * 1024 * 1024);

		if (setrlimit(RLIMIT_CORE, &rlim))
		{
			std::string message = "Cannot set max size of core file to " + std::to_string(rlim.rlim_cur);
		#if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER)
			throw Poco::Exception(message);
		#else
			/// Не работает под address/thread sanitizer. http://lists.llvm.org/pipermail/llvm-bugs/2013-April/027880.html
			std::cerr << message << std::endl;
		#endif
		}
	}

	/// This must be done before any usage of DateLUT. In particular, before any logging.
	if (config().has("timezone"))
	{
		if (0 != setenv("TZ", config().getString("timezone").data(), 1))
			throw Poco::Exception("Cannot setenv TZ variable");

		tzset();
	}

	std::string log_path = config().getString("logger.log", "");
	if (!log_path.empty())
		log_path = Poco::Path(log_path).setFileName("").toString();

	if (is_daemon)
	{
		/** Переназначим stdout, stderr в отдельные файлы в директориях с логами.
		  * Некоторые библиотеки пишут в stderr в случае ошибок или в отладочном режиме,
		  *  и этот вывод иногда имеет смысл смотреть даже когда программа запущена в режиме демона.
		  * Делаем это до buildLoggers, чтобы ошибки во время инициализации логгера, попали в эти файлы.
		  */
		if (!log_path.empty())
		{
			std::string stdout_path = log_path + "/stdout";
			if (!freopen(stdout_path.c_str(), "a+", stdout))
				throw Poco::OpenFileException("Cannot attach stdout to " + stdout_path);

			std::string stderr_path = log_path + "/stderr";
			if (!freopen(stderr_path.c_str(), "a+", stderr))
				throw Poco::OpenFileException("Cannot attach stderr to " + stderr_path);
		}

		/// Создадим pid-file.
		if (is_daemon && config().has("pid"))
			pid.seed(config().getString("pid"));
	}

	buildLoggers();

	if (is_daemon)
	{
		/** Сменим директорию на ту, куда надо писать core файлы.
		  * Делаем это после buildLoggers, чтобы не менять текущую директорию раньше.
		  * Это важно, если конфиги расположены в текущей директории.
		  */

		std::string core_path = config().getString("core_path", "");
		if (core_path.empty())
			core_path = getDefaultCorePath();

		tryCreateDirectories(&logger(), core_path);

		Poco::File cores = core_path;
		if (!(cores.exists() && cores.isDirectory()))
		{
			core_path = !log_path.empty() ? log_path : "/opt/";
			tryCreateDirectories(&logger(), core_path);
		}

		if (0 != chdir(core_path.c_str()))
			throw Poco::Exception("Cannot change directory to " + core_path);
//.........这里部分代码省略.........
开发者ID:jacktang,项目名称:ClickHouse,代码行数:101,代码来源:BaseDaemon.cpp


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