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


C++ poco::File类代码示例

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


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

示例1: 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

示例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: initFileSystem

void GoPlusContext::initFileSystem()
{
   //std::string confDir = Poco::Util::Application::instance().config().getString("application.dir") + "conf";
   //std::string dataDir = Poco::Util::Application::instance().config().getString("application.dir") + "data";
   //std::string logDir = Poco::Util::Application::instance().config().getString("application.dir") + "log";
   //std::string tmpDir = Poco::Util::Application::instance().config().getString("application.dir") + "tmp";
   std::string confDir = "conf";
   std::string dataDir = "data";
   std::string logDir = "log";
   std::string tmpDir = "tmp";

   Poco::File file; 

   file = confDir;
   file.createDirectories();

   file = dataDir;
   file.createDirectories();

   file = logDir;
   file.createDirectories();

   file = tmpDir;
   file.createDirectories();
}
开发者ID:wuyao721,项目名称:gopuls,代码行数:25,代码来源:GoPlusContext.cpp

示例4: 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

示例5: DoExportAll

    int CStatsUtil::DoExportAll()
    {
        Poco::Path inpath(m_inputPath);
        Poco::Path outpath;
        
        if( m_outputPath.empty() )
        {
            outpath = inpath.absolute().makeParent().append(DefExportAllDir);
        }
        else
        {
            outpath = Poco::Path(m_outputPath).makeAbsolute();
        }

        GameStats gstats( m_inputPath, m_langconf );
        gstats.Load();

        //Test output path
        Poco::File fTestOut = outpath;
        if( ! fTestOut.exists() )
        {
            cout << "Created output directory \"" << fTestOut.path() <<"\"!\n";
            fTestOut.createDirectory();
        }
        gstats.ExportAll(outpath.toString());
        return 0;
    }
开发者ID:SeredithM,项目名称:ppmdu,代码行数:27,代码来源:statsutil.cpp

示例6: 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

示例7: enableFileLogging

void Logger::enableFileLogging(const std::string& fileName, int level)
{
    Mutex::ScopedLock lock(loggerMutex);

    Logger::setLevel(level);

    // close the current file log and re-create it.
    disableFileLogging();

    if (!simpleFileChannel)
    {
        std::string realName;

        // figure out what file name to use
        if (fileName.length() == 0) {
            // none given, use one from config.
            realName = Config::getString(Config::LOGGER_LOG_FILE_PATH);
        } else {
            realName = fileName;
        }

        if (realName.length() == 0) {
            // default log name.
            realName = joinPath(getTempDir(), "roadrunner.log");
        } else {
            // expand any env vars and make absolute path.
            realName = Poco::Path::expand(realName);
            Poco::Path path(realName);
            realName = path.makeAbsolute().toString();
        }

        // check if the path is writable
        Poco::Path p(realName);
        Poco::File fdir = p.parent();
        if(!fdir.exists())
        {
            realName = joinPath(getTempDir(), "roadrunner.log");
            Log(Logger::LOG_ERROR) << "The specified log file directory path, "
                    << fdir.path() << " does not exist, using default log file path: "
                    << realName;
        }

        SplitterChannel *splitter = getSplitterChannel();

        simpleFileChannel = new SimpleFileChannel();
        simpleFileChannel->setProperty("path", realName);
        simpleFileChannel->setProperty("rotation", "never");

        logFileName = simpleFileChannel->getProperty("path");

        splitter->addChannel(simpleFileChannel);
        simpleFileChannel->release();
    }
}
开发者ID:Peter-J,项目名称:roadrunner,代码行数:54,代码来源:rrLogger.cpp

示例8: checkWatchedFile

void Rules::checkWatchedFile()
{
    Poco::File file = ofFile(watchedFileName).getPocoFile();
    Poco::Timestamp timestamp = file.getLastModified();
    if (timestamp != watchedLastModified)
    {
        clear();
        load(watchedFileName);
        ofNotifyEvent(fileReloaded, branches, this);
        watchedLastModified = timestamp;
    }
}
开发者ID:Solertis,项目名称:CLOUDS,代码行数:12,代码来源:Rules.cpp

示例9: openLibrary

