Exemple #1
0
 t_filename splitpath( string const& in ) {
    fn_intern::t_bfe bfe;
    fn_intern::splitpath( in, bfe );
    return t_filename( bfe.path, bfe.base, bfe.ext );
 }
   void ftw::scan_folders() {

      if( !path_exists( _impl->_path.path() ) ) {
         throw bad_ftw( "folder doesn't exist: " + _impl->_path.path() );
      }

      if( !is_directory( _impl->_path.path() ) ) {
         throw bad_ftw( "input is not a folder: " + _impl->_path.path() );
      }

      //boost::regex pattern("*"); // list all files starting with a
      boost::filesystem::path  current_dir( _impl->_path.path() ); //

      for( recursive_directory_iterator iter( current_dir ), end;
            iter != end;
            ++iter ) {

         boost::filesystem::path p = iter->path();

         if( boost::filesystem::is_directory( p ) ) {
            std::string dname = p.string();
            size_t i = index( dname, ".tmp" );

            if( i != string::npos ) {
               i = 0;
            }

            bool b = exclude_folder( dname, _impl->_folder_exclude );

            if( b == false ) {
               t_filename fn;
               fn.path( dname );
               _impl->_folders.push_back( fn );
            }
         }

         if( boost::filesystem::is_regular_file( p ) ) {
            std::string name = p.string();
            t_filename fn = t_filename( name );
            string dir = fn.path();
            size_t i = index( dir, ".tmp" );

            if( i != string::npos ) {
               i = 0;
            }

            bool bdir = exclude_folder( dir, _impl->_folder_exclude );

            if( bdir == false ) {
               bool b_include = include_file( name, _impl->_file_include );

               if( b_include == true ) {
                  _impl->_files.push_back( name );
               }
            }

            //    if (regex_match(name, pattern))
            //      std::cout << iter->path() << "\n";
         }
      }
   }
Exemple #3
0
int lex_build_script(struct build_script_lexer_state * build_script_lexer_state, unsigned char * filename, unsigned char * buffer, unsigned int buffer_size){
	struct memory_pooler * build_script_lexer_token_pool = memory_pooler_collection_get_pool(build_script_lexer_state->c.memory_pooler_collection, sizeof(struct build_script_lexer_token));
	build_script_lexer_state->c.buf = buffer;
	build_script_lexer_state->c.position = 0;
	build_script_lexer_state->c.current_line = 0;
	build_script_lexer_state->c.filename = filename;
	build_script_lexer_state->c.buffer_size = buffer_size;

	g_format_buffer_use();

	struct_build_script_lexer_token_ptr_list_create(&build_script_lexer_state->tokens);

	while(build_script_lexer_state->c.position < buffer_size){
		unsigned int rtn = 0;
		unsigned char * first_byte = &build_script_lexer_state->c.buf[build_script_lexer_state->c.position];
		enum build_script_token_type type;
		struct build_script_lexer_token * new_token;

		if((rtn = t_space(&build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_SPACE;
		}else if((rtn = t_newline(&build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_NEWLINE;
			build_script_lexer_state->c.current_line = build_script_lexer_state->c.current_line + rtn; /* NEWLINE token can be multiple newlines */
		}else if((rtn = t_keyword((const unsigned char *)"PREPROCESS", &build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_PREPROCESS;
		}else if((rtn = t_keyword((const unsigned char *)"CODE GENERATE", &build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_CODE_GENERATE;
		}else if((rtn = t_keyword((const unsigned char *)"LINK", &build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_LINK;
		}else if((rtn = t_keyword((const unsigned char *)"SYMBOLS", &build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_SYMBOLS;
		}else if((rtn = t_keyword((const unsigned char *)"TO", &build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_TO;
		}else if((rtn = t_filename(&build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_FILENAME;
		}else if((rtn = t_symbol((const unsigned char *)",", &build_script_lexer_state->c, build_script_lexer_state->c.position))){
			type = B_COMMA_CHAR;
		}else{
			unsigned int i = 0;
			buffered_printf(build_script_lexer_state->c.buffered_output, "Lexer stopping on character '%c' 0x(%x)\n", build_script_lexer_state->c.buf[build_script_lexer_state->c.position], build_script_lexer_state->c.buf[build_script_lexer_state->c.position]);
			for(build_script_lexer_state->c.position = 0; i < build_script_lexer_state->c.position + 100; i++){
				if(build_script_lexer_state->c.buf[i]){
					buffered_printf(build_script_lexer_state->c.buffered_output, "%c", build_script_lexer_state->c.buf[i]);
				}
			}
			g_format_buffer_release();
			return 1;
		}

		new_token = (struct build_script_lexer_token *)memory_pooler_malloc(build_script_lexer_token_pool);
		new_token->type = type;
		new_token->first_byte = first_byte;
		new_token->last_byte = (unsigned char *)((first_byte + rtn) - 1);

		struct_build_script_lexer_token_ptr_list_add_end(&build_script_lexer_state->tokens, new_token);
		show_lexer_token(build_script_lexer_state->c.buffered_output, get_c_token_type_names()[new_token->type], new_token->first_byte, new_token->last_byte, SHOW_LEXER_TOKENS);
		build_script_lexer_state->c.position += rtn;
	}
	g_format_buffer_release();
	return 0;
}