X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/d1481392271fd44b04c384a3dd56f3386edadfb3..84b2ee7ee3b47f01471691fa8b85d9e0bebf2c60:/LinuxGUI/Ventoy2Disk/QT/main.cpp diff --git a/LinuxGUI/Ventoy2Disk/QT/main.cpp b/LinuxGUI/Ventoy2Disk/QT/main.cpp index 37f47d4..60e6281 100644 --- a/LinuxGUI/Ventoy2Disk/QT/main.cpp +++ b/LinuxGUI/Ventoy2Disk/QT/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ char g_ini_file[4096]; int main(int argc, char *argv[]) { int ret; + long long size; QApplication a(argc, argv); Ventoy2DiskWindow w; @@ -34,6 +36,21 @@ int main(int argc, char *argv[]) } #endif + if (!QFileInfo::exists("./boot/boot.img")) + { + QString curdir = a.applicationDirPath(); + int index = curdir.indexOf("/tool/"); + + if (index >= 0) + { + QDir::setCurrent(curdir.left(index)); + } + else + { + QDir::setCurrent(curdir); + } + } + if (!QFileInfo::exists("./boot/boot.img")) { QMessageBox::critical(NULL, "Error", "Please run under the correct directory."); @@ -56,9 +73,18 @@ int main(int argc, char *argv[]) } } + QFileInfo Info(g_log_file); + size = (long long)Info.size(); + if (size >= 4 * SIZE_1MB) + { + QFile::remove(g_log_file); + } + vlog("===================================================\n"); vlog("===== Ventoy2Disk %s powered by QT %s =====\n", ventoy_get_local_version(), qVersion()); vlog("===================================================\n"); + vlog("log file is <%s> lastsize:%lld\n", g_log_file, (long long)size); + vlog("ini file is <%s>\n", g_ini_file); ventoy_disk_init(); ventoy_http_init();