Esempio n. 1
0
FILE* fcFileOpener::OpenFile(const std::string& include_path)
{
	if ( include_path.empty() ) {
		return NULL;
	}

	std::string mod_path ( include_path );
	static std::string trimString("\"<> \t");

	mod_path.erase(0, mod_path.find_first_not_of(trimString));
	mod_path.erase(mod_path.find_last_not_of    (trimString)+1);

	if ( _scannedfiles.find(mod_path) != _scannedfiles.end() ) {
		// we already scanned this file
		return NULL;
	}

	// try to open the file as is
	FILE *fp (NULL);

	// try to prepend the search paths
	for (size_t i=0; i<_searchPath.size(); i++) {
		fp = try_open(_searchPath.at(i), mod_path);
		if ( fp ) return fp;
	}
	_scannedfiles.insert( mod_path );
	return NULL;
}
Esempio n. 2
0
FILE* fcFileOpener::OpenFile(const wxString& include_path, wxString &filepath)
{
    filepath.Clear();
    if ( include_path.empty() ) {
        return NULL;
    }

    wxString mod_path ( include_path );

    static wxString trimString("\"<> \t");

    mod_path.erase(0, mod_path.find_first_not_of(trimString));
    mod_path.erase(mod_path.find_last_not_of    (trimString)+1);

    if ( _scannedfiles.find(mod_path) != _scannedfiles.end() ) {
        // we already scanned this file
        filepath.Clear();
        return NULL;
    }

    FILE *fp (NULL);
    
    // first try to cwd
    fp = try_open(_cwd, mod_path, filepath);
    if ( fp ) {
        return fp;
    }
    
    // Now try the search directories
    for (size_t i=0; i<_searchPath.size(); ++i) {
        fp = try_open(_searchPath.at(i), mod_path, filepath);
        if ( fp ) return fp;
    }
    
    _scannedfiles.insert( mod_path );
    filepath.Clear();
    return NULL;
}