Path.Join()

This commit is contained in:
Natsumi
2025-01-25 12:00:59 +13:00
parent ebb222e7bf
commit 5214522789
26 changed files with 91 additions and 91 deletions
+2 -2
View File
@@ -116,7 +116,7 @@ namespace VRCX
{
StartInfo = new ProcessStartInfo
{
FileName = Path.Combine(Program.BaseDirectory, "VRCX.exe"),
FileName = Path.Join(Program.BaseDirectory, "VRCX.exe"),
Arguments = string.Join(' ', args),
UseShellExecute = true,
WorkingDirectory = Program.BaseDirectory
@@ -128,7 +128,7 @@ namespace VRCX
public override bool CheckForUpdateExe()
{
return File.Exists(Path.Combine(Program.AppDataDirectory, "update.exe"));
return File.Exists(Path.Join(Program.AppDataDirectory, "update.exe"));
}
public override void ExecuteAppFunction(string function, string json)
+1 -1
View File
@@ -75,7 +75,7 @@ namespace VRCX
public string CustomVrScriptPath()
{
var output = string.Empty;
var filePath = Path.Combine(Program.AppDataDirectory, "customvr.js");
var filePath = Path.Join(Program.AppDataDirectory, "customvr.js");
if (File.Exists(filePath))
output = filePath;
return output;
+6 -6
View File
@@ -35,7 +35,7 @@ namespace VRCX
}
}
return Path.Combine(GetVRChatAppDataLocation(), "Cache-WindowsPlayer");
return Path.Join(GetVRChatAppDataLocation(), "Cache-WindowsPlayer");
}
public override string GetVRChatPhotosLocation()
@@ -54,7 +54,7 @@ namespace VRCX
}
}
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat");
return Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat");
}
public override string GetUGCPhotoLocation(string path = "")
@@ -81,7 +81,7 @@ namespace VRCX
private string GetSteamUserdataPathFromRegistry()
{
string steamUserdataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Steam\userdata");
string steamUserdataPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Steam\userdata");
try
{
@@ -92,7 +92,7 @@ namespace VRCX
object o = key.GetValue("InstallPath");
if (o != null)
{
steamUserdataPath = Path.Combine(o.ToString(), @"userdata");
steamUserdataPath = Path.Join(o.ToString(), @"userdata");
}
}
}
@@ -117,7 +117,7 @@ namespace VRCX
var steamUserDirs = Directory.GetDirectories(steamUserdataPath);
foreach (var steamUserDir in steamUserDirs)
{
var screenshotDir = Path.Combine(steamUserDir, @"760\remote\438100\screenshots");
var screenshotDir = Path.Join(steamUserDir, @"760\remote\438100\screenshots");
if (!Directory.Exists(screenshotDir))
continue;
@@ -184,7 +184,7 @@ namespace VRCX
public override bool OpenCrashVrcCrashDumps()
{
var path = Path.Combine(Path.GetTempPath(), "VRChat", "VRChat", "Crashes");
var path = Path.Join(Path.GetTempPath(), "VRChat", "VRChat", "Crashes");
if (!Directory.Exists(path))
return false;
+2 -2
View File
@@ -30,7 +30,7 @@ namespace VRCX
if (Wine.GetIfWine())
{
var wineTmpPath = Path.Combine(Program.AppDataDirectory, "wine.tmp");
var wineTmpPath = Path.Join(Program.AppDataDirectory, "wine.tmp");
if (File.Exists(wineTmpPath))
{
var wineTmp = File.ReadAllText(wineTmpPath);
@@ -122,7 +122,7 @@ namespace VRCX
public override bool StartGameFromPath(string path, string arguments)
{
if (!path.EndsWith(".exe"))
path = Path.Combine(path, "launch.exe");
path = Path.Join(path, "launch.exe");
if (!path.EndsWith("launch.exe") || !File.Exists(path))
return false;
+1 -1
View File
@@ -28,7 +28,7 @@ namespace VRCX
if (changeFilename)
{
var newFileName = $"{fileName}_{worldId}";
var newPath = Path.Combine(Path.GetDirectoryName(path), newFileName + Path.GetExtension(path));
var newPath = Path.Join(Path.GetDirectoryName(path), newFileName + Path.GetExtension(path));
File.Move(path, newPath);
path = newPath;
}
+2 -2
View File
@@ -83,7 +83,7 @@ namespace VRCX
public string CustomCssPath()
{
var output = string.Empty;
var filePath = Path.Combine(Program.AppDataDirectory, "custom.css");
var filePath = Path.Join(Program.AppDataDirectory, "custom.css");
if (File.Exists(filePath))
output = filePath;
return output;
@@ -92,7 +92,7 @@ namespace VRCX
public string CustomScriptPath()
{
var output = string.Empty;
var filePath = Path.Combine(Program.AppDataDirectory, "custom.js");
var filePath = Path.Join(Program.AppDataDirectory, "custom.js");
if (File.Exists(filePath))
output = filePath;
return output;
+5 -5
View File
@@ -171,7 +171,7 @@ namespace VRCX
public async Task CropAllPrints(string ugcFolderPath)
{
var folder = Path.Combine(GetUGCPhotoLocation(ugcFolderPath), "Prints");
var folder = Path.Join(GetUGCPhotoLocation(ugcFolderPath), "Prints");
var files = Directory.GetFiles(folder, "*.png", SearchOption.AllDirectories);
foreach (var file in files)
{
@@ -210,9 +210,9 @@ namespace VRCX
public async Task<string> SavePrintToFile(string url, string ugcFolderPath, string monthFolder, string fileName)
{
var folder = Path.Combine(GetUGCPhotoLocation(ugcFolderPath), "Prints", MakeValidFileName(monthFolder));
var folder = Path.Join(GetUGCPhotoLocation(ugcFolderPath), "Prints", MakeValidFileName(monthFolder));
Directory.CreateDirectory(folder);
var filePath = Path.Combine(folder, MakeValidFileName(fileName));
var filePath = Path.Join(folder, MakeValidFileName(fileName));
if (File.Exists(filePath))
return null;
@@ -223,9 +223,9 @@ namespace VRCX
public async Task<string> SaveStickerToFile(string url, string ugcFolderPath, string monthFolder, string fileName)
{
var folder = Path.Combine(GetUGCPhotoLocation(ugcFolderPath), "Stickers", MakeValidFileName(monthFolder));
var folder = Path.Join(GetUGCPhotoLocation(ugcFolderPath), "Stickers", MakeValidFileName(monthFolder));
Directory.CreateDirectory(folder);
var filePath = Path.Combine(folder, MakeValidFileName(fileName));
var filePath = Path.Join(folder, MakeValidFileName(fileName));
if (File.Exists(filePath))
return null;
@@ -12,7 +12,7 @@ namespace VRCX
{
// 004 = hideAvatar
// 005 = showAvatar
var filePath = Path.Combine(GetVRChatAppDataLocation(), @$"LocalPlayerModerations\{currentUserId}-show-hide-user.vrcset");
var filePath = Path.Join(GetVRChatAppDataLocation(), @$"LocalPlayerModerations\{currentUserId}-show-hide-user.vrcset");
if (!File.Exists(filePath))
return null;
@@ -35,7 +35,7 @@ namespace VRCX
public short GetVRChatUserModeration(string currentUserId, string userId)
{
var filePath = Path.Combine(GetVRChatAppDataLocation(), @$"LocalPlayerModerations\{currentUserId}-show-hide-user.vrcset");
var filePath = Path.Join(GetVRChatAppDataLocation(), @$"LocalPlayerModerations\{currentUserId}-show-hide-user.vrcset");
if (!File.Exists(filePath))
return 0;
@@ -58,7 +58,7 @@ namespace VRCX
public bool SetVRChatUserModeration(string currentUserId, string userId, int type)
{
var filePath = Path.Combine(GetVRChatAppDataLocation(), @$"LocalPlayerModerations\{currentUserId}-show-hide-user.vrcset");
var filePath = Path.Join(GetVRChatAppDataLocation(), @$"LocalPlayerModerations\{currentUserId}-show-hide-user.vrcset");
if (!File.Exists(filePath))
return false;
+2 -2
View File
@@ -8,7 +8,7 @@ namespace VRCX
public string ReadConfigFile()
{
var path = GetVRChatAppDataLocation();
var configFile = Path.Combine(path, "config.json");
var configFile = Path.Join(path, "config.json");
if (!Directory.Exists(path) || !File.Exists(configFile))
{
return string.Empty;
@@ -21,7 +21,7 @@ namespace VRCX
public void WriteConfigFile(string json)
{
var path = GetVRChatAppDataLocation();
var configFile = Path.Combine(path, "config.json");
var configFile = Path.Join(path, "config.json");
File.WriteAllText(configFile, json);
}
}
+9 -9
View File
@@ -24,16 +24,16 @@ namespace VRCX
{
const string vrchatAppid = "438100";
_homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
_steamPath = Path.Combine(_homeDirectory, ".local/share/Steam");
var flatpakSteamPath = Path.Combine(_homeDirectory, ".var/app/com.valvesoftware.Steam/.local/share/Steam");
_steamPath = Path.Join(_homeDirectory, ".local/share/Steam");
var flatpakSteamPath = Path.Join(_homeDirectory, ".var/app/com.valvesoftware.Steam/.local/share/Steam");
if (!Directory.Exists(_steamPath) && Directory.Exists(flatpakSteamPath))
{
logger.Info("Flatpak Steam detected.");
_steamPath = flatpakSteamPath;
}
_steamUserdataPath = Path.Combine(_homeDirectory, ".steam/steam/userdata");
_steamUserdataPath = Path.Join(_homeDirectory, ".steam/steam/userdata");
var libraryFoldersVdfPath = Path.Combine(_steamPath, "config/libraryfolders.vdf");
var libraryFoldersVdfPath = Path.Join(_steamPath, "config/libraryfolders.vdf");
var vrcLibraryPath = GetLibraryWithAppId(libraryFoldersVdfPath, vrchatAppid);
if (string.IsNullOrEmpty(vrcLibraryPath))
{
@@ -41,8 +41,8 @@ namespace VRCX
vrcLibraryPath = _steamPath;
}
logger.Info($"Using steam library path {vrcLibraryPath}");
_vrcPrefixPath = Path.Combine(vrcLibraryPath, $"steamapps/compatdata/{vrchatAppid}/pfx");
_vrcAppDataPath = Path.Combine(_vrcPrefixPath, "drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat");
_vrcPrefixPath = Path.Join(vrcLibraryPath, $"steamapps/compatdata/{vrchatAppid}/pfx");
_vrcAppDataPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat");
}
private static string? GetLibraryWithAppId(string libraryFoldersVdfPath, string appId)
@@ -91,12 +91,12 @@ namespace VRCX
}
}
return Path.Combine(GetVRChatAppDataLocation(), "Cache-WindowsPlayer");
return Path.Join(GetVRChatAppDataLocation(), "Cache-WindowsPlayer");
}
public override string GetVRChatPhotosLocation()
{
return Path.Combine(_vrcPrefixPath, "drive_c/users/steamuser/Pictures/VRChat");
return Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/Pictures/VRChat");
}
public override string GetUGCPhotoLocation(string path = "")
@@ -138,7 +138,7 @@ namespace VRCX
public override string GetVRChatScreenshotsLocation()
{
// program files steam userdata screenshots
return Path.Combine(_steamUserdataPath, "760/remote/438100/screenshots");
return Path.Join(_steamUserdataPath, "760/remote/438100/screenshots");
}
public override bool OpenVrcxAppDataFolder()
+2 -2
View File
@@ -79,7 +79,7 @@ namespace VRCX
return false;
}
var steamExecutable = Path.Combine(steamPath, "steam.sh");
var steamExecutable = Path.Join(steamPath, "steam.sh");
if (!File.Exists(steamExecutable))
{
logger.Error("Steam executable not found.");
@@ -105,7 +105,7 @@ namespace VRCX
public override bool StartGameFromPath(string path, string arguments)
{
if (!path.EndsWith(".exe"))
path = Path.Combine(path, "launch.exe");
path = Path.Join(path, "launch.exe");
if (!path.EndsWith("launch.exe") || !File.Exists(path))
return false;
@@ -85,7 +85,7 @@ namespace VRCX
private static string GetSteamVdfCompatTool()
{
string steamPath = _steamPath;
string configVdfPath = Path.Combine(steamPath, "config", "config.vdf");
string configVdfPath = Path.Join(steamPath, "config", "config.vdf");
if (!File.Exists(configVdfPath))
{
logger.Error("config.vdf not found");
@@ -240,14 +240,14 @@ namespace VRCX
}
string steamPath = _steamPath;
string steamAppsCommonPath = Path.Combine(steamPath, "steamapps", "common");
string compatabilityToolsPath = Path.Combine(steamPath, "compatibilitytools.d");
string protonPath = Path.Combine(steamAppsCommonPath, compatTool);
string compatToolPath = Path.Combine(compatabilityToolsPath, compatTool);
string steamAppsCommonPath = Path.Join(steamPath, "steamapps", "common");
string compatabilityToolsPath = Path.Join(steamPath, "compatibilitytools.d");
string protonPath = Path.Join(steamAppsCommonPath, compatTool);
string compatToolPath = Path.Join(compatabilityToolsPath, compatTool);
string winePath = "";
if (Directory.Exists(compatToolPath))
{
winePath = Path.Combine(compatToolPath, "files", "bin", "wine");
winePath = Path.Join(compatToolPath, "files", "bin", "wine");
if (!File.Exists(winePath))
{
Console.WriteLine("Wine not found in CompatTool path");
@@ -256,7 +256,7 @@ namespace VRCX
}
else if (Directory.Exists(protonPath))
{
winePath = Path.Combine(protonPath, "dist", "bin", "wine");
winePath = Path.Join(protonPath, "dist", "bin", "wine");
if (!File.Exists(winePath))
{
logger.Error("Wine not found in Proton path");
@@ -270,7 +270,7 @@ namespace VRCX
{
if (dir.Contains(compatTool))
{
winePath = Path.Combine(dir, "files", "bin", "wine");
winePath = Path.Join(dir, "files", "bin", "wine");
if (File.Exists(winePath))
{
break;
@@ -338,7 +338,7 @@ namespace VRCX
private string GetWineRegCommandEx(string regCommand)
{
string winePrefix = _vrcPrefixPath;
string filePath = Path.Combine(winePrefix, "user.reg");
string filePath = Path.Join(winePrefix, "user.reg");
if (!File.Exists(filePath))
throw new FileNotFoundException($"Registry file not found at {filePath}");
+2 -2
View File
@@ -16,7 +16,7 @@ namespace VRCX
{
var winePrefix = Path.Join(_vrcPrefixPath, "drive_c");
var winePath = path.Substring(3).Replace("\\", "/");
path = Path.Combine(winePrefix, winePath);
path = Path.Join(winePrefix, winePath);
var fileName = Path.GetFileNameWithoutExtension(path);
if (!File.Exists(path) || !path.EndsWith(".png") || !fileName.StartsWith("VRChat_"))
@@ -25,7 +25,7 @@ namespace VRCX
if (changeFilename)
{
var newFileName = $"{fileName}_{worldId}";
var newPath = Path.Combine(Path.GetDirectoryName(path), newFileName + Path.GetExtension(path));
var newPath = Path.Join(Path.GetDirectoryName(path), newFileName + Path.GetExtension(path));
File.Move(path, newPath);
path = newPath;
}