Esempio n. 1
0
  bool found_include_directive(const ContextT &ctx, const std::string &filename, bool include_next)
  {
    bool isSystem = filename[0] == '<';
    std::string path = filename.substr(1, filename.length() - 2);
    std::string dirPath, nativePath;

    bool result = ctx.find_include_file(path, dirPath, isSystem, nullptr);

    return !result;
  }
Esempio n. 2
0
bool CPreProcessor::locate_include_file(ContextT& ctx, std::string& file_path, bool is_system, char const* current_name, std::string& dir_path, std::string& native_name)
{
	//if (is_system) {
	// Check if file is in the files map	
	if ( CPreProcessor::files_.find(file_path) != CPreProcessor::files_.end())
	{
		//std::cout << "locate_include_file 1: file_path:" << file_path << " dir_path:" << dir_path << " native_name:" << native_name << std::endl;
		native_name = file_path;

		return true;
	}
	else
	{
		namespace fs = boost::filesystem;
		//} else {
		// could not locate file
		
		fs::path baseDir = fs::path(baseDirectory_);
		if ( fs::exists(baseDir) && fs::is_directory(baseDir))
		{
			file_path = baseDir.string() + std::string("/") + file_path;
		}
		//std::cout << "baseDirectory_: " << baseDirectory_ << std::endl;
		//std::cout << "locate_include_file doesn't exist 2: file_path:" << file_path << " dir_path:" << dir_path << " native_name:" << native_name << std::endl;
		if ( !ctx.find_include_file(file_path, dir_path, is_system, current_name))
		{
			return false;
		}
		

		fs::path native_path(wave::util::create_path(file_path));
		if ( !fs::exists(native_path))
		{
			//BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file,
			//    file_path.c_str(), ctx.get_main_pos());
			//std::cout << "error: doesn't exist" << std::endl;
			//std::cout << "locate_include_file doesn't exist 3: file_path:" << file_path << " dir_path:" << dir_path << " native_name:" << native_name << std::endl;
			return false;
		}

		// return the unique full file system path of the located file
		native_name = wave::util::native_file_string(native_path);

		return true;
	}

	// include file has not been located
	return false;
}
    bool
    locate_include_file(ContextT& ctx, std::string &file_path,
                        bool is_system, char const *current_name, std::string &dir_path,
                        std::string &native_name)
    {
        if (!ctx.find_include_file (file_path, dir_path, is_system, current_name))
            return false;   // could not locate file

        namespace fs = boost::filesystem;

        fs::path native_path(wave::util::create_path(file_path));
        if (!fs::exists(native_path)) {
            BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file,
                                 file_path.c_str(), ctx.get_main_pos());
            return false;
        }

        // return the unique full file system path of the located file
        native_name = wave::util::native_file_string(native_path);

        return true;      // include file has been located successfully
    }