Skip to content

Commit

Permalink
Sa v e
Browse files Browse the repository at this point in the history
  • Loading branch information
reitowo committed Oct 19, 2023
1 parent 7a3030b commit 20fd826
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 1 addition & 13 deletions Updator.Downloader.UI/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,7 @@ public static class App {
public static string AppLocalDataFolder =>
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Reito", "Updator");

static App() {
if (OperatingSystem.IsMacOS()) {
var pwd = Process.GetCurrentProcess().MainModule?.FileName;
if (!string.IsNullOrWhiteSpace(pwd)) {
var match = ".app/Contents/MacOS";
if (pwd.Contains(match)) {
pwd = pwd[..pwd.IndexOf(match, StringComparison.Ordinal)];
pwd = pwd[..pwd.LastIndexOf('/')];
Environment.CurrentDirectory = pwd;
}
}
}

static App() {
Directory.CreateDirectory(AppLocalDataFolder);
LogFactory = LoggerFactory.Create(builder => {
builder.AddSimpleConsole(o => {
Expand Down
13 changes: 13 additions & 0 deletions Updator.Downloader.UI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ public static void Main(string[] args) {

App.AppLog.LogInformation($"启动器 {Meta.RuntimeString} {Meta.RuntimeVersion}");
App.AppLog.LogInformation($"工作目录 {Environment.CurrentDirectory}");

if (OperatingSystem.IsMacOS()) {
var pwd = Process.GetCurrentProcess().MainModule?.FileName;
if (!string.IsNullOrWhiteSpace(pwd)) {
var match = ".app/Contents/MacOS";
if (pwd.Contains(match)) {
pwd = pwd[..pwd.IndexOf(match, StringComparison.Ordinal)];
pwd = pwd[..pwd.LastIndexOf('/')];
Environment.CurrentDirectory = pwd;
App.AppLog.LogInformation($"改变工作目录 {Environment.CurrentDirectory}");
}
}
}

var parsed = new Parser(a => {
a.AllowMultiInstance = true;
Expand Down

0 comments on commit 20fd826

Please sign in to comment.