Exemplo n.º 1
0
void FilePathTest::testConversion( void )
{
  String s( "foo/bar/baaz" );

  FilePath p;
  CPPUNIT_ASSERT( s.to<>( p ) );
  CPPUNIT_ASSERT_EQUAL( s, p.path() );

  CPPUNIT_ASSERT_EQUAL( s, s.as<FilePath>().path() );
}
Exemplo n.º 2
0
Context::Context( FilePath const &keyFile )
: _ctx( *SSL_CTX_new( SSLv23_method() ) )
{
  // load the certs (probably not used, but if left out it causes problems)
  if ( SSL_CTX_use_certificate_chain_file( &_ctx, keyFile.path() ) != 1 )
    throw BadKeyFileEx( keyFile );

  // load the keys
  if ( SSL_CTX_use_PrivateKey_file( &_ctx, keyFile, SSL_FILETYPE_PEM ) != 1 )
    throw BadKeyFileEx( keyFile );
}
Exemplo n.º 3
0
//=============================================================================
FileLogChannel::FileLogChannel(const std::string& name,
                               const FilePath& path,
                               bool fallback)
  : LogChannel(name),
    m_fallback(fallback)
{
  if (Ok != m_file.open(path, File::Write | File::Append | File::Create,
                        0640)) {
    if (m_fallback) {
      std::cerr << "Unable to open log file '"
                << path.path() << "' - will log to stdout\n";
    }
  } else {
    m_file.write("\n----------\n\n");
  }
}
Exemplo n.º 4
0
	bool find(const std::string& name, FilePath& result, bool recursive=true) {
		bool found = false;
		if (dir && APR_SUCCESS == check_apr(apr_dir_open(&dir, dirname.c_str(), mPool))) {
			// iterate over directory:
			while ((!found) && APR_SUCCESS == (apr_dir_read(&dirent, APR_FINFO_TYPE|APR_FINFO_NAME, dir))) {
				//printf("test %s %s\n", dirname.c_str(), dirent.name);
				if (dirent.filetype == APR_REG && dirent.name && std::string(dirent.name) == name) {
					result.file(dirent.name);
					result.path(dirname);
					found = true;
					break;
				} else if (recursive && dirent.filetype == APR_DIR && dirent.name && dirent.name[0] != '.') {
					Path path(dirname + dirent.name + AL_FILE_DELIMITER);
					found = path.find(name, result, true);
				}
			}
		} else {
			printf("couldn't open directory %s\n", dirname.c_str());
		}
		return found;
	}
	int glob(const std::string& regex, FileList& result, bool recursive=true) {
		std::regex e(regex);
		if (dir && APR_SUCCESS == check_apr(apr_dir_open(&dir, dirname.c_str(), mPool))) {
			// iterate over directory:
			while (APR_SUCCESS == (apr_dir_read(&dirent, APR_FINFO_TYPE|APR_FINFO_NAME, dir))) {
				//printf("test %s %s\n", dirname.c_str(), dirent.name);
				if (dirent.filetype == APR_REG && dirent.name && std::regex_match(dirname+dirent.name,e) ) {
					FilePath res;
					res.file(dirent.name);
					res.path(dirname);
					result.add(res);
				} else if (recursive && dirent.filetype == APR_DIR && dirent.name && dirent.name[0] != '.') {
					Path path(dirname + dirent.name + AL_FILE_DELIMITER);
					path.glob(regex, result, true);
				}
			}
		} else {
			AL_WARN("couldn't open directory %s", dirname.c_str());
		}
		return result.count();
	}
Exemplo n.º 6
0
void ConfigManager::readXml(const icl_core::String& prefix, TiXmlNode *node, FilePath fp, bool extend_prefix)
{
  icl_core::String node_name(node->Value());
  icl_core::String fq_node_name = prefix;
  if (extend_prefix)
  {
    fq_node_name = prefix + "/" + node_name;
  }

  TiXmlNode *child = node->IterateChildren(NULL);
  while (child != 0)
  {
    if (child->Type() == TiXmlNode::TINYXML_ELEMENT)
    {
      if (strcmp(child->Value(), "INCLUDE") == 0)
      {
        TiXmlElement *child_element = dynamic_cast<TiXmlElement*>(child);
        assert(child_element != NULL);
        const char *included_file = child_element->GetText();
        if (included_file != NULL)
        {
          load(fp.path() + included_file);
        }
      }
      else
      {
        readXml(fq_node_name, child, fp);
      }
    }
    else if (child->Type() == TiXmlNode::TINYXML_TEXT)
    {
      insert(fq_node_name, child->Value());
      notify(fq_node_name);
    }

    child = node->IterateChildren(child);
  }
}
Exemplo n.º 7
0
bool Peer::onRead(Exception& ex, FilePath& filePath,DataReader& parameters,DataWriter& properties) {
	if(connected)
		return _handler.onRead(ex, *this, filePath,parameters,properties);
	ERROR("Resource '",filePath.path(),"' access by a not connected client")
	return false;
}