mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Scripting: add CURRDIR environmental variable
This commit is contained in:
parent
3cfdc3dc77
commit
3025329799
@ -26,11 +26,12 @@ ask -o -s "Really continue running this script?\n(I will completely ignore your
|
||||
|
||||
# ENVIRONMENTAL VARS
|
||||
# SERIAL is the serial number of your device
|
||||
# GM9OUT is the standard ouptput path
|
||||
# GM9OUT is the standard output path
|
||||
# CURRDIR is the directory the script is running from
|
||||
# SYSID0 is the id0 belonging to your SysNAND
|
||||
# EMUID0 is the id0 belonging to your EmuNAND (if available)
|
||||
# Use $[VAR] to get the *content* of a variable VAR
|
||||
echo "Your serial number is $[SERIAL]\nYour std output path is $[GM9OUT]\n \nYour sys / emu ID0 is:\n$[SYSID0]\n$[EMUID0]"
|
||||
echo "Your serial number is $[SERIAL]\nYour std output path is $[GM9OUT]\nCurrent dir is $[CURRDIR]\n \nYour sys / emu ID0 is:\n$[SYSID0]\n$[EMUID0]"
|
||||
|
||||
# ERRORMSG and SUCCESSMSG / 'set' COMMAND
|
||||
# These two are special environment vars, allowing you to control the message on script failure or success
|
||||
|
@ -134,7 +134,7 @@ char* set_var(const char* name, const char* content) {
|
||||
return vars[n_var].content;
|
||||
}
|
||||
|
||||
bool init_vars(void) {
|
||||
bool init_vars(const char* path_script) {
|
||||
// reset var buffer
|
||||
memset(VAR_BUFFER, 0x00, VAR_BUFFER_SIZE);
|
||||
|
||||
@ -144,6 +144,12 @@ bool init_vars(void) {
|
||||
(FileGetData("1:/rw/sys/SecureInfo_B", (u8*) env_serial, 0xF, 0x102) != 0xF))
|
||||
snprintf(env_serial, 0xF, "UNKNOWN");
|
||||
|
||||
// current path
|
||||
char curr_dir[_VAR_CNT_LEN];
|
||||
strncpy(curr_dir, path_script, _VAR_CNT_LEN);
|
||||
char* slash = strrchr(curr_dir, '/');
|
||||
if (slash) *slash = '\0';
|
||||
|
||||
// device sysnand / emunand id0
|
||||
char env_sys_id0[32+1];
|
||||
char env_emu_id0[32+1];
|
||||
@ -163,6 +169,7 @@ bool init_vars(void) {
|
||||
set_var("NULL", ""); // this one is special and should not be changed later
|
||||
set_var("SERIAL", env_serial);
|
||||
set_var("GM9OUT", OUTPUT_PATH);
|
||||
set_var("CURRDIR", curr_dir);
|
||||
set_var("SYSID0", env_sys_id0);
|
||||
set_var("EMUID0", env_emu_id0);
|
||||
|
||||
@ -479,7 +486,7 @@ bool ExecuteGM9Script(const char* path_script) {
|
||||
*end = '\0';
|
||||
|
||||
// initialise variables
|
||||
init_vars();
|
||||
init_vars(path_script);
|
||||
|
||||
for (u32 line = 1; ptr < end; line++) {
|
||||
u32 flags = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user