mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-19 00:56:57 -04:00
Fix[log]: Unmovable file
This commit is contained in:
@@ -55,7 +55,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_java_gui_launcher);
|
||||
|
||||
Logger.begin(new File(Tools.DIR_GAME_HOME, "latestlog.txt").getAbsolutePath());
|
||||
Logger.beginLog(new File(Tools.DIR_GAME_HOME, "latestlog.txt"));
|
||||
mTouchCharInput = findViewById(R.id.awt_touch_char);
|
||||
mTouchCharInput.setCharacterSender(new AwtCharSender());
|
||||
|
||||
|
||||
@@ -2,23 +2,47 @@ package net.kdt.pojavlaunch;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/** Singleton class made to log on one file
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Singleton class made to log on one file
|
||||
* The singleton part can be removed but will require more implementation from the end-dev
|
||||
*/
|
||||
@Keep
|
||||
public class Logger {
|
||||
/** Print the text to the log file if not censored */
|
||||
/**
|
||||
* Print the text to the log file if not censored
|
||||
*/
|
||||
public static native void appendToLog(String text);
|
||||
|
||||
public static void beginLog(File logFile) {
|
||||
try {
|
||||
if (logFile.exists())
|
||||
logFile.delete();
|
||||
|
||||
/** Reset the log file, effectively erasing any previous logs */
|
||||
logFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Logger.begin(logFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the log file, effectively erasing any previous logs
|
||||
*/
|
||||
public static native void begin(String logFilePath);
|
||||
|
||||
/** Small listener for anything listening to the log */
|
||||
/**
|
||||
* Link a log listener to the logger
|
||||
*/
|
||||
public static native void setLogListener(eventLogListener logListener);
|
||||
|
||||
/**
|
||||
* Small listener for anything listening to the log
|
||||
*/
|
||||
public interface eventLogListener {
|
||||
void onEventLogged(String text);
|
||||
}
|
||||
|
||||
/** Link a log listener to the logger */
|
||||
public static native void setLogListener(eventLogListener logListener);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
|
||||
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||
|
||||
try {
|
||||
Logger.begin(new File(Tools.DIR_GAME_HOME, "latestlog.txt").getAbsolutePath());
|
||||
Logger.beginLog(new File(Tools.DIR_GAME_HOME, "latestlog.txt"));
|
||||
// FIXME: is it safe for multi thread?
|
||||
GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
touchCharInput.setCharacterSender(new LwjglCharSender());
|
||||
|
||||
@@ -84,9 +84,9 @@ Java_net_kdt_pojavlaunch_Logger_begin(JNIEnv *env, __attribute((unused)) jclass
|
||||
dup2(pfd[1], 2);
|
||||
|
||||
/* open latestlog.txt for writing */
|
||||
const char* logFilePath = (*env)->GetStringUTFChars(env, logPath, NULL);
|
||||
latestlog_fd = open(logFilePath, O_WRONLY | O_TRUNC | O_CREAT, 644);
|
||||
if(latestlog_fd == -1) {
|
||||
const char *logFilePath = (*env)->GetStringUTFChars(env, logPath, NULL);
|
||||
latestlog_fd = open(logFilePath, O_WRONLY | O_APPEND, 644);
|
||||
if (latestlog_fd == -1) {
|
||||
latestlog_fd = 0;
|
||||
(*env)->ThrowNew(env, ioeClass, strerror(errno));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user