Skip to content

Commit 6013d73

Browse files
Check on installing/setting route in OR progranm directory one piece of code
1 parent de10375 commit 6013d73

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Source/Menu/DownloadContentForm.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,7 @@ private async void DownloadContentButton_Click(object sender, EventArgs e)
204204
string topPathDirectoryExe = determineTopDirectory(pathDirectoryExe.Substring(6));
205205
string topInstallPath = determineTopDirectory(installPath);
206206

207-
if (topPathDirectoryExe.Equals(topInstallPath, StringComparison.OrdinalIgnoreCase))
208-
{
209-
message = Catalog.GetStringFmt("Top directory {0} is the same for exe and route, installing in this directory not allowed", topInstallPath);
210-
MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.OK, MessageBoxIcon.Error);
207+
if (OptionsForm.isWrongPath(installPath, Catalog)) {
211208
// cancelled
212209
EnableButtons();
213210
return;

Source/Menu/Options.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -728,14 +728,8 @@ private void textBoxContentName_TextChanged(object sender, EventArgs e)
728728
var current = bindingSourceContent.Current as ContentFolder;
729729
if (current != null && current.Name != textBoxContentName.Text)
730730
{
731-
if (current.Path.ToLower().Contains(Application.StartupPath.ToLower()))
731+
if (isWrongPath(current.Path, catalog))
732732
{
733-
// Block added because a succesful Update operation will empty the Open Rails folder and lose any content stored within it.
734-
MessageBox.Show(catalog.GetString
735-
($"Cannot use content from any folder which lies inside the Open Rails folder {Application.StartupPath}\n\n")
736-
, "Invalid content location"
737-
, MessageBoxButtons.OK
738-
, MessageBoxIcon.Error);
739733
DeleteContent();
740734
return;
741735
}
@@ -792,6 +786,22 @@ private void checkPerformanceTuner_Click(object sender, EventArgs e)
792786
labelPerformanceTunerTarget.Enabled = checkPerformanceTuner.Checked;
793787
}
794788

789+
public static bool isWrongPath(string path, GettextResourceManager catalog)
790+
{
791+
if (path.ToLower().Contains(Application.StartupPath.ToLower()))
792+
{
793+
// check added because a succesful Update operation will empty the Open Rails folder and lose any content stored within it.
794+
MessageBox.Show(catalog.GetString
795+
($"Cannot use content from any folder which lies inside the Open Rails program folder {Application.StartupPath}\n\n")
796+
, "Invalid content location"
797+
, MessageBoxButtons.OK
798+
, MessageBoxIcon.Error);
799+
return true;
800+
}
801+
802+
return false;
803+
}
804+
795805
#region Help for Options
796806
// The icons all share the same code which assumes they are named according to a simple scheme as follows:
797807
// 1. To add a new Help Icon, copy an existing one and paste it onto the tab.

0 commit comments

Comments
 (0)