mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-10 18:24:27 +08:00
chg: some more checks in pathing
This commit is contained in:
parent
c1b03b7fc4
commit
ab38130c3e
2 changed files with 21 additions and 16 deletions
|
@ -142,9 +142,11 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
|
||||
bool found = false;
|
||||
int error;
|
||||
if (get_my_executable_directory() != NULL) {
|
||||
char script_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
strcpy(script_path, get_my_executable_directory());
|
||||
const char* exec_path = get_my_executable_directory();
|
||||
|
||||
if (exec_path != NULL) {
|
||||
char script_path[strlen(exec_path) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
strcpy(script_path, exec_path);
|
||||
strcat(script_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(script_path, script_name);
|
||||
strcat(script_path, suffix);
|
||||
|
|
|
@ -1133,38 +1133,41 @@ int set_pm3_libraries(lua_State *L) {
|
|||
|
||||
//--add to the LUA_PATH (package.path in lua)
|
||||
// so we can load scripts from various places:
|
||||
if (get_my_executable_directory() != NULL) {
|
||||
const char *exec_path = get_my_executable_directory();
|
||||
if (exec_path != NULL) {
|
||||
// from the ./luascripts/ directory
|
||||
char scripts_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, get_my_executable_directory());
|
||||
char scripts_path[strlen(exec_path) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, exec_path);
|
||||
strcat(scripts_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(scripts_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, scripts_path);
|
||||
// from the ./lualib/ directory
|
||||
char libraries_path[strlen(get_my_executable_directory()) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, get_my_executable_directory());
|
||||
char libraries_path[strlen(exec_path) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, exec_path);
|
||||
strcat(libraries_path, LUA_LIBRARIES_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, libraries_path);
|
||||
}
|
||||
char *userpath = getenv("HOME");
|
||||
if (userpath != NULL) {
|
||||
char *user_path = getenv("HOME");
|
||||
if (user_path != NULL) {
|
||||
// from the ~/.proxmark3/luascripts/ directory
|
||||
char scripts_path[strlen(userpath) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, userpath);
|
||||
char scripts_path[strlen(user_path) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, user_path);
|
||||
strcat(scripts_path, LUA_PM3_USER_DIRECTORY);
|
||||
strcat(scripts_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(scripts_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, scripts_path);
|
||||
// from the ~/.proxmark3/lualib/ directory
|
||||
char libraries_path[strlen(userpath) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, userpath);
|
||||
|
||||
// from the ~/.proxmark3/lualib/ directory
|
||||
char libraries_path[strlen(user_path) + strlen(LUA_PM3_USER_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(libraries_path, user_path);
|
||||
strcat(libraries_path, LUA_PM3_USER_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_DIRECTORY);
|
||||
strcat(libraries_path, LUA_LIBRARIES_WILDCARD);
|
||||
setLuaPath(L, libraries_path);
|
||||
}
|
||||
{
|
||||
|
||||
if (strlen(LUA_PM3_SYSTEM_DIRECTORY) != 0 || strlen(LUA_SCRIPTS_DIRECTORY) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0 ) {
|
||||
// from the /usr/local/share/proxmark3/luascripts/ directory
|
||||
char scripts_path[strlen(LUA_PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1];
|
||||
strcpy(scripts_path, LUA_PM3_SYSTEM_DIRECTORY);
|
||||
|
|
Loading…
Reference in a new issue