本文整理汇总了C++中path::directory_string方法的典型用法代码示例。如果您正苦于以下问题:C++ path::directory_string方法的具体用法?C++ path::directory_string怎么用?C++ path::directory_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::directory_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findPlugins
/***************************
Find liblightsparkBACKENDplugin libraries
****************************/
void PluginManager::findPlugins()
{
//Search for all files under ${PRIVATELIBDIR}/plugins
//Verify if they are audio plugins
//If true, add to list of audio plugins
string froot ( PRIVATELIBDIR ), fplugins ( "/plugins/" ); //LS should always look in the plugins folder, nowhere else
const path plugins_folder = froot + fplugins;
const string pattern ( "liblightspark+[A-Za-z]+plugin.so" );
regex file_pattern ( pattern ); //pattern of ls plugins
#if defined DEBUG
cout << "Looking for plugins under " << plugins_folder << " for pattern " << pattern << endl;
#endif
if ( !is_directory ( plugins_folder ) ) {
LOG ( LOG_ERROR,_ ( ( ( string ) ( "The plugins folder doesn't exists under " + plugins_folder.string() ) ).c_str() ) );
} else {
for ( recursive_directory_iterator itr ( plugins_folder ), end_itr; itr != end_itr; ++itr ) {
if ( is_regular_file ( itr.status() ) ) { //Is it a real file? This will remove symlink
string leaf_name = itr->path().filename();
if ( regex_match ( leaf_name, file_pattern ) ) { // Does it answer to the desired pattern?
string fullpath = plugins_folder.directory_string() + leaf_name;
//Try to load the file and see if it's an audio plugin
if ( HMODULE h_plugin = LoadLib ( fullpath ) ) {
PLUGIN_FACTORY p_factory_function = ( PLUGIN_FACTORY ) ExtractLibContent ( h_plugin, "create" );
PLUGIN_CLEANUP p_cleanup_function = ( PLUGIN_CLEANUP ) ExtractLibContent ( h_plugin, "release" );
if ( p_factory_function != NULL && p_cleanup_function != NULL ) { //Does it contain the LS IPlugin?
IPlugin *p_plugin = ( *p_factory_function ) (); //Instanciate the plugin
LOG ( LOG_NO_INFO,_ ( "A plugin was found. Adding it to the list." ) );
addPluginToList ( p_plugin, fullpath ); //Add the plugin info to the audio plugins list
( *p_cleanup_function ) ( p_plugin );
CloseLib ( h_plugin );
} else { //If doesn't implement our IPlugin interface entry points, close it
CloseLib ( h_plugin );
}
}
}
}
}
}
}
示例2: findPlugins
/***************************
Find liblightsparkBACKENDplugin libraries
****************************/
void PluginManager::findPlugins()
{
//Search for all files under the plugins directory
//Verify if they are audio plugins
//If true, add to list of audio plugins
#ifdef _WIN32
const path plugins_folder = getExectuablePath();
#else
const path plugins_folder = string(PRIVATELIBDIR) + "/plugins/";
#endif
const string pattern ( "liblightspark+[A-Za-z]+plugin.*" );
//Stuff used by/for pcre
const char* patternError;
int patternErrorOffset;
pcre* file_pattern = pcre_compile ( pattern.c_str(), 0, &patternError, &patternErrorOffset, NULL );
if(patternError)
throw RunTimeException("PluginManager::findPlugins(): can't compile file_pattern");
//We don't expect any captured substrings, so 3 ints should be enough
int patternOvector[3];
#if defined DEBUG
LOG(LOG_INFO, "Looking for plugins under " << plugins_folder << " for pattern " << pattern);
#endif
if ( !is_directory ( plugins_folder ) )
{
LOG ( LOG_ERROR, _ ( ( ( string ) ( "The plugins folder doesn't exists under " + plugins_folder.string() ) ).c_str() ) );
}
else
{
for ( directory_iterator itr ( plugins_folder ), end_itr; itr != end_itr; ++itr )
{
if ( is_regular_file ( *itr ) ) //Is it a real file? This will remove symlink
{
#if BOOST_VERSION >= 104600
string leaf_name = itr->path().filename().string();
#else
string leaf_name = itr->path().filename();
#endif
int rc=pcre_exec(file_pattern, NULL, leaf_name.c_str(), leaf_name.length(), 0, 0, patternOvector, 3);
if ( rc > 0 ) // Does it answer to the desired pattern?
{
#if BOOST_VERSION >= 104600
path fullpath = plugins_folder.string();
#else
path fullpath = plugins_folder.directory_string();
#endif
fullpath /= leaf_name;
//Try to load the file and see if it's an audio plugin
if ( GModule* h_plugin = g_module_open( fullpath.string().c_str(), G_MODULE_BIND_LAZY) )
{
PLUGIN_FACTORY p_factory_function;
PLUGIN_CLEANUP p_cleanup_function;
if ( g_module_symbol(h_plugin, "create", (void**)&p_factory_function)
&& g_module_symbol(h_plugin, "release", (void**)&p_cleanup_function) )
{ //Does it contain the LS IPlugin?
IPlugin *p_plugin = p_factory_function (); //Instanciate the plugin
LOG ( LOG_INFO, _ ( "A plugin was found. Adding it to the list." ) );
addPluginToList ( p_plugin, fullpath.string() ); //Add the plugin info to the audio plugins list
p_cleanup_function ( p_plugin );
g_module_close ( h_plugin );
}
else //If doesn't implement our IPlugin interface entry points, close it
{
g_module_close( h_plugin );
}
}
}
}
}
}
pcre_free(file_pattern);
}
示例3: findPlugins
/***************************
Find liblightsparkBACKENDplugin libraries
****************************/
void PluginManager::findPlugins()
{
//Search for all files under ${PRIVATELIBDIR}/plugins
//Verify if they are audio plugins
//If true, add to list of audio plugins
string froot ( PRIVATELIBDIR ), fplugins ( "/plugins/" ); //LS should always look in the plugins folder, nowhere else
const path plugins_folder = froot + fplugins;
const string pattern ( "liblightspark+[A-Za-z]+plugin.so" );
//Stuff used by/for pcre
const char* patternError;
int patternErrorOffset;
pcre* file_pattern = pcre_compile ( pattern.c_str(), 0, &patternError, &patternErrorOffset, NULL );
if(patternError)
throw RunTimeException("PluginManager::findPlugins(): can't compile file_pattern");
//We don't expect any captured substrings, so 3 ints should be enough
int patternOvector[3];
#if defined DEBUG
cout << "Looking for plugins under " << plugins_folder << " for pattern " << pattern << endl;
#endif
if ( !is_directory ( plugins_folder ) )
{
LOG ( LOG_ERROR, _ ( ( ( string ) ( "The plugins folder doesn't exists under " + plugins_folder.string() ) ).c_str() ) );
}
else
{
for ( recursive_directory_iterator itr ( plugins_folder ), end_itr; itr != end_itr; ++itr )
{
if ( is_regular_file ( itr.status() ) ) //Is it a real file? This will remove symlink
{
string leaf_name = itr->path().filename();
int rc=pcre_exec(file_pattern, NULL, leaf_name.c_str(), leaf_name.length(), 0, 0, patternOvector, 3);
if ( rc > 0 ) // Does it answer to the desired pattern?
{
string fullpath = plugins_folder.directory_string() + leaf_name;
//Try to load the file and see if it's an audio plugin
if ( HMODULE h_plugin = LoadLib ( fullpath ) )
{
PLUGIN_FACTORY p_factory_function = ( PLUGIN_FACTORY ) ExtractLibContent ( h_plugin, "create" );
PLUGIN_CLEANUP p_cleanup_function = ( PLUGIN_CLEANUP ) ExtractLibContent ( h_plugin, "release" );
if ( p_factory_function != NULL && p_cleanup_function != NULL ) //Does it contain the LS IPlugin?
{
IPlugin *p_plugin = ( *p_factory_function ) (); //Instanciate the plugin
LOG ( LOG_NO_INFO, _ ( "A plugin was found. Adding it to the list." ) );
addPluginToList ( p_plugin, fullpath ); //Add the plugin info to the audio plugins list
( *p_cleanup_function ) ( p_plugin );
CloseLib ( h_plugin );
}
else //If doesn't implement our IPlugin interface entry points, close it
{
CloseLib ( h_plugin );
}
}
}
}
}
}
pcre_free(file_pattern);
}