Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Path separator issue and StringUtils optimization #9

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BSLegacyUtil/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private static void BeginInput() {

Process.Start(new ProcessStartInfo {
WorkingDirectory = bsDir,
FileName = $"{bsDir}{Path.PathSeparator}IPA.exe"
FileName = $"{bsDir}{Path.DirectorySeparatorChar}IPA.exe"
});

if (!isOldSelected) {
Expand Down Expand Up @@ -241,7 +241,7 @@ private static void BeginInput() {
private static void PlayGame(bool oculus = false) {
var p = new Process();
var temp = Path.Combine(Vars.BaseDirectory, "Installed Versions", $"Beat Saber {LocalJsonModel.TheConfig!.RememberedVersion}");
p.StartInfo = new ProcessStartInfo($"{temp}{Path.PathSeparator}Beat Saber.exe", oculus ? "-vrmode oculus" : "") {
p.StartInfo = new ProcessStartInfo($"{temp}{Path.DirectorySeparatorChar}Beat Saber.exe", oculus ? "-vrmode oculus" : "") {
UseShellExecute = false,
WorkingDirectory = temp
};
Expand Down
9 changes: 2 additions & 7 deletions BSLegacyUtil/Utils/StringUtils.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
namespace BSLegacyUtil.Utils;

public static class StringUtils {
public static bool ContainsMultiple(this string str1, string str2, string str3) => str1.Contains(str2) || str1.Contains(str3);
public static bool ContainsMultiple(this string str1, string str2, string str3, string str4) => str1.Contains(str2) || str1.Contains(str3) || str1.Contains(str4);
public static bool ContainsMultiple(this string str1, string str2, string str3, string str4, string str5) => str1.Contains(str2) || str1.Contains(str3) || str1.Contains(str4) || str1.Contains(str5);

public static bool EqualsMultiple(this string str1, string str2, string str3) => str1.Equals(str2) || str1.Equals(str3);
public static bool EqualsMultiple(this string str1, string str2, string str3, string str4) => str1.Equals(str2) || str1.Equals(str3) || str1.Equals(str4);
public static bool EqualsMultiple(this string str1, string str2, string str3, string str4, string str5) => str1.Equals(str2) || str1.Equals(str3) || str1.Equals(str4) || str1.Equals(str5);
public static bool ContainsMultiple(this string str1, params string[] strs) => strs.Any(str1.Contains);
public static bool EqualsMultiple(this string str1, params string[] strs) => strs.Any(str1.Equals);

public static string ReplaceAll(this string theStringToBeEdited, string oldCharacters, string newCharacters) // Idea from Java String.ReplaceAll()
=> oldCharacters.ToCharArray().Aggregate(theStringToBeEdited, (current, c) => current.Replace($"{c}", newCharacters));
Expand Down
2 changes: 1 addition & 1 deletion BSLegacyUtil/Vars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class Vars {
#else
public static bool IsDebug { get; set; }
#endif
public static string BaseDirectory { get; internal set; } = IsWindows ? Environment.CurrentDirectory + Path.PathSeparator : AppDomain.CurrentDomain.BaseDirectory;
public static string BaseDirectory { get; internal set; } = IsWindows ? Environment.CurrentDirectory + Path.DirectorySeparatorChar : AppDomain.CurrentDomain.BaseDirectory;

/*===============================================*/
public static string SteamPassword { get; internal set; } = "";
Expand Down