Skip to content

Commit

Permalink
add fallback impementation
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Dec 27, 2022
1 parent 49804a2 commit 670b6ef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Smdn.Text.Ondulish/Smdn.Text.Ondulish/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ private static string GetMeCabDefaultTaggerArgs(string baseDirectory)
return $"-r {pathToMeCabResourceFile} -d {pathToMeCabDictionaryDirectory}";
}

private static string? GetProcessDirectory()
#if SYSTEM_ENVIRONMENT_PROCESSPATH
=> System.IO.Path.GetDirectoryName(Environment.ProcessPath);
#else
=> System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
#endif

public Translator()
: this(processDirectory: System.IO.Path.GetDirectoryName(Environment.ProcessPath) ?? string.Empty /* fallback: use relative path from current directory */)
: this(processDirectory: GetProcessDirectory() ?? string.Empty /* fallback: use relative path from current directory */)
{
}

Expand Down

0 comments on commit 670b6ef

Please sign in to comment.