예제 #1
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;
}
예제 #2
0
    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
    }
예제 #3
0
void AboutOpera::writePaths( URL& url )
{
	OpString type, name;

	TRAPD(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_OPERASYSINFO, name));
	if (OpStatus::IsSuccess(rc)) outHeading(url, name);
	url.WriteDocumentData(UNI_L(" <dl>"));

	TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_SETTINGS, type));
	// This code makes the assumption that we're using PrefsFile and OpFile
# ifdef PREFS_READ
	PrefsFile *prefsfile  = (PrefsFile *) g_prefsManager->GetReader();
	OpFile    *inifile    = (OpFile *)    prefsfile->GetFile();
	rc = name.Set(inifile->GetFullPath());
# else
	rc = OpStatus::ERR_NOT_SUPPORTED;
# endif
	if (OpStatus::IsSuccess(rc))
	{
		cleanPath(name);
		outRow(url, type, name);
	}

#ifdef AUTOSAVE_WINDOWS
	TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_DEFAULTWINFILE, type));
	if (OpStatus::IsSuccess(rc))
	{
		OpFile f;
		TRAP(rc, g_pcfiles->GetFileL(PrefsCollectionFiles::WindowsStorageFile, f));
		if (OpStatus::IsSuccess(rc)) rc = name.Set(f.GetFullPath());
		if (OpStatus::IsSuccess(rc))
		{
			cleanPath(name);
			outRow(url, type, name);
		}
	}
#endif // AUTOSAVE_WINDOWS

	TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_HOTLISTFILE, type));
	if (OpStatus::IsSuccess(rc))
	{
		OpFile f;
		TRAP(rc, g_pcfiles->GetFileL(PrefsCollectionFiles::HotListFile, f));
		if (OpStatus::IsSuccess(rc)) rc = name.Set(f.GetFullPath());
		if (OpStatus::IsSuccess(rc))
		{
			cleanPath(name);
			outRow(url, type, name);
		}
	}

	TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_OPERADIRECTORY, type));
	if (OpStatus::IsSuccess(rc))
	{
		rc = g_folder_manager->GetFolderPath(OPFILE_HOME_FOLDER, name);
		if (OpStatus::IsSuccess(rc))
		{
			cleanPath(name, TRUE);
			outRow(url, type, name);
		}
	}

	TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_CACHEDIR, type));
	if (OpStatus::IsSuccess(rc))
	{
		rc = g_folder_manager->GetFolderPath(OPFILE_CACHE_FOLDER, name);
		if (OpStatus::IsSuccess(rc))
		{
			cleanPath(name, TRUE);
			outRow(url, type, name);
		}
	}

#ifdef M2_SUPPORT
	TRAP(rc, g_languageManager->GetStringL(Str::S_IDABOUT_HELPDIR, type)); // HELPDIR -> MAILDIR maybe
	if (OpStatus::IsSuccess(rc))
	{
		rc = g_folder_manager->GetFolderPath(OPFILE_MAIL_FOLDER, name);
		if (OpStatus::IsSuccess(rc))
		{
			cleanPath(name, TRUE);
			outRow(url, type, name);
		}
	}
#endif // M2_SUPPORT

	if (OpStatus::IsSuccess(getHelpDir(name)))
	{
		TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_HELPDIR, type));
		if (OpStatus::IsSuccess(rc))
		{
			cleanPath(name, TRUE);
			outRow(url, type, name);
		}
	}

	// Plugin path:
	TRAP(rc, g_languageManager->GetStringL(Str::SI_IDABOUT_PLUGINPATH, type));
	if (OpStatus::IsSuccess(rc))
	{
		rc = name.Set(g_pcapp->GetStringPref(PrefsCollectionApp::PluginPath));
		if (!OpStatus::IsSuccess(rc)) name.Empty();

		while (name.Length())
		{
			int col = name.FindFirstOf(':');
			if (col == KNotFound)
			{
				cleanPath(name, TRUE);
				outRow(url, type, name);
				name.Empty();
			}
			else
			{
				OpString nom;
				if (OpStatus::IsSuccess(nom.Set(name.CStr(), col)))
				{
					cleanPath(nom, TRUE);
					outRow(url, type, nom);
				}
				// else: silent OOM :-(
				name.Delete(0, col+1);
			}
			type.Empty(); // only say "Plugin path:" on first row.
		}
#if 0 // 1 do we want to mention plugin path even if empty ?  Moose prefers not in bug #206083.
		if (type.Length())
		{
			OP_ASSERT(name.IsEmpty());
			outRow(url, type, name); // name is empty, which is what we want here ...
		}
#endif // mention plugin path even if empty
	}

#ifdef USER_JAVASCRIPT
	TRAP(rc, g_languageManager->GetStringL(Str::S_IDABOUT_USERJSFILE, type));
	if (OpStatus::IsSuccess(rc))
	{
		name.SetL(g_pcjs->GetStringPref(PrefsCollectionJS::UserJSFiles));
		/* This preference can be a comma-joined sequence of tokens, each of
		 * which is a directory or file and may have arbitrarily many ;-suffixes
		 * which may be either greasemonkey or opera (other things may be added
		 * to this list in future).  For now (2005/May, O8) this is unofficial -
		 * users are told it's just a single file or directory name - so we can
		 * just display it "as is"; but we'll eventually need to parse it as
		 * above and display it nicely.
		 */
		PosixNativeUtil::NativeString native_path (name.CStr());
		if (native_path.get() && access(native_path.get(), F_OK) == 0)
		{
			cleanPath(name, FALSE);
			outRow(url, type, name);
		}
	}
#endif // USER_JAVASCRIPT

#ifdef PREFS_USE_CSS_FOLDER_SCAN
	TRAP(rc, g_languageManager->GetStringL(Str::S_USER_CSS_LABEL, type));
	if (OpStatus::IsSuccess(rc))
	{
		OpString tmp_storage;
		name.Set(g_folder_manager->GetFolderPathIgnoreErrors(OPFILE_USERPREFSSTYLE_FOLDER, tmp_storage));
		cleanPath(name, FALSE);
		outRow(url, type, name);
	}
#endif // PREFS_USE_CSS_FOLDER_SCAN

	url.WriteDocumentData(UNI_L("\n </dl>\n"));
}
예제 #4
0
파일: posix.cpp 프로젝트: Zoxc/mirb
		CharArray native_null_path(const CharArray &path)
		{
			return native_path(path).c_str();
		}