Portable path changes
This commit is contained in:
parent
5ae67ad7ce
commit
cdf66aeb00
@ -67,7 +67,9 @@ Source: "{#AppParentDirectory}\hu\*.resources.dll"; DestDir: {app}\Languages\hu;
|
||||
Source: "{#AppParentDirectory}\ko-KR\*.resources.dll"; DestDir: {app}\Languages\ko-KR; Flags: ignoreversion
|
||||
Source: "{#AppParentDirectory}\nl-NL\*.resources.dll"; DestDir: {app}\Languages\nl-NL; Flags: ignoreversion
|
||||
Source: "{#AppParentDirectory}\pt-BR\*.resources.dll"; DestDir: {app}\Languages\pt-BR; Flags: ignoreversion
|
||||
Source: "{#AppParentDirectory}\ru\*.resources.dll"; DestDir: {app}\Languages\ru; Flags: ignoreversion
|
||||
Source: "{#AppParentDirectory}\tr\*.resources.dll"; DestDir: {app}\Languages\tr; Flags: ignoreversion
|
||||
Source: "{#AppParentDirectory}\vi-VN\*.resources.dll"; DestDir: {app}\Languages\vi-VN; Flags: ignoreversion
|
||||
Source: "{#AppParentDirectory}\zh-CN\*.resources.dll"; DestDir: {app}\Languages\zh-CN; Flags: ignoreversion
|
||||
|
||||
[Icons]
|
||||
|
@ -141,7 +141,7 @@ namespace ShareX.Setup
|
||||
CopyFile(Path.Combine(outputDir, "Recorder-devices-setup.exe"), destination);
|
||||
CopyFile(Path.Combine(chromeReleaseDir, "ShareX_Chrome.exe"), destination);
|
||||
|
||||
string[] languages = new string[] { "de", "es", "fr", "hu", "ko-KR", "nl-NL", "pt-BR", "tr", "zh-CN" };
|
||||
string[] languages = new string[] { "de", "es", "fr", "hu", "ko-KR", "nl-NL", "pt-BR", "ru", "tr", "vi-VN", "zh-CN" };
|
||||
|
||||
foreach (string language in languages)
|
||||
{
|
||||
@ -156,7 +156,7 @@ namespace ShareX.Setup
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllText(Path.Combine(destination, "PersonalPath.cfg"), "ShareX", Encoding.UTF8);
|
||||
File.Create(Path.Combine(destination, "Portable")).Dispose();
|
||||
|
||||
//FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(releaseDir, "ShareX.exe"));
|
||||
//string zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart);
|
||||
|
@ -249,7 +249,7 @@ namespace ShareX
|
||||
|
||||
if (string.IsNullOrEmpty(personalPath))
|
||||
{
|
||||
personalPath = Program.DefaultPersonalPath;
|
||||
personalPath = Program.DefaultPersonalFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -361,7 +361,7 @@ namespace ShareX
|
||||
|
||||
private void btnBrowsePersonalFolderPath_Click(object sender, EventArgs e)
|
||||
{
|
||||
Helpers.BrowseFolder(Resources.ApplicationSettingsForm_btnBrowsePersonalFolderPath_Click_Choose_ShareX_personal_folder_path, txtPersonalFolderPath, Program.PersonalPath);
|
||||
Helpers.BrowseFolder(Resources.ApplicationSettingsForm_btnBrowsePersonalFolderPath_Click_Choose_ShareX_personal_folder_path, txtPersonalFolderPath, Program.PersonalFolder);
|
||||
}
|
||||
|
||||
private void btnOpenPersonalFolder_Click(object sender, EventArgs e)
|
||||
@ -383,7 +383,7 @@ namespace ShareX
|
||||
|
||||
private void btnBrowseCustomScreenshotsPath_Click(object sender, EventArgs e)
|
||||
{
|
||||
Helpers.BrowseFolder(Resources.ApplicationSettingsForm_btnBrowseCustomScreenshotsPath_Click_Choose_screenshots_folder_path, txtCustomScreenshotsPath, Program.PersonalPath);
|
||||
Helpers.BrowseFolder(Resources.ApplicationSettingsForm_btnBrowseCustomScreenshotsPath_Click_Choose_screenshots_folder_path, txtCustomScreenshotsPath, Program.PersonalFolder);
|
||||
}
|
||||
|
||||
private void txtSaveImageSubFolderPattern_TextChanged(object sender, EventArgs e)
|
||||
|
@ -48,7 +48,7 @@ namespace ShareX
|
||||
{
|
||||
name = "com.getsharex.sharex",
|
||||
description = "ShareX",
|
||||
path = Program.ChromeHostPath,
|
||||
path = Program.ChromeHostFilePath,
|
||||
type = "stdio",
|
||||
allowed_origins = new string[] { "chrome-extension://nlkoigbdolhchiicbonbihbphgamnaoc/" }
|
||||
};
|
||||
@ -62,9 +62,9 @@ namespace ShareX
|
||||
{
|
||||
try
|
||||
{
|
||||
CreateChromeHostManifest(Program.ChromeHostManifestPath);
|
||||
CreateChromeHostManifest(Program.ChromeHostManifestFilePath);
|
||||
|
||||
RegistryHelpers.RegisterChromeSupport(Program.ChromeHostManifestPath);
|
||||
RegistryHelpers.RegisterChromeSupport(Program.ChromeHostManifestFilePath);
|
||||
|
||||
MessageBox.Show(Resources.ChromeForm_btnRegister_Click_Chrome_support_enabled_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
@ -78,9 +78,9 @@ namespace ShareX
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(Program.ChromeHostManifestPath))
|
||||
if (File.Exists(Program.ChromeHostManifestFilePath))
|
||||
{
|
||||
File.Delete(Program.ChromeHostManifestPath);
|
||||
File.Delete(Program.ChromeHostManifestFilePath);
|
||||
}
|
||||
|
||||
RegistryHelpers.UnregisterChromeSupport();
|
||||
|
@ -855,7 +855,7 @@ namespace ShareX
|
||||
|
||||
using (FFmpegOptionsForm form = new FFmpegOptionsForm(options))
|
||||
{
|
||||
form.DefaultToolsPath = Program.DefaultFFmpegPath;
|
||||
form.DefaultToolsPath = Program.DefaultFFmpegFilePath;
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ namespace ShareX
|
||||
|
||||
public static bool CheckSteamShowInApp()
|
||||
{
|
||||
return File.Exists(Program.SteamInAppPath);
|
||||
return File.Exists(Program.SteamInAppFilePath);
|
||||
}
|
||||
|
||||
public static void SteamShowInApp(bool showInApp)
|
||||
{
|
||||
string path = Program.SteamInAppPath;
|
||||
string path = Program.SteamInAppFilePath;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -98,25 +98,22 @@ namespace ShareX
|
||||
public static HotkeyManager HotkeyManager { get; set; }
|
||||
public static WatchFolderManager WatchFolderManager { get; set; }
|
||||
|
||||
#region Paths
|
||||
|
||||
public static readonly string StartupPath = Application.StartupPath;
|
||||
|
||||
public static readonly string DefaultPersonalPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ShareX");
|
||||
private static readonly string PortablePersonalPath = Path.Combine(StartupPath, "ShareX");
|
||||
private static readonly string PersonalPathConfig = Path.Combine(StartupPath, "PersonalPath.cfg");
|
||||
private static readonly string ApplicationConfigFilename = "ApplicationConfig.json";
|
||||
private static readonly string UploadersConfigFilename = "UploadersConfig.json";
|
||||
private static readonly string HotkeysConfigFilename = "HotkeysConfig.json";
|
||||
private static readonly string HistoryFilename = "History.xml";
|
||||
private static readonly string LogFileName = "ShareX-Log-{0:yyyy-MM}.txt";
|
||||
|
||||
public static string CustomPersonalPath { get; private set; }
|
||||
|
||||
private static bool restarting;
|
||||
private static FileSystemWatcher uploaderConfigWatcher;
|
||||
private static WatchFolderDuplicateEventTimer uploaderConfigWatcherTimer;
|
||||
|
||||
public static string PersonalPath
|
||||
#region Paths
|
||||
|
||||
public static readonly string DefaultPersonalFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ShareX");
|
||||
private static readonly string PortablePersonalFolder = Helpers.GetAbsolutePath("ShareX");
|
||||
private static readonly string PersonalPathConfigFilePath = Helpers.GetAbsolutePath("PersonalPath.cfg");
|
||||
private static readonly string PortableCheckFilePath = Helpers.GetAbsolutePath("Portable");
|
||||
public static readonly string ChromeHostFilePath = Helpers.GetAbsolutePath("ShareX_Chrome.exe");
|
||||
public static readonly string SteamInAppFilePath = Helpers.GetAbsolutePath("Steam");
|
||||
|
||||
private static string CustomPersonalPath { get; set; }
|
||||
|
||||
public static string PersonalFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -125,7 +122,7 @@ namespace ShareX
|
||||
return CustomPersonalPath;
|
||||
}
|
||||
|
||||
return DefaultPersonalPath;
|
||||
return DefaultPersonalFolder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,59 +132,55 @@ namespace ShareX
|
||||
{
|
||||
if (!IsSandbox)
|
||||
{
|
||||
return Path.Combine(PersonalPath, ApplicationConfigFilename);
|
||||
return Path.Combine(PersonalFolder, "ApplicationConfig.json");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static string UploadersConfigFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Settings != null && !string.IsNullOrEmpty(Settings.CustomUploadersConfigPath))
|
||||
{
|
||||
return Settings.CustomUploadersConfigPath;
|
||||
}
|
||||
|
||||
return PersonalPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static string UploadersConfigFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsSandbox)
|
||||
{
|
||||
return Path.Combine(UploadersConfigFolder, UploadersConfigFilename);
|
||||
string uploadersConfigFolder;
|
||||
|
||||
if (Settings != null && !string.IsNullOrEmpty(Settings.CustomUploadersConfigPath))
|
||||
{
|
||||
uploadersConfigFolder = Settings.CustomUploadersConfigPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
uploadersConfigFolder = PersonalFolder;
|
||||
}
|
||||
|
||||
return Path.Combine(uploadersConfigFolder, "UploadersConfig.json");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static string HotkeysConfigFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Settings != null && !string.IsNullOrEmpty(Settings.CustomHotkeysConfigPath))
|
||||
{
|
||||
return Settings.CustomHotkeysConfigPath;
|
||||
}
|
||||
|
||||
return PersonalPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static string HotkeysConfigFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsSandbox)
|
||||
{
|
||||
return Path.Combine(HotkeysConfigFolder, HotkeysConfigFilename);
|
||||
string hotkeysConfigFolder;
|
||||
|
||||
if (Settings != null && !string.IsNullOrEmpty(Settings.CustomHotkeysConfigPath))
|
||||
{
|
||||
hotkeysConfigFolder = Settings.CustomHotkeysConfigPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
hotkeysConfigFolder = PersonalFolder;
|
||||
}
|
||||
|
||||
return Path.Combine(hotkeysConfigFolder, "HotkeysConfig.json");
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -200,21 +193,20 @@ namespace ShareX
|
||||
{
|
||||
if (!IsSandbox)
|
||||
{
|
||||
return Path.Combine(PersonalPath, HistoryFilename);
|
||||
return Path.Combine(PersonalFolder, "History.xml");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static string LogsFolder => Path.Combine(PersonalPath, "Logs");
|
||||
|
||||
public static string LogsFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filename = string.Format(LogFileName, DateTime.Now);
|
||||
return Path.Combine(LogsFolder, filename);
|
||||
string logsFolder = Path.Combine(PersonalFolder, "Logs");
|
||||
string filename = string.Format("ShareX-Log-{0:yyyy-MM}.txt", DateTime.Now);
|
||||
return Path.Combine(logsFolder, filename);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,7 +219,7 @@ namespace ShareX
|
||||
return Environment.ExpandEnvironmentVariables(Settings.CustomScreenshotsPath);
|
||||
}
|
||||
|
||||
return Path.Combine(PersonalPath, "Screenshots");
|
||||
return Path.Combine(PersonalFolder, "Screenshots");
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,24 +232,14 @@ namespace ShareX
|
||||
}
|
||||
}
|
||||
|
||||
public static string ScreenRecorderCacheFilePath => Path.Combine(PersonalPath, "ScreenRecorder.avi");
|
||||
|
||||
private static string BackupFolder => Path.Combine(PersonalPath, "Backup");
|
||||
|
||||
public static string ToolsFolder => Path.Combine(PersonalPath, "Tools");
|
||||
|
||||
public static string DefaultFFmpegPath => Path.Combine(ToolsFolder, "ffmpeg.exe");
|
||||
|
||||
public static string ChromeHostManifestPath => Path.Combine(ToolsFolder, "Chrome-host-manifest.json");
|
||||
|
||||
public static string ChromeHostPath => Helpers.GetAbsolutePath("ShareX_Chrome.exe");
|
||||
|
||||
public static string SteamInAppPath => Helpers.GetAbsolutePath("Steam");
|
||||
private static string BackupFolder => Path.Combine(PersonalFolder, "Backup");
|
||||
private static string ToolsFolder => Path.Combine(PersonalFolder, "Tools");
|
||||
public static string ScreenRecorderCacheFilePath => Path.Combine(PersonalFolder, "ScreenRecorder.avi");
|
||||
public static string DefaultFFmpegFilePath => Path.Combine(ToolsFolder, "ffmpeg.exe");
|
||||
public static string ChromeHostManifestFilePath => Path.Combine(ToolsFolder, "Chrome-host-manifest.json");
|
||||
|
||||
#endregion Paths
|
||||
|
||||
private static bool restarting;
|
||||
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
@ -307,22 +289,23 @@ namespace ShareX
|
||||
|
||||
if (IsPortable)
|
||||
{
|
||||
CustomPersonalPath = PortablePersonalPath;
|
||||
CustomPersonalPath = PortablePersonalFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsPortable = File.Exists(PortableCheckFilePath);
|
||||
CheckPersonalPathConfig();
|
||||
}
|
||||
|
||||
if (!Directory.Exists(PersonalPath))
|
||||
if (!Directory.Exists(PersonalFolder))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(PersonalPath);
|
||||
Directory.CreateDirectory(PersonalFolder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(Resources.Program_Run_Unable_to_create_folder_ + string.Format(" \"{0}\"\r\n\r\n{1}", PersonalPath, e),
|
||||
MessageBox.Show(Resources.Program_Run_Unable_to_create_folder_ + string.Format(" \"{0}\"\r\n\r\n{1}", PersonalFolder, e),
|
||||
"ShareX - " + Resources.Program_Run_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
CustomPersonalPath = "";
|
||||
}
|
||||
@ -338,7 +321,7 @@ namespace ShareX
|
||||
DebugHelper.WriteLine(TitleLong);
|
||||
DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
|
||||
DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
|
||||
DebugHelper.WriteLine("Personal path: " + PersonalPath);
|
||||
DebugHelper.WriteLine("Personal path: " + PersonalFolder);
|
||||
|
||||
LoadProgramSettings();
|
||||
|
||||
@ -469,19 +452,18 @@ namespace ShareX
|
||||
{
|
||||
customPersonalPath = Environment.ExpandEnvironmentVariables(customPersonalPath);
|
||||
CustomPersonalPath = Helpers.GetAbsolutePath(customPersonalPath);
|
||||
|
||||
if (CustomPersonalPath.Equals(PortablePersonalPath, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
IsPortable = true;
|
||||
}
|
||||
}
|
||||
else if (IsPortable)
|
||||
{
|
||||
CustomPersonalPath = PortablePersonalFolder;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadPersonalPathConfig()
|
||||
{
|
||||
if (File.Exists(PersonalPathConfig))
|
||||
if (File.Exists(PersonalPathConfigFilePath))
|
||||
{
|
||||
return File.ReadAllText(PersonalPathConfig, Encoding.UTF8).Trim();
|
||||
return File.ReadAllText(PersonalPathConfigFilePath, Encoding.UTF8).Trim();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
@ -498,7 +480,7 @@ namespace ShareX
|
||||
path = path.Trim();
|
||||
}
|
||||
|
||||
bool isDefaultPath = string.IsNullOrEmpty(path) && !File.Exists(PersonalPathConfig);
|
||||
bool isDefaultPath = string.IsNullOrEmpty(path) && !File.Exists(PersonalPathConfigFilePath);
|
||||
|
||||
if (!isDefaultPath)
|
||||
{
|
||||
@ -508,11 +490,11 @@ namespace ShareX
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(PersonalPathConfig, path, Encoding.UTF8);
|
||||
File.WriteAllText(PersonalPathConfigFilePath, path, Encoding.UTF8);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
MessageBox.Show(string.Format(Resources.Program_WritePersonalPathConfig_Cant_access_to_file, PersonalPathConfig),
|
||||
MessageBox.Show(string.Format(Resources.Program_WritePersonalPathConfig_Cant_access_to_file, PersonalPathConfigFilePath),
|
||||
"ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ namespace ShareX
|
||||
|
||||
public static Image AnnotateImage(Image img, string imgPath)
|
||||
{
|
||||
return ImageHelpers.AnnotateImage(img, imgPath, !Program.IsSandbox, Program.PersonalPath,
|
||||
return ImageHelpers.AnnotateImage(img, imgPath, !Program.IsSandbox, Program.PersonalFolder,
|
||||
x => Program.MainForm.InvokeSafe(() => ClipboardHelpers.CopyImage(x)),
|
||||
x => Program.MainForm.InvokeSafe(() => UploadManager.UploadImage(x)),
|
||||
(x, filePath) => Program.MainForm.InvokeSafe(() => ImageHelpers.SaveImage(x, filePath)),
|
||||
@ -780,7 +780,7 @@ namespace ShareX
|
||||
|
||||
if (string.IsNullOrEmpty(ffmpegPath))
|
||||
{
|
||||
ffmpegPath = Program.DefaultFFmpegPath;
|
||||
ffmpegPath = Program.DefaultFFmpegFilePath;
|
||||
}
|
||||
|
||||
if (!File.Exists(ffmpegPath))
|
||||
@ -791,7 +791,7 @@ namespace ShareX
|
||||
if (FFmpegDownloader.DownloadFFmpeg(false, DownloaderForm_InstallRequested) == DialogResult.OK)
|
||||
{
|
||||
Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.CLIPath =
|
||||
taskSettings.CaptureSettings.FFmpegOptions.CLIPath = Program.DefaultFFmpegPath;
|
||||
taskSettings.CaptureSettings.FFmpegOptions.CLIPath = Program.DefaultFFmpegFilePath;
|
||||
|
||||
#if STEAM
|
||||
Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.OverrideCLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.OverrideCLIPath =
|
||||
@ -810,7 +810,7 @@ namespace ShareX
|
||||
|
||||
private static void DownloaderForm_InstallRequested(string filePath)
|
||||
{
|
||||
bool result = FFmpegDownloader.ExtractFFmpeg(filePath, Program.DefaultFFmpegPath);
|
||||
bool result = FFmpegDownloader.ExtractFFmpeg(filePath, Program.DefaultFFmpegFilePath);
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
@ -312,7 +312,7 @@ namespace ShareX
|
||||
|
||||
#region Capture / Screen recorder
|
||||
|
||||
public FFmpegOptions FFmpegOptions = new FFmpegOptions(Program.DefaultFFmpegPath);
|
||||
public FFmpegOptions FFmpegOptions = new FFmpegOptions(Program.DefaultFFmpegFilePath);
|
||||
public int ScreenRecordFPS = 20;
|
||||
public int GIFFPS = 5;
|
||||
public ScreenRecordGIFEncoding GIFEncoding = ScreenRecordGIFEncoding.FFmpeg;
|
||||
|
Loading…
x
Reference in New Issue
Block a user