/**
* Load a library
* @param filepath :: A Poco::File The full path to a library as a string
* @param cacheKey :: An identifier for the cache if loading is successful
* @return 1 if the file loaded successfully, 0 otherwise
*/
int LibraryManagerImpl::openLibrary(const Poco::File &filepath,
                                    const std::string &cacheKey) {
  // Try to open the library. The wrapper will unload the library when it
  // is deleted
  LibraryWrapper dlwrap;
  if (dlwrap.openLibrary(filepath.path())) {
    // Successfully opened, so add to map
    if (g_log.is(Poco::Message::PRIO_DEBUG)) {
      g_log.debug("Opened library: " + filepath.path() + ".\n");
    }
    m_openedLibs.emplace(cacheKey, std::move(dlwrap));
    return 1;
  } else
    return 0;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:21,代码来源:LibraryManager.cpp

示例10: initialize

    /**
     * Module initialization function. Takes a string as input that allows
     * arguments to be passed into the module.
     * @param arguments Tells the module which
     */
    TskModule::Status TSK_MODULE_EXPORT initialize(const char* arguments)
    {
        magicHandle = magic_open(MAGIC_NONE);
        if (magicHandle == NULL) {
            LOGERROR("FileTypeSigModule: Error allocating magic cookie.");
            return TskModule::FAIL;
        }

//Attempt to load magic database from default places on Linux.
//Don't bother trying magic_load() for defaults on win32 because it will always cause an exception instead of gracefully returning.
#ifndef TSK_WIN32
        /* Load the default magic database, which is found in this order:
               1. MAGIC env variable
               2. $HOME/.magic.mgc (or $HOME/.magic dir)
               3. /usr/share/misc/magic.mgc (or /usr/share/misc/magic dir) (unless libmagic was build configured abnormally)
        */
        if (magic_load(magicHandle, NULL)) {
            std::stringstream msg;
            msg << "FileTypeSigModule: Error loading default magic file: " << magic_error(magicHandle);
            LOGERROR(msg.str());
            //don't return, just fall through to the default loading below
        } else {
            return TskModule::OK;
        }
#endif
        //Load the magic database file in the repo
        std::string path = GetSystemProperty(TskSystemProperties::MODULE_CONFIG_DIR) + Poco::Path::separator() + MODULE_NAME + Poco::Path::separator() + "magic.mgc";

        Poco::File magicFile = Poco::File(path);
        if (magicFile.exists() == false) {
            std::stringstream msg;
            msg << "FileTypeSigModule: Magic file not found: " << path;
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }

        if (magic_load(magicHandle, path.c_str())) {
            std::stringstream msg;
            msg << "FileTypeSigModule: Error loading magic file: " << magic_error(magicHandle) << GetSystemProperty(TskSystemProperties::MODULE_CONFIG_DIR);
            LOGERROR(msg.str());
            return TskModule::FAIL;
        }

        return TskModule::OK;
    }
开发者ID:Smoss,项目名称:sleuthkit,代码行数:50,代码来源:FileTypeModule.cpp

示例11: FileNotFoundException

SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void*):
	_name(file.path()),
	_memHandle(INVALID_HANDLE_VALUE),
	_fileHandle(INVALID_HANDLE_VALUE),
	_size(0),
	_mode(PAGE_READONLY),
	_address(0)
{
	if (!file.exists() || !file.isFile())
		throw FileNotFoundException(_name);

	_size = static_cast<DWORD>(file.getSize());

	DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
	DWORD fileMode  = GENERIC_READ;

	if (mode == SharedMemory::AM_WRITE)
	{
		_mode = PAGE_READWRITE;
		fileMode |= GENERIC_WRITE;
	}

#if defined (POCO_WIN32_UTF8)
	std::wstring utf16name;
	UnicodeConverter::toUTF16(_name, utf16name);
	_fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
	_fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif

	if (_fileHandle == INVALID_HANDLE_VALUE)
		throw OpenFileException("Cannot open memory mapped file", _name);

	_memHandle = CreateFileMapping(_fileHandle, NULL, _mode, 0, 0, NULL);
	if (!_memHandle)
	{
		CloseHandle(_fileHandle);
		_fileHandle = INVALID_HANDLE_VALUE;
		throw SystemException("Cannot map file into shared memory", _name);
	}
	map();
}
开发者ID:Chingliu,项目名称:poco,代码行数:42,代码来源:SharedMemory_WIN32.cpp

示例12: isDirectory

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

示例13: FileNotFoundException

SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint):
    _size(0),
    _fd(-1),
    _address(0),
    _access(mode),
    _name(file.path()),
    _fileMapped(true),
    _server(false)
{
    if (!file.exists() || !file.isFile())
        throw FileNotFoundException(file.path());

    _size = file.getSize();
    int flag = O_RDONLY;
    if (mode == SharedMemory::AM_WRITE)
        flag = O_RDWR;
    _fd = ::open(_name.c_str(), flag);
    if (-1 == _fd)
        throw OpenFileException("Cannot open memory mapped file", _name);

    map(addrHint);
}
开发者ID:as2120,项目名称:ZPoco,代码行数:22,代码来源:SharedMemory_POSIX.cpp

示例14: before

    persist_fixture(f8String& curPath, bool before_clear = true, bool after_clear = false):
    before(before_clear),
    after(after_clear),
    directory(curPath + "/"+ "store")
    {
        if (before)
        {
            unlink_directory();
            directory.createDirectory();
        }

        filePer = new FilePersister();
        filePer->initialise(curPath + "/" + "store", "utest_log");
    }
开发者ID:douwen2000,项目名称:fix8,代码行数:14,代码来源:filePersister_test.cpp

示例15: 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


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