diff --git a/delete-storage.bat b/delete-storage.bat new file mode 100755 index 0000000..b2ed3f1 --- /dev/null +++ b/delete-storage.bat @@ -0,0 +1,26 @@ +@echo off +REM delete-storage.bat +REM Deletes the Millions JSON storage for resetting app state +REM The storage file location is chosen by StorageFile.java + +SET "STORAGE_FOLDER_NAME=Millions" +SET "STORAGE_FILE=storage.json" + +REM Use %APPDATA% if set, otherwise fallback to %USERPROFILE% +IF DEFINED APPDATA ( + SET "STORAGE_DIR=%APPDATA%\%STORAGE_FOLDER_NAME%" +) ELSE ( + SET "STORAGE_DIR=%USERPROFILE%\%STORAGE_FOLDER_NAME%" +) + +SET "STORAGE_PATH=%STORAGE_DIR%\%STORAGE_FILE%" + +IF EXIST "%STORAGE_PATH%" ( + ECHO Deleting storage at %STORAGE_PATH% ... + DEL /F "%STORAGE_PATH%" + ECHO Storage deleted. +) ELSE ( + ECHO Storage not found at %STORAGE_PATH%. +) + +PAUSE diff --git a/delete-storage.sh b/delete-storage.sh new file mode 100755 index 0000000..c387f85 --- /dev/null +++ b/delete-storage.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# delete-storage.sh +# Deletes the Millions JSON storage for resetting app state +# The storage file location is chosen by StorageFile.java + +set -e + +STORAGE_FOLDER_NAME="Millions" +STORAGE_FILE="storage.json" + +OS=$(uname | tr '[:upper:]' '[:lower:]') +HOME_DIR="$HOME" + +# Determine database folder path based on OS +if [[ "$OS" == *"darwin"* ]]; then + # macOS + STORAGE_DIR="$HOME_DIR/Library/Application Support/$STORAGE_FOLDER_NAME" +elif [[ "$OS" == *"linux"* ]]; then + # Linux / Unix + STORAGE_DIR="$HOME_DIR/.local/share/$STORAGE_FOLDER_NAME" +elif [[ "$OS" == *"mingw"* || "$OS" == *"cygwin"* || "$OS" == *"msys"* ]]; then + # Windows (Git Bash, Cygwin, MSYS) + if [[ -n "$APPDATA" ]]; then + STORAGE_DIR="$APPDATA/$STORAGE_FOLDER_NAME" + else + STORAGE_DIR="$HOME_DIR/$STORAGE_FOLDER_NAME" + fi +else + echo "Unsupported OS: $OS" + exit 1 +fi + +STORAGE_PATH="$STORAGE_DIR/$STORAGE_FILE" + +if [[ -f "$STORAGE_PATH" ]]; then + echo "Deleting storage at $STORAGE_PATH ..." + rm "$STORAGE_PATH" + echo "Storage deleted." +else + echo "Storage not found at $STORAGE_PATH" +fi +