Skip to content

Commit

Permalink
Moved file related methods to FileHelpers class
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaex committed May 3, 2022
1 parent 23061aa commit f60e8dd
Show file tree
Hide file tree
Showing 78 changed files with 991 additions and 930 deletions.
2 changes: 1 addition & 1 deletion ShareX.HelpersLib/Extensions/StreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static bool WriteToFile(this Stream stream, string filePath)
{
if (stream.Length > 0 && !string.IsNullOrEmpty(filePath))
{
Helpers.CreateDirectoryFromFilePath(filePath);
FileHelpers.CreateDirectoryFromFilePath(filePath);

using (FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
Expand Down
6 changes: 3 additions & 3 deletions ShareX.HelpersLib/ExternalProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ExternalProgram(string name, string path) : this()

public string GetFullPath()
{
return Helpers.ExpandFolderVariables(Path);
return FileHelpers.ExpandFolderVariables(Path);
}

public string Run(string inputPath)
Expand Down Expand Up @@ -107,7 +107,7 @@ public string Run(string inputPath)
CreateNoWindow = HiddenWindow
};

DebugHelper.WriteLine($"Action input: \"{inputPath}\" [{Helpers.GetFileSizeReadable(inputPath)}]");
DebugHelper.WriteLine($"Action input: \"{inputPath}\" [{FileHelpers.GetFileSizeReadable(inputPath)}]");
DebugHelper.WriteLine($"Action run: \"{psi.FileName}\" {psi.Arguments}");

process.StartInfo = psi;
Expand All @@ -117,7 +117,7 @@ public string Run(string inputPath)

if (!string.IsNullOrEmpty(outputPath) && File.Exists(outputPath))
{
DebugHelper.WriteLine($"Action output: \"{outputPath}\" [{Helpers.GetFileSizeReadable(outputPath)}]");
DebugHelper.WriteLine($"Action output: \"{outputPath}\" [{FileHelpers.GetFileSizeReadable(outputPath)}]");

if (DeleteInputFile && !inputPath.Equals(outputPath, StringComparison.OrdinalIgnoreCase))
{
Expand Down
4 changes: 2 additions & 2 deletions ShareX.HelpersLib/Forms/DebugForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private DebugForm(Logger logger)

string startupPath = AppDomain.CurrentDomain.BaseDirectory;
llRunningFrom.Text = startupPath;
llRunningFrom.LinkClicked += (sender, e) => Helpers.OpenFolder(startupPath);
llRunningFrom.LinkClicked += (sender, e) => FileHelpers.OpenFolder(startupPath);

Logger.MessageAdded += logger_MessageAdded;
Activated += (sender, e) => btnUploadLog.Visible = HasUploadRequested;
Expand Down Expand Up @@ -101,7 +101,7 @@ private void btnCopyAll_Click(object sender, EventArgs e)

private void btnOpenLogFile_Click(object sender, EventArgs e)
{
Helpers.OpenFile(Logger.LogFilePath);
FileHelpers.OpenFile(Logger.LogFilePath);
}

private void btnLoadedAssemblies_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion ShareX.HelpersLib/Forms/ErrorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void btnSendBugReport_Click(object sender, EventArgs e)

private void btnOpenLogFile_Click(object sender, EventArgs e)
{
Helpers.OpenFile(LogPath);
FileHelpers.OpenFile(LogPath);
}

private void btnContinue_Click(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions ShareX.HelpersLib/Forms/HashCheckForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ private void UpdateCompareControls()

private void btnFilePathBrowse_Click(object sender, EventArgs e)
{
Helpers.BrowseFile(txtFilePath);
FileHelpers.BrowseFile(txtFilePath);
}

private void btnFilePathBrowse2_Click(object sender, EventArgs e)
{
Helpers.BrowseFile(txtFilePath2);
FileHelpers.BrowseFile(txtFilePath2);
}

private void cbCompareTwoFiles_CheckedChanged(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions ShareX.HelpersLib/Forms/ImageViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private void FilterImageFiles()
{
string imageFilePath = Images[i];

bool isImageFile = !string.IsNullOrEmpty(imageFilePath) && Helpers.IsImageFile(imageFilePath);
bool isImageFile = !string.IsNullOrEmpty(imageFilePath) && FileHelpers.IsImageFile(imageFilePath);

if (i == CurrentImageIndex)
{
Expand Down Expand Up @@ -150,7 +150,7 @@ private void UpdateStatus()
AppendStatus($"{CurrentImageIndex + 1} / {Images.Length}");
}

string fileName = Helpers.GetFileNameSafe(CurrentImageFilePath);
string fileName = FileHelpers.GetFileNameSafe(CurrentImageFilePath);

if (!string.IsNullOrEmpty(fileName))
{
Expand Down
Loading

0 comments on commit f60e8dd

Please sign in to comment.