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

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)

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;

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;

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;

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;
}

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;

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;

View File

@@ -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;

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);
}
}

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()

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;

View File

@@ -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}");

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;
}

View File

@@ -102,16 +102,16 @@ namespace VRCX
{
var cachePath = GetVRChatCacheLocation();
var idHash = GetAssetId(id, variant);
var topDir = Path.Combine(cachePath, idHash);
var topDir = Path.Join(cachePath, idHash);
var versionLocation = GetAssetVersion(version, variantVersion);
if (!Directory.Exists(topDir))
return Path.Combine(topDir, versionLocation);
return Path.Join(topDir, versionLocation);
var versionSearchPattern = string.Concat("*", versionLocation.AsSpan(8));
var dirs = Directory.GetDirectories(topDir, versionSearchPattern);
if (dirs.Length > 0)
return dirs.OrderByDescending(dir => ReverseHexToDecimal(Path.GetFileName(dir)).Item2).First();
return Path.Combine(topDir, versionLocation);
return Path.Join(topDir, versionLocation);
}
/// <summary>
@@ -130,7 +130,7 @@ namespace VRCX
if (!Directory.Exists(fullLocation))
fullLocation = GetVRChatCacheFullLocation(id, version, variant, variantVersion);
var fileLocation = Path.Combine(fullLocation, "__data");
var fileLocation = Path.Join(fullLocation, "__data");
var cachePath = string.Empty;
if (File.Exists(fileLocation))
{
@@ -138,7 +138,7 @@ namespace VRCX
FileInfo data = new FileInfo(fileLocation);
fileSize = data.Length;
}
if (File.Exists(Path.Combine(fullLocation, "__lock")))
if (File.Exists(Path.Join(fullLocation, "__lock")))
{
isLocked = true;
}
@@ -204,7 +204,7 @@ namespace VRCX
if (index == versionDirectories.Length - 1)
continue; // skip last version
if (File.Exists(Path.Combine(versionDirectory.FullName, "__lock")))
if (File.Exists(Path.Join(versionDirectory.FullName, "__lock")))
continue; // skip locked version
versionDirectory.Delete(true);

View File

