shells_path is now a directory of .shell files
Matches the existing units_path pattern — shells_path points to a directory that is scanned for .shell files rather than a single monolithic definitions file.
This commit is contained in:
1 parent
879f07ec4b
commit
a7eab683e8
6 files changed
+87
-24
No files matched your search
@@ -61,4 +61,39 @@ int Shell::load_root( Json::Value loader_root )
|
||||
throw ShellException("No source_cmd attribute specified when loading a shell definition.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void get_shells_from_dir( std::vector<std::string> * files, std::string path )
|
||||
{
|
||||
DIR* dirFile = opendir( path.c_str() );
|
||||
if ( dirFile )
|
||||
{
|
||||
struct dirent* hFile;
|
||||
errno = 0;
|
||||
while (( hFile = readdir( dirFile )) != NULL )
|
||||
{
|
||||
if ( !strcmp( hFile->d_name, "." ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( !strcmp( hFile->d_name, ".." ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// hidden files
|
||||
if ( hFile->d_name[0] == '.' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( strstr( hFile->d_name, ".shell" ))
|
||||
{
|
||||
std::string full_path = path + "/" + hFile->d_name;
|
||||
files->push_back( full_path );
|
||||
}
|
||||
}
|
||||
closedir( dirFile );
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@
|
||||
#define REX_SHELLS_H
|
||||
|
||||
#include "../json_support/JSON.h"
|
||||
#include "../misc/helpers.h"
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <dirent.h>
|
||||
|
||||
class Shell: public JSON_Loader {
|
||||
public:
|
||||
@@ -23,4 +27,6 @@ class Shell: public JSON_Loader {
|
||||
|
||||
};
|
||||
|
||||
void get_shells_from_dir( std::vector<std::string> * files, std::string path );
|
||||
|
||||
#endif //REX_SHELLS_H
|
||||
Reference in new issue
Block a user