forked from Mirror/GodMode9
Scripting: Support TIMESTAMP and DATESTAMP env variable
This commit is contained in:
parent
3f87c42334
commit
8e3d864d83
@ -30,8 +30,10 @@ ask -o -s "Really continue running this script?\n(I will completely ignore your
|
||||
# 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)
|
||||
# TIMESTAMP is the current time in hhmmss format
|
||||
# DATESTAMP is the current date in YYMMDD format
|
||||
# Use $[VAR] to get the *content* of a variable VAR
|
||||
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]"
|
||||
echo "Your serial number is $[SERIAL]\nYour std output path is $[GM9OUT]\nCurrent dir is $[CURRDIR]\nCurrent datestamp is: $[DATESTAMP]\nCurrent timestamp is: $[TIMESTAMP]\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
|
||||
|
@ -6,6 +6,6 @@ set ERRORMSG "EmuNAND backup failed"
|
||||
set SUCCESSMSGMSG "EmuNAND backup success"
|
||||
|
||||
ask "Create a EmuNAND backup in $[GM9OUT]?"
|
||||
findnot $[GM9OUT]/$[SERIAL]_emunand_???.bin OUTPATH
|
||||
findnot $[GM9OUT]/$[DATESTAMP]_$[SERIAL]_emunand_???.bin OUTPATH
|
||||
cp E:/nand_minsize.bin $[OUTPATH]
|
||||
echo "Backup created succesfully:\n$[OUTPATH]"
|
||||
|
@ -5,6 +5,6 @@
|
||||
set ERRORMSG "SysNAND backup failed"
|
||||
|
||||
ask "Create a SysNAND backup in $[GM9OUT]?"
|
||||
findnot $[GM9OUT]/$[SERIAL]_sysnand_???.bin OUTPATH
|
||||
findnot $[GM9OUT]/$[DATESTAMP]_$[SERIAL]_sysnand_???.bin OUTPATH
|
||||
cp S:/nand_minsize.bin $[OUTPATH]
|
||||
echo "Backup created succesfully:\n$[OUTPATH]"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "filetype.h"
|
||||
#include "power.h"
|
||||
#include "vff.h"
|
||||
#include "rtc.h"
|
||||
#include "sha.h"
|
||||
#include "ui.h"
|
||||
|
||||
@ -128,6 +129,15 @@ char* get_var(const char* name, char** endptr) {
|
||||
}
|
||||
|
||||
if (n_var >= max_vars || !*(vars[n_var].name)) n_var = 0;
|
||||
if (n_var && (strncmp(vars[n_var].name, "DATESTAMP", _VAR_NAME_LEN) == 0)) {
|
||||
DsTime dstime;
|
||||
get_dstime(&dstime);
|
||||
snprintf(vars[n_var].content, _VAR_CNT_LEN, "%02lX%02lX%02lX", (u32) dstime.bcd_Y, (u32) dstime.bcd_M, (u32) dstime.bcd_D);
|
||||
} else if (n_var && (strncmp(vars[n_var].name, "TIMESTAMP", _VAR_NAME_LEN) == 0)) {
|
||||
DsTime dstime;
|
||||
get_dstime(&dstime);
|
||||
snprintf(vars[n_var].content, _VAR_CNT_LEN, "%02lX%02lX%02lX", (u32) dstime.bcd_h, (u32) dstime.bcd_m, (u32) dstime.bcd_s);
|
||||
}
|
||||
|
||||
return vars[n_var].content;
|
||||
}
|
||||
@ -189,6 +199,8 @@ bool init_vars(const char* path_script) {
|
||||
set_var("CURRDIR", curr_dir);
|
||||
set_var("SYSID0", env_sys_id0);
|
||||
set_var("EMUID0", env_emu_id0);
|
||||
set_var("DATESTAMP", ""); // needs to be set on every access
|
||||
set_var("TIMESTAMP", ""); // needs to be set on every access
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user