@@ -64,7 +64,7 @@ namespace VRCX
public AutoAppLaunchManager()
{
AppShortcutDirectory = Path.Combine(Program.AppDataDirectory, "startup");
AppShortcutDirectory = Path.Join(Program.AppDataDirectory, "startup");
if (!Directory.Exists(AppShortcutDirectory))
{

View File

@@ -19,11 +19,11 @@ namespace VRCX
internal void Init()
{
var userDataDir = Path.Combine(Program.AppDataDirectory, "userdata");
var userDataDir = Path.Join(Program.AppDataDirectory, "userdata");
var cefSettings = new CefSettings
{
RootCachePath = userDataDir,
CachePath = Path.Combine(userDataDir, "cache"),
CachePath = Path.Join(userDataDir, "cache"),
LogSeverity = LogSeverity.Disable,
WindowlessRenderingEnabled = true,
PersistSessionCookies = true,
@@ -37,7 +37,7 @@ namespace VRCX
SchemeName = "file",
DomainName = "vrcx",
SchemeHandlerFactory = new FolderSchemeHandlerFactory(
Path.Combine(Program.BaseDirectory, "html"),
Path.Join(Program.BaseDirectory, "html"),
"file",
defaultPage: "index.html"
),

View File

@@ -31,10 +31,10 @@ public class BrowserSubprocess
return;
}
var browserSubprocessDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CefSharp.BrowserSubprocess.Core.dll");
var browserSubprocessDllPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "CefSharp.BrowserSubprocess.Core.dll");
if (!File.Exists(browserSubprocessDllPath))
{
browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll");
browserSubprocessDllPath = Path.Join(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll");
}
var browserSubprocessDll = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(browserSubprocessDllPath);
var browserSubprocessExecutableType = browserSubprocessDll.GetType("CefSharp.BrowserSubprocess.BrowserSubprocessExecutable");

View File

@@ -22,7 +22,7 @@ internal static class ImageCache
static ImageCache()
{
cacheLocation = Path.Combine(Program.AppDataDirectory, "ImageCache");
cacheLocation = Path.Join(Program.AppDataDirectory, "ImageCache");
var httpClientHandler = new HttpClientHandler();
if (WebApi.ProxySet)
httpClientHandler.Proxy = WebApi.Proxy;
@@ -33,8 +33,8 @@ internal static class ImageCache
public static async Task<string> GetImage(string url, string fileId, string version)
{
var directoryLocation = Path.Combine(cacheLocation, fileId);
var fileLocation = Path.Combine(directoryLocation, $"{version}.png");
var directoryLocation = Path.Join(cacheLocation, fileId);
var fileLocation = Path.Join(directoryLocation, $"{version}.png");
if (File.Exists(fileLocation))
{

View File

@@ -561,7 +561,7 @@ namespace VRCX
return err;
}
var iconPath = Path.Combine(Program.BaseDirectory, "VRCX.png");
var iconPath = Path.Join(Program.BaseDirectory, "VRCX.png");
err = overlay.SetOverlayFromFile(thumbnailHandle, iconPath);
if (err != EVROverlayError.None)
{

View File

@@ -489,7 +489,7 @@ namespace VRCX
return err;
}
var iconPath = Path.Combine(Program.BaseDirectory, "VRCX.png");
var iconPath = Path.Join(Program.BaseDirectory, "VRCX.png");
err = overlay.SetOverlayFromFile(thumbnailHandle, iconPath);
if (err != EVROverlayError.None)
{

View File

@@ -22,7 +22,7 @@ namespace VRCX
InitializeComponent();
_browser1 = new ChromiumWebBrowser(
Path.Combine(Program.BaseDirectory, "html/vr.html?1")
Path.Join(Program.BaseDirectory, "html/vr.html?1")
)
{
DragHandler = new CefNoopDragHandler(),
@@ -34,7 +34,7 @@ namespace VRCX
};
_browser2 = new ChromiumWebBrowser(
Path.Combine(Program.BaseDirectory, "html/vr.html?2")
Path.Join(Program.BaseDirectory, "html/vr.html?2")
)
{
DragHandler = new CefNoopDragHandler(),

View File

@@ -34,7 +34,7 @@ namespace VRCX
listener = new HttpListener();
listener.Prefixes.Add(WorldDBServerUrl);
worldDB = new WorldDatabase(Path.Combine(Program.AppDataDirectory, "VRCX-WorldData.db"));
worldDB = new WorldDatabase(Path.Join(Program.AppDataDirectory, "VRCX-WorldData.db"));
}
public void Init()

View File

@@ -30,39 +30,39 @@ namespace VRCX
private static void SetProgramDirectories()
{
if (string.IsNullOrEmpty(AppDataDirectory))
AppDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
AppDataDirectory = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"VRCX");
BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
ConfigLocation = Path.Combine(AppDataDirectory, "VRCX.sqlite3");
ConfigLocation = Path.Join(AppDataDirectory, "VRCX.sqlite3");
if (!Directory.Exists(AppDataDirectory))
{
Directory.CreateDirectory(AppDataDirectory);
// Migrate config to AppData
if (File.Exists(Path.Combine(BaseDirectory, "VRCX.json")))
if (File.Exists(Path.Join(BaseDirectory, "VRCX.json")))
{
File.Move(Path.Combine(BaseDirectory, "VRCX.json"), Path.Combine(AppDataDirectory, "VRCX.json"));
File.Copy(Path.Combine(AppDataDirectory, "VRCX.json"),
Path.Combine(AppDataDirectory, "VRCX-backup.json"));
File.Move(Path.Join(BaseDirectory, "VRCX.json"), Path.Join(AppDataDirectory, "VRCX.json"));
File.Copy(Path.Join(AppDataDirectory, "VRCX.json"),
Path.Join(AppDataDirectory, "VRCX-backup.json"));
}
if (File.Exists(Path.Combine(BaseDirectory, "VRCX.sqlite3")))
if (File.Exists(Path.Join(BaseDirectory, "VRCX.sqlite3")))
{
File.Move(Path.Combine(BaseDirectory, "VRCX.sqlite3"),
Path.Combine(AppDataDirectory, "VRCX.sqlite3"));
File.Copy(Path.Combine(AppDataDirectory, "VRCX.sqlite3"),
Path.Combine(AppDataDirectory, "VRCX-backup.sqlite3"));
File.Move(Path.Join(BaseDirectory, "VRCX.sqlite3"),
Path.Join(AppDataDirectory, "VRCX.sqlite3"));
File.Copy(Path.Join(AppDataDirectory, "VRCX.sqlite3"),
Path.Join(AppDataDirectory, "VRCX-backup.sqlite3"));
}
}
// Migrate cache to userdata for Cef 115 update
var oldCachePath = Path.Combine(AppDataDirectory, "cache");
var newCachePath = Path.Combine(AppDataDirectory, "userdata", "cache");
var oldCachePath = Path.Join(AppDataDirectory, "cache");
var newCachePath = Path.Join(AppDataDirectory, "userdata", "cache");
if (Directory.Exists(oldCachePath) && !Directory.Exists(newCachePath))
{
Directory.CreateDirectory(Path.Combine(AppDataDirectory, "userdata"));
Directory.CreateDirectory(Path.Join(AppDataDirectory, "userdata"));
Directory.Move(oldCachePath, newCachePath);
}
}
@@ -73,7 +73,7 @@ namespace VRCX
try
{
Version = $"{buildName} {File.ReadAllText(Path.Combine(BaseDirectory, "Version"))}";
Version = $"{buildName} {File.ReadAllText(Path.Join(BaseDirectory, "Version"))}";
}
catch (Exception)
{
@@ -89,12 +89,12 @@ namespace VRCX
{
var fileTarget = new FileTarget("fileTarget")
{
FileName = Path.Combine(AppDataDirectory, "logs", "VRCX.log"),
FileName = Path.Join(AppDataDirectory, "logs", "VRCX.log"),
//Layout = "${longdate} [${level:uppercase=true}] ${logger} - ${message} ${exception:format=tostring}",
// Layout with padding between the level/logger and message so that the message always starts at the same column
Layout =
"${longdate} [${level:uppercase=true:padding=-5}] ${logger:padding=-20} - ${message} ${exception:format=tostring}",
ArchiveFileName = Path.Combine(AppDataDirectory, "logs", "VRCX.{#}.log"),
ArchiveFileName = Path.Join(AppDataDirectory, "logs", "VRCX.{#}.log"),
ArchiveNumbering = ArchiveNumberingMode.DateAndSequence,
ArchiveEvery = FileArchivePeriod.Day,
MaxArchiveFiles = 4,

View File

@@ -14,7 +14,7 @@ namespace VRCX
internal static class ScreenshotHelper
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly ScreenshotMetadataDatabase cacheDatabase = new ScreenshotMetadataDatabase(Path.Combine(Program.AppDataDirectory, "metadataCache.db"));
private static readonly ScreenshotMetadataDatabase cacheDatabase = new ScreenshotMetadataDatabase(Path.Join(Program.AppDataDirectory, "metadataCache.db"));
private static readonly Dictionary<string, ScreenshotMetadata> metadataCache = new Dictionary<string, ScreenshotMetadata>();
public enum ScreenshotSearchType

View File

@@ -23,10 +23,10 @@ namespace VRCX
public class Update
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly string VrcxSetupExecutable = Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe");
private static readonly string UpdateExecutable = Path.Combine(Program.AppDataDirectory, "update.exe");
private static readonly string TempDownload = Path.Combine(Program.AppDataDirectory, "tempDownload");
private static readonly string HashLocation = Path.Combine(Program.AppDataDirectory, "sha256sum.txt");
private static readonly string VrcxSetupExecutable = Path.Join(Program.AppDataDirectory, "VRCX_Setup.exe");
private static readonly string UpdateExecutable = Path.Join(Program.AppDataDirectory, "update.exe");
private static readonly string TempDownload = Path.Join(Program.AppDataDirectory, "tempDownload");
private static readonly string HashLocation = Path.Join(Program.AppDataDirectory, "sha256sum.txt");
private static readonly HttpClient httpClient;
private static CancellationToken _cancellationToken;
public static int UpdateProgress;
@@ -138,9 +138,9 @@ namespace VRCX
throw new Exception($"Failed to download the file. Status code: {response.StatusCode}");
var fileName = GetFileNameFromContentDisposition(response);
var tempPath = Path.Combine(Path.GetTempPath(), "VRCX");
var tempPath = Path.Join(Path.GetTempPath(), "VRCX");
Directory.CreateDirectory(tempPath);
var filePath = Path.Combine(tempPath, fileName);
var filePath = Path.Join(tempPath, fileName);
await using var fileStream = File.Create(filePath);
await response.Content.CopyToAsync(fileStream, cancellationToken);
return filePath;

View File

@@ -17,7 +17,7 @@ namespace VRCX
public static readonly VRCXStorage Instance;
private static readonly ReaderWriterLockSlim m_Lock = new ReaderWriterLockSlim();
private static Dictionary<string, string> m_Storage = new Dictionary<string, string>();
private static readonly string m_JsonPath = Path.Combine(Program.AppDataDirectory, "VRCX.json");
private static readonly string m_JsonPath = Path.Join(Program.AppDataDirectory, "VRCX.json");
private static bool m_Dirty;
static VRCXStorage()