示例#1
0
文件: WebModules.cpp 项目: Affix/znc
void CWebSock::GetAvailSkins(VCString& vRet) const {
	vRet.clear();

	CString sRoot(GetSkinPath("_default_"));

	sRoot.TrimRight("/");
	sRoot.TrimRight("_default_");
	sRoot.TrimRight("/");

	if (!sRoot.empty()) {
		sRoot += "/";
	}

	if (!sRoot.empty() && CFile::IsDir(sRoot)) {
		CDir Dir(sRoot);

		for (unsigned int d = 0; d < Dir.size(); d++) {
			const CFile& SubDir = *Dir[d];

			if (SubDir.IsDir() && SubDir.GetShortName() == "_default_") {
				vRet.push_back(SubDir.GetShortName());
				break;
			}
		}

		for (unsigned int e = 0; e < Dir.size(); e++) {
			const CFile& SubDir = *Dir[e];

			if (SubDir.IsDir() && SubDir.GetShortName() != "_default_" && SubDir.GetShortName() != ".svn") {
				vRet.push_back(SubDir.GetShortName());
			}
		}
	}
}
示例#2
0
void CXmlFile::FixInputString(CString& sXml, const CString& sRootItem)
{
	CXmlItem::ValidateString(sXml);
	
	// check for any other obvious problems
	if (sRootItem)
	{
		CString sRoot(sRootItem);
		sRoot = '<' + sRoot;
		
		int nRoot = sXml.Find(sRoot);
		int nHeader = sXml.Find(_T("<?xml"));
		
		if (nHeader > nRoot)
		{
			// what should we do?
			
			/*
			// if there is another instance of sRootItem after the 
			// header tag then try deleting everything before the header
			// tag
			if (sXml.Find(sRoot, nHeader) != -1)
			{
			sXml = sXml.Right(nHeader);
			}
			else // try moving the header to the start
			{
			int nHeaderEnd = sXml.Find('>', nHeader) + 1;
			CString sHeader = sXml.Mid(nHeader, nHeaderEnd - nHeader);
			
			  sXml = sHeader + sXml.Left(nHeader) + sXml.Right(nHeaderEnd);
			  }
			*/
		}
	}
	
}
示例#3
0
文件: cii.cpp 项目: MangoCats/winglib
int main( int argc, char* argv[] )
{
	// Parse the command line
    t_cmdline8 cl( argc, argv );

	// Dumping the command line options to STDOUT?
	if ( cl.pb().IsSet( "d" ) || cl.pb().IsSet( "debug" ) )
	{	for ( TCmdLine< char >::iterator it = cl.begin(); cl.end() != it; it++ )
			str::Print( "[%s] = '%s'\n", it->first.c_str(), it->second->c_str() );
		return 0;
	} // end if

	// Ensure all needed parameters are present
	if ( cl.pb().IsSet( "h" ) || cl.pb().IsSet( "help" )
		 || !cl.pb().IsSet( "i" ) || !cl.pb().IsSet( "o" ) )
	{	str::Print( "Options\n"
				" -i            '<comma separated input directories>'\n"
				" -o            '<output directory>'\n"
				" -c            '<semi-colon separated compiled file types>' - default is '*.cii'\n"
				" -q / --quiet  Suppress all output\n"
				" -d / --debug  'Show processed command line array'\n"
				" -h / --help   Display this information\n"
				);
		return cl.pb().IsSet( "h" ) ? 0 : -1;
	} // end if

	if ( !disk::exists( cl.pb()[ "o" ] ) )
	{	str::Print( "Directory not found : %s\n" );
		return -1;
	} // end if

	// Combine quiet options
	if ( cl.pb().IsSet( "quiet" ) )
		cl.pb()[ "q" ] = 1;

	// res_extern.hpp
	disk::unlink( disk::FilePath< char, t_string8 >( cl.pb()[ "o" ].str(), "cii_resource_extern.hpp" ).c_str() );
	
	// res_list.hpp
	disk::WriteFile< char >( disk::FilePath< char, t_string8 >( cl.pb()[ "o" ].str(), "cii_resource.cpp" ),
							 t_string8() + "#include \"cii_resource.h\"\n"
										   "#include \"cii_resource_extern.hpp\"\n"
										   "\nextern SResInfo _cii_resources[] = \n{\n" );

	// resource.h
	disk::WriteFile< char >( disk::FilePath< char, t_string8 >( cl.pb()[ "o" ].str(), "cii_resource.h" ),
							 t_string8() + "\nstruct SCiiResourceInfo\n{"
										   "\n\tconst char*   name,"
										   "\n\tconst char*   data,"
										   "\n\tunsigned long size,"
										   "\n\tvoid*         func"
										   "\n};\n" 
										   "\nextern SResInfo _cii_resources[];\n"
										 );

	// Get compiled types
	t_strlist8 lstCmp;
	if ( !cl.pb().IsSet( "c" ) )
		lstCmp.push_back( "*.cii" );
	else
		lstCmp = str::SplitQuoted< char, t_string8, t_strlist8 >
								   ( (char*)cl.pb()[ "c" ].data(), cl.pb()[ "c" ].length(), 
								     ";, \t", "\"'", "\"'", "\\", true );

	// Separate the different directories
	t_strlist8 lstDir = str::SplitQuoted< char, t_string8, t_strlist8 >
										  ( (char*)cl.pb()[ "i" ].data(), cl.pb()[ "i" ].length(), 
											";, \t", "\"'", "\"'", "\\", true );

	// Root variable name
	t_string8 sRoot( "T" );
	sRoot += str::ToString< char, t_string8 >( (unsigned long)time( 0 ) );
	sRoot += "I";

	// Process each directory
	long lI = 0;
	stdForeach( t_strlist8::iterator, it, lstDir )
		process_directory( *it, cl.pb()[ "o" ].str(), "", cl, lstCmp, sRoot, lI );

	// Close up res_list.hpp
	disk::AppendFile< char >( disk::FilePath< char, t_string8 >( cl.pb()[ "o" ].str(), "cii_resource.cpp" ), 
							  t_string8( "\n{0,0,0,0}\n\n};\n" ) );

	return 0;
}