Rename variables

This commit is contained in:
Jaex 2021-12-12 00:21:19 +03:00
parent 7792e7d244
commit 241619cc07
37 changed files with 196 additions and 199 deletions

View file

@ -227,9 +227,9 @@ private void tsmiImportFile_Click(object sender, EventArgs e)
{ {
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
{ {
foreach (string filename in ofd.FileNames) foreach (string fileName in ofd.FileNames)
{ {
ImportFile(filename); ImportFile(fileName);
} }
OnImportCompleted(); OnImportCompleted();

View file

@ -92,7 +92,7 @@ public static Cursor[] CursorList
} }
} }
public static string GetFilenameExtension(string filePath, bool includeDot = false, bool checkSecondExtension = true) public static string GetFileNameExtension(string filePath, bool includeDot = false, bool checkSecondExtension = true)
{ {
string extension = ""; string extension = "";
@ -107,7 +107,7 @@ public static string GetFilenameExtension(string filePath, bool includeDot = fal
if (checkSecondExtension) if (checkSecondExtension)
{ {
filePath = filePath.Remove(pos); filePath = filePath.Remove(pos);
string extension2 = GetFilenameExtension(filePath, false, false); string extension2 = GetFileNameExtension(filePath, false, false);
if (!string.IsNullOrEmpty(extension2)) if (!string.IsNullOrEmpty(extension2))
{ {
@ -132,7 +132,7 @@ public static string GetFilenameExtension(string filePath, bool includeDot = fal
return extension; return extension;
} }
public static string GetFilenameSafe(string filePath) public static string GetFileNameSafe(string filePath)
{ {
if (!string.IsNullOrEmpty(filePath)) if (!string.IsNullOrEmpty(filePath))
{ {
@ -152,7 +152,7 @@ public static string GetFilenameSafe(string filePath)
return filePath; return filePath;
} }
public static string ChangeFilenameExtension(string fileName, string extension) public static string ChangeFileNameExtension(string fileName, string extension)
{ {
if (!string.IsNullOrEmpty(fileName)) if (!string.IsNullOrEmpty(fileName))
{ {
@ -186,7 +186,7 @@ public static string AppendExtension(string filePath, string extension)
public static bool CheckExtension(string filePath, IEnumerable<string> extensions) public static bool CheckExtension(string filePath, IEnumerable<string> extensions)
{ {
string ext = GetFilenameExtension(filePath); string ext = GetFileNameExtension(filePath);
if (!string.IsNullOrEmpty(ext)) if (!string.IsNullOrEmpty(ext))
{ {

View file

@ -1767,7 +1767,7 @@ public static string[] OpenImageFileDialog(bool multiselect, Form form = null, s
public static ImageFormat GetImageFormat(string filePath) public static ImageFormat GetImageFormat(string filePath)
{ {
ImageFormat imageFormat = ImageFormat.Png; ImageFormat imageFormat = ImageFormat.Png;
string ext = Helpers.GetFilenameExtension(filePath); string ext = Helpers.GetFileNameExtension(filePath);
if (!string.IsNullOrEmpty(ext)) if (!string.IsNullOrEmpty(ext))
{ {
@ -1840,7 +1840,7 @@ public static string SaveImageFileDialog(Image img, string filePath = "", bool u
sfd.FileName = Path.GetFileName(filePath); sfd.FileName = Path.GetFileName(filePath);
string ext = Helpers.GetFilenameExtension(filePath); string ext = Helpers.GetFileNameExtension(filePath);
if (!string.IsNullOrEmpty(ext)) if (!string.IsNullOrEmpty(ext))
{ {

View file

@ -121,7 +121,7 @@ public static bool CheckStringValue(string path, string name = null, string valu
public static string SearchProgramPath(string fileName) public static string SearchProgramPath(string fileName)
{ {
// First method: HKEY_CLASSES_ROOT\Applications\{filename}\shell\{command}\command // First method: HKEY_CLASSES_ROOT\Applications\{fileName}\shell\{command}\command
string[] commands = new string[] { "open", "edit" }; string[] commands = new string[] { "open", "edit" };

View file

@ -111,14 +111,14 @@ private static bool Delete(string shortcutPath)
private static string GetShortcutTargetPath(string shortcutPath) private static string GetShortcutTargetPath(string shortcutPath)
{ {
string directory = Path.GetDirectoryName(shortcutPath); string directory = Path.GetDirectoryName(shortcutPath);
string filename = Path.GetFileName(shortcutPath); string fileName = Path.GetFileName(shortcutPath);
try try
{ {
Type t = Type.GetTypeFromProgID("Shell.Application"); Type t = Type.GetTypeFromProgID("Shell.Application");
object shell = Activator.CreateInstance(t); object shell = Activator.CreateInstance(t);
Folder folder = (Folder)t.InvokeMember("NameSpace", BindingFlags.InvokeMethod, null, shell, new object[] { directory }); Folder folder = (Folder)t.InvokeMember("NameSpace", BindingFlags.InvokeMethod, null, shell, new object[] { directory });
FolderItem folderItem = folder.ParseName(filename); FolderItem folderItem = folder.ParseName(fileName);
if (folderItem != null) if (folderItem != null)
{ {
@ -145,11 +145,11 @@ public static void PinUnpinTaskBar(string filePath, bool pin)
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath)) if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
{ {
string directory = Path.GetDirectoryName(filePath); string directory = Path.GetDirectoryName(filePath);
string filename = Path.GetFileName(filePath); string fileName = Path.GetFileName(filePath);
Shell shell = new ShellClass(); Shell shell = new ShellClass();
Folder folder = shell.NameSpace(directory); Folder folder = shell.NameSpace(directory);
FolderItem folderItem = folder.ParseName(filename); FolderItem folderItem = folder.ParseName(fileName);
FolderItemVerbs verbs = folderItem.Verbs(); FolderItemVerbs verbs = folderItem.Verbs();

View file

@ -63,7 +63,7 @@ public string ProcessFilePath
} }
} }
public string ProcessFileName => Helpers.GetFilenameSafe(ProcessFilePath); public string ProcessFileName => Helpers.GetFileNameSafe(ProcessFilePath);
public int ProcessId public int ProcessId
{ {

View file

@ -68,7 +68,7 @@ public override void CheckUpdate()
throw new Exception("Unable to find setup file."); throw new Exception("Unable to find setup file.");
} }
Filename = artifact.fileName; FileName = artifact.fileName;
DownloadURL = appveyor.GetArtifactDownloadURL(job.jobId, artifact.fileName); DownloadURL = appveyor.GetArtifactDownloadURL(job.jobId, artifact.fileName);
if (Version.TryParse(project.build.version, out Version version)) if (Version.TryParse(project.build.version, out Version version))
{ {

View file

@ -40,7 +40,7 @@ public partial class DownloaderForm : BlackStyleForm
public event DownloaderInstallEventHandler InstallRequested; public event DownloaderInstallEventHandler InstallRequested;
public string URL { get; set; } public string URL { get; set; }
public string Filename { get; set; } public string FileName { get; set; }
public string DownloadLocation { get; private set; } public string DownloadLocation { get; private set; }
public IWebProxy Proxy { get; set; } public IWebProxy Proxy { get; set; }
public string AcceptHeader { get; set; } public string AcceptHeader { get; set; }
@ -64,14 +64,14 @@ private DownloaderForm()
RunInstallerInBackground = true; RunInstallerInBackground = true;
} }
public DownloaderForm(string url, string filename) : this() public DownloaderForm(string url, string fileName) : this()
{ {
URL = url; URL = url;
Filename = filename; FileName = fileName;
lblFilename.Text = Helpers.SafeStringFormat(Resources.DownloaderForm_DownloaderForm_Filename___0_, Filename); lblFilename.Text = Helpers.SafeStringFormat(Resources.DownloaderForm_DownloaderForm_Filename___0_, FileName);
} }
public DownloaderForm(UpdateChecker updateChecker) : this(updateChecker.DownloadURL, updateChecker.Filename) public DownloaderForm(UpdateChecker updateChecker) : this(updateChecker.DownloadURL, updateChecker.FileName)
{ {
Proxy = updateChecker.Proxy; Proxy = updateChecker.Proxy;
@ -216,7 +216,7 @@ private void StartDownload()
string folderPath = Path.Combine(Path.GetTempPath(), "ShareX"); string folderPath = Path.Combine(Path.GetTempPath(), "ShareX");
Helpers.CreateDirectory(folderPath); Helpers.CreateDirectory(folderPath);
DownloadLocation = Path.Combine(folderPath, Filename); DownloadLocation = Path.Combine(folderPath, FileName);
DebugHelper.WriteLine($"Downloading: \"{URL}\" -> \"{DownloadLocation}\""); DebugHelper.WriteLine($"Downloading: \"{URL}\" -> \"{DownloadLocation}\"");

View file

@ -76,7 +76,7 @@ protected override bool UpdateReleaseInfo(GitHubRelease release, bool isPortable
{ {
if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase)) if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase))
{ {
Filename = asset.name; FileName = asset.name;
if (isBrowserDownloadURL) if (isBrowserDownloadURL)
{ {

View file

@ -151,7 +151,7 @@ protected virtual bool UpdateReleaseInfo(GitHubRelease release, bool isPortable,
{ {
if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase)) if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase))
{ {
Filename = asset.name; FileName = asset.name;
if (isBrowserDownloadURL) if (isBrowserDownloadURL)
{ {

View file

@ -43,22 +43,22 @@ public abstract class UpdateChecker
public bool IsPortable { get; set; } public bool IsPortable { get; set; }
public IWebProxy Proxy { get; set; } public IWebProxy Proxy { get; set; }
private string filename; private string fileName;
public string Filename public string FileName
{ {
get get
{ {
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(fileName))
{ {
return HttpUtility.UrlDecode(DownloadURL.Substring(DownloadURL.LastIndexOf('/') + 1)); return HttpUtility.UrlDecode(DownloadURL.Substring(DownloadURL.LastIndexOf('/') + 1));
} }
return filename; return fileName;
} }
set set
{ {
filename = value; fileName = value;
} }
} }

View file

@ -359,7 +359,7 @@ private string OutputStats(HistoryItem[] historyItems)
IEnumerable<string> fileExtensions = historyItems. IEnumerable<string> fileExtensions = historyItems.
Where(x => !string.IsNullOrEmpty(x.FileName) && !x.FileName.EndsWith(")")). Where(x => !string.IsNullOrEmpty(x.FileName) && !x.FileName.EndsWith(")")).
Select(x => Helpers.GetFilenameExtension(x.FileName)). Select(x => Helpers.GetFileNameExtension(x.FileName)).
GroupBy(x => x). GroupBy(x => x).
OrderByDescending(x => x.Count()). OrderByDescending(x => x.Count()).
Select(x => string.Format("{0} ({1})", x.Key, x.Count())); Select(x => string.Format("{0} ({1})", x.Key, x.Count()));

View file

@ -149,7 +149,7 @@ private void btnGenerate_Click(object sender, EventArgs e)
int height = (int)nudHeight.Value; int height = (int)nudHeight.Value;
int quality = (int)nudQuality.Value; int quality = (int)nudQuality.Value;
string outputFolder = txtOutputFolder.Text; string outputFolder = txtOutputFolder.Text;
string outputFilename = txtOutputFilename.Text; string outputFileName = txtOutputFilename.Text;
Cursor = Cursors.WaitCursor; Cursor = Cursors.WaitCursor;
@ -167,8 +167,8 @@ private void btnGenerate_Click(object sender, EventArgs e)
{ {
using (Bitmap thumbnail = ImageHelpers.CreateThumbnail(bmp, width, height)) using (Bitmap thumbnail = ImageHelpers.CreateThumbnail(bmp, width, height))
{ {
string filename = Path.GetFileNameWithoutExtension(filePath); string fileName = Path.GetFileNameWithoutExtension(filePath);
string outputPath = Path.Combine(outputFolder, outputFilename.Replace("$filename", filename)); string outputPath = Path.Combine(outputFolder, outputFileName.Replace("$filename", fileName));
outputPath = Path.ChangeExtension(outputPath, "jpg"); outputPath = Path.ChangeExtension(outputPath, "jpg");
using (Bitmap newImage = ImageHelpers.FillBackground(thumbnail, Color.White)) using (Bitmap newImage = ImageHelpers.FillBackground(thumbnail, Color.White))

View file

@ -84,8 +84,8 @@ public List<VideoThumbnailInfo> TakeThumbnails(string mediaPath)
timeSliceElapsed = GetTimeSlice(Options.ThumbnailCount) * (i + 1); timeSliceElapsed = GetTimeSlice(Options.ThumbnailCount) * (i + 1);
} }
string filename = string.Format("{0}-{1}.{2}", mediaFileName, timeSliceElapsed, Options.ImageFormat.GetDescription()); string fileName = string.Format("{0}-{1}.{2}", mediaFileName, timeSliceElapsed, Options.ImageFormat.GetDescription());
string tempThumbnailPath = Path.Combine(GetOutputDirectory(), filename); string tempThumbnailPath = Path.Combine(GetOutputDirectory(), fileName);
using (Process process = new Process()) using (Process process = new Process())
{ {

View file

@ -260,11 +260,11 @@ internal void UpdateTitle()
text += $" - {Canvas.Width}x{Canvas.Height}"; text += $" - {Canvas.Width}x{Canvas.Height}";
} }
string filename = Helpers.GetFilenameSafe(ImageFilePath); string fileName = Helpers.GetFileNameSafe(ImageFilePath);
if (!string.IsNullOrEmpty(filename)) if (!string.IsNullOrEmpty(fileName))
{ {
text += " - " + filename; text += " - " + fileName;
} }
if (!IsFullscreen && Options.ShowFPS) if (!IsFullscreen && Options.ShowFPS)

View file

@ -233,11 +233,11 @@ private static void CompileSetup()
CompileISSFile("ShareX-setup.iss"); CompileISSFile("ShareX-setup.iss");
} }
private static void CompileISSFile(string filename) private static void CompileISSFile(string fileName)
{ {
if (File.Exists(InnoSetupCompilerPath)) if (File.Exists(InnoSetupCompilerPath))
{ {
Console.WriteLine("Compiling setup file: " + filename); Console.WriteLine("Compiling setup file: " + fileName);
using (Process process = new Process()) using (Process process = new Process())
{ {
@ -245,7 +245,7 @@ private static void CompileISSFile(string filename)
{ {
FileName = InnoSetupCompilerPath, FileName = InnoSetupCompilerPath,
WorkingDirectory = Path.GetFullPath(InnoSetupDir), WorkingDirectory = Path.GetFullPath(InnoSetupDir),
Arguments = $"\"{filename}\"", Arguments = $"\"{fileName}\"",
UseShellExecute = false UseShellExecute = false
}; };
@ -337,8 +337,8 @@ private static void CreateFolder(string source, string destination, SetupJobs jo
Helpers.CreateEmptyFile(Path.Combine(destination, "Portable")); Helpers.CreateEmptyFile(Path.Combine(destination, "Portable"));
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(ReleaseExecutablePath); FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(ReleaseExecutablePath);
string zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart); string zipFileName = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart);
string zipPath = Path.Combine(OutputDir, zipFilename); string zipPath = Path.Combine(OutputDir, zipFileName);
//string zipPath = Path.Combine(OutputDir, "ShareX-portable.zip"); //string zipPath = Path.Combine(OutputDir, "ShareX-portable.zip");
ZipManager.Compress(Path.GetFullPath(destination), Path.GetFullPath(zipPath)); ZipManager.Compress(Path.GetFullPath(destination), Path.GetFullPath(zipPath));

View file

@ -63,11 +63,11 @@ public static void CopyFiles(IEnumerable<string> files, string toFolder)
Directory.CreateDirectory(toFolder); Directory.CreateDirectory(toFolder);
} }
foreach (string filepath in files) foreach (string filePath in files)
{ {
string filename = Path.GetFileName(filepath); string fileName = Path.GetFileName(filePath);
string dest = Path.Combine(toFolder, filename); string dest = Path.Combine(toFolder, fileName);
File.Copy(filepath, dest); File.Copy(filePath, dest);
} }
} }
@ -81,9 +81,9 @@ public static void CopyFiles(string directory, string searchPattern, string toFo
foreach (string file in files) foreach (string file in files)
{ {
string filename = Path.GetFileName(file); string fileName = Path.GetFileName(file);
if (ignoreFiles.All(x => !filename.Equals(x, StringComparison.InvariantCultureIgnoreCase))) if (ignoreFiles.All(x => !fileName.Equals(x, StringComparison.InvariantCultureIgnoreCase)))
{ {
newFiles.Add(file); newFiles.Add(file);
} }

View file

@ -27,12 +27,12 @@ namespace ShareX.UploadersLib
{ {
public class CustomUploaderInput public class CustomUploaderInput
{ {
public string Filename { get; set; } public string FileName { get; set; }
public string Input { get; set; } public string Input { get; set; }
public CustomUploaderInput(string filename, string input) public CustomUploaderInput(string fileName, string input)
{ {
Filename = filename; FileName = fileName;
Input = input; Input = input;
} }
} }

View file

@ -266,7 +266,7 @@ public void ParseResponse(UploadResult result, ResponseInfo responseInfo, Custom
} }
CustomUploaderParser parser = new CustomUploaderParser(responseInfo, RegexList); CustomUploaderParser parser = new CustomUploaderParser(responseInfo, RegexList);
parser.Filename = input.Filename; parser.FileName = input.FileName;
parser.URLEncode = true; parser.URLEncode = true;
if (responseInfo.IsSuccess) if (responseInfo.IsSuccess)

View file

@ -43,7 +43,7 @@ public class CustomUploaderParser
public const char SyntaxEscapeChar = '\\'; public const char SyntaxEscapeChar = '\\';
public bool IsOutput { get; set; } public bool IsOutput { get; set; }
public string Filename { get; set; } public string FileName { get; set; }
public string Input { get; set; } public string Input { get; set; }
public ResponseInfo ResponseInfo { get; set; } public ResponseInfo ResponseInfo { get; set; }
public List<Match> RegexMatches { get; set; } public List<Match> RegexMatches { get; set; }
@ -61,9 +61,9 @@ public CustomUploaderParser()
IsOutput = false; IsOutput = false;
} }
public CustomUploaderParser(string filename, string input) public CustomUploaderParser(string fileName, string input)
{ {
Filename = filename; FileName = fileName;
Input = input; Input = input;
IsOutput = false; IsOutput = false;
@ -87,7 +87,7 @@ public CustomUploaderParser(ResponseInfo responseInfo, List<string> regexList)
IsOutput = true; IsOutput = true;
} }
public CustomUploaderParser(CustomUploaderInput input) : this(input.Filename, input.Input) public CustomUploaderParser(CustomUploaderInput input) : this(input.FileName, input.Input)
{ {
} }
@ -233,7 +233,7 @@ private string ParseSyntax(string syntax, bool isOutput)
if (CheckKeyword(syntax, "filename")) // Example: $filename$ if (CheckKeyword(syntax, "filename")) // Example: $filename$
{ {
return AutoEncode(Filename); return AutoEncode(FileName);
} }
else if (CheckKeyword(syntax, "random", out value)) // Example: $random:domain1.com|domain2.com$ else if (CheckKeyword(syntax, "random", out value)) // Example: $random:domain1.com|domain2.com$
{ {

View file

@ -192,17 +192,17 @@ public override UploadResult Upload(Stream stream, string fileName)
public string GetLinkURL(CopyLinksInfo link, string path, CopyURLType urlType = CopyURLType.Default) public string GetLinkURL(CopyLinksInfo link, string path, CopyURLType urlType = CopyURLType.Default)
{ {
string filename = URLHelpers.URLEncode(URLHelpers.GetFileName(path)); string fileName = URLHelpers.URLEncode(URLHelpers.GetFileName(path));
switch (urlType) switch (urlType)
{ {
default: default:
case CopyURLType.Default: case CopyURLType.Default:
return string.Format("https://www.copy.com/s/{0}/{1}", link.id, filename); return string.Format("https://www.copy.com/s/{0}/{1}", link.id, fileName);
case CopyURLType.Shortened: case CopyURLType.Shortened:
return string.Format("https://copy.com/{0}", link.id); return string.Format("https://copy.com/{0}", link.id);
case CopyURLType.Direct: case CopyURLType.Direct:
return string.Format("https://copy.com/{0}/{1}", link.id, filename); return string.Format("https://copy.com/{0}/{1}", link.id, fileName);
} }
} }

View file

@ -33,20 +33,17 @@ namespace ShareX.UploadersLib.FileUploaders
public sealed class DropIO : FileUploader public sealed class DropIO : FileUploader
{ {
public string DropName { get; set; } public string DropName { get; set; }
public string DropDescription { get; set; } public string DropDescription { get; set; }
public class Asset public class Asset
{ {
public string Name { get; set; } public string Name { get; set; }
public string OriginalFilename { get; set; } public string OriginalFilename { get; set; }
} }
public class Drop public class Drop
{ {
public string Name { get; set; } public string Name { get; set; }
public string AdminToken { get; set; } public string AdminToken { get; set; }
} }

View file

@ -149,24 +149,24 @@ private NameValueCollection GetAuthHeaders()
return headers; return headers;
} }
public static string VerifyPath(string path, string filename = null) public static string VerifyPath(string path, string fileName = null)
{ {
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
path = path.Trim().Replace('\\', '/').Trim('/'); path = path.Trim().Replace('\\', '/').Trim('/');
path = URLHelpers.AddSlash(path, SlashType.Prefix); path = URLHelpers.AddSlash(path, SlashType.Prefix);
if (!string.IsNullOrEmpty(filename)) if (!string.IsNullOrEmpty(fileName))
{ {
path = URLHelpers.CombineURL(path, filename); path = URLHelpers.CombineURL(path, fileName);
} }
return path; return path;
} }
if (!string.IsNullOrEmpty(filename)) if (!string.IsNullOrEmpty(fileName))
{ {
return filename; return fileName;
} }
return ""; return "";
@ -205,7 +205,7 @@ public bool DownloadFile(string path, Stream downloadStream)
return false; return false;
} }
public UploadResult UploadFile(Stream stream, string path, string filename, bool createShareableLink = false, bool useDirectLink = false) public UploadResult UploadFile(Stream stream, string path, string fileName, bool createShareableLink = false, bool useDirectLink = false)
{ {
if (stream.Length > 150000000) if (stream.Length > 150000000)
{ {
@ -215,7 +215,7 @@ public UploadResult UploadFile(Stream stream, string path, string filename, bool
string json = JsonConvert.SerializeObject(new string json = JsonConvert.SerializeObject(new
{ {
path = VerifyPath(path, filename), path = VerifyPath(path, fileName),
mode = "overwrite", mode = "overwrite",
autorename = false, autorename = false,
mute = true mute = true

View file

@ -302,18 +302,18 @@ public void UploadFiles(string[] localPaths, string remotePath)
{ {
if (!string.IsNullOrEmpty(file)) if (!string.IsNullOrEmpty(file))
{ {
string filename = Path.GetFileName(file); string fileName = Path.GetFileName(file);
if (File.Exists(file)) if (File.Exists(file))
{ {
UploadFile(file, URLHelpers.CombineURL(remotePath, filename)); UploadFile(file, URLHelpers.CombineURL(remotePath, fileName));
} }
else if (Directory.Exists(file)) else if (Directory.Exists(file))
{ {
List<string> filesList = new List<string>(); List<string> filesList = new List<string>();
filesList.AddRange(Directory.GetFiles(file)); filesList.AddRange(Directory.GetFiles(file));
filesList.AddRange(Directory.GetDirectories(file)); filesList.AddRange(Directory.GetDirectories(file));
string path = URLHelpers.CombineURL(remotePath, filename); string path = URLHelpers.CombineURL(remotePath, fileName);
CreateDirectory(path); CreateDirectory(path);
UploadFiles(filesList.ToArray(), path); UploadFiles(filesList.ToArray(), path);
} }
@ -454,8 +454,8 @@ public void DeleteDirectory(string remotePath)
{ {
if (Connect()) if (Connect())
{ {
string filename = URLHelpers.GetFileName(remotePath); string fileName = URLHelpers.GetFileName(remotePath);
if (filename == "." || filename == "..") if (fileName == "." || fileName == "..")
{ {
return; return;
} }

View file

@ -99,10 +99,10 @@ public string FTPAddress
} }
} }
private string exampleFilename = "example.png"; private string exampleFileName = "example.png";
[Category("FTP"), Description("Preview of the FTP path based on the settings above")] [Category("FTP"), Description("Preview of the FTP path based on the settings above")]
public string PreviewFtpPath => GetFtpPath(exampleFilename); public string PreviewFtpPath => GetFtpPath(exampleFileName);
[Category("FTP"), Description("Preview of the HTTP path based on the settings above")] [Category("FTP"), Description("Preview of the HTTP path based on the settings above")]
public string PreviewHttpPath public string PreviewHttpPath
@ -111,7 +111,7 @@ public string PreviewHttpPath
{ {
try try
{ {
return GetUriPath(exampleFilename); return GetUriPath(exampleFileName);
} }
catch catch
{ {
@ -150,10 +150,10 @@ public FTPAccount()
FTPSCertificateLocation = ""; FTPSCertificateLocation = "";
} }
public string GetSubFolderPath(string filename = null, NameParserType nameParserType = NameParserType.URL) public string GetSubFolderPath(string fileName = null, NameParserType nameParserType = NameParserType.URL)
{ {
string path = NameParser.Parse(nameParserType, SubFolderPath.Replace("%host", Host)); string path = NameParser.Parse(nameParserType, SubFolderPath.Replace("%host", Host));
return URLHelpers.CombineURL(path, filename); return URLHelpers.CombineURL(path, fileName);
} }
public string GetHttpHomePath() public string GetHttpHomePath()
@ -166,7 +166,7 @@ public string GetHttpHomePath()
return parser.Parse(homePath); return parser.Parse(homePath);
} }
public string GetUriPath(string filename, string subFolderPath = null) public string GetUriPath(string fileName, string subFolderPath = null)
{ {
if (string.IsNullOrEmpty(Host)) if (string.IsNullOrEmpty(Host))
{ {
@ -175,10 +175,10 @@ public string GetUriPath(string filename, string subFolderPath = null)
if (HttpHomePathNoExtension) if (HttpHomePathNoExtension)
{ {
filename = Path.GetFileNameWithoutExtension(filename); fileName = Path.GetFileNameWithoutExtension(fileName);
} }
filename = URLHelpers.URLEncode(filename); fileName = URLHelpers.URLEncode(fileName);
if (subFolderPath == null) if (subFolderPath == null)
{ {
@ -203,7 +203,7 @@ public string GetUriPath(string filename, string subFolderPath = null)
url = URLHelpers.CombineURL(url, subFolderPath); url = URLHelpers.CombineURL(url, subFolderPath);
} }
url = URLHelpers.CombineURL(url, filename); url = URLHelpers.CombineURL(url, fileName);
httpHomeUri = new UriBuilder(url); httpHomeUri = new UriBuilder(url);
httpHomeUri.Port = -1; //Since httpHomePath is not set, it's safe to erase UriBuilder's assumed port number httpHomeUri.Port = -1; //Since httpHomePath is not set, it's safe to erase UriBuilder's assumed port number
@ -237,11 +237,11 @@ public string GetUriPath(string filename, string subFolderPath = null)
//Setting URIBuilder.Query automatically prepends a ? so we must trim it first. //Setting URIBuilder.Query automatically prepends a ? so we must trim it first.
if (HttpHomePathAutoAddSubFolderPath) if (HttpHomePathAutoAddSubFolderPath)
{ {
httpHomeUri.Query = URLHelpers.CombineURL(httpHomeUri.Query.Substring(1), subFolderPath, filename); httpHomeUri.Query = URLHelpers.CombineURL(httpHomeUri.Query.Substring(1), subFolderPath, fileName);
} }
else else
{ {
httpHomeUri.Query = httpHomeUri.Query.Substring(1) + filename; httpHomeUri.Query = httpHomeUri.Query.Substring(1) + fileName;
} }
} }
else else
@ -251,7 +251,7 @@ public string GetUriPath(string filename, string subFolderPath = null)
httpHomeUri.Path = URLHelpers.CombineURL(httpHomeUri.Path, subFolderPath); httpHomeUri.Path = URLHelpers.CombineURL(httpHomeUri.Path, subFolderPath);
} }
httpHomeUri.Path = URLHelpers.CombineURL(httpHomeUri.Path, filename); httpHomeUri.Path = URLHelpers.CombineURL(httpHomeUri.Path, fileName);
} }
} }

View file

@ -78,14 +78,14 @@ public string LocalUri
} }
} }
private string exampleFilename = "screenshot.jpg"; private string exampleFileName = "screenshot.jpg";
[Category("Localhost"), Description("Preview of the Localhost Path based on the settings above")] [Category("Localhost"), Description("Preview of the Localhost Path based on the settings above")]
public string PreviewLocalPath public string PreviewLocalPath
{ {
get get
{ {
return GetLocalhostUri(exampleFilename); return GetLocalhostUri(exampleFileName);
} }
} }
@ -94,7 +94,7 @@ public string PreviewRemotePath
{ {
get get
{ {
return GetUriPath(exampleFilename); return GetUriPath(exampleFileName);
} }
} }
@ -129,7 +129,7 @@ public string GetHttpHomePath()
return NameParser.Parse(NameParserType.URL, HttpHomePath.Replace("%host", Helpers.ExpandFolderVariables(LocalhostRoot))); return NameParser.Parse(NameParserType.URL, HttpHomePath.Replace("%host", Helpers.ExpandFolderVariables(LocalhostRoot)));
} }
public string GetUriPath(string filename) public string GetUriPath(string fileName)
{ {
if (string.IsNullOrEmpty(LocalhostRoot)) if (string.IsNullOrEmpty(LocalhostRoot))
{ {
@ -138,10 +138,10 @@ public string GetUriPath(string filename)
if (HttpHomePathNoExtension) if (HttpHomePathNoExtension)
{ {
filename = Path.GetFileNameWithoutExtension(filename); fileName = Path.GetFileNameWithoutExtension(fileName);
} }
filename = URLHelpers.URLEncode(filename); fileName = URLHelpers.URLEncode(fileName);
string subFolderPath = GetSubFolderPath(); string subFolderPath = GetSubFolderPath();
subFolderPath = URLHelpers.URLEncode(subFolderPath, true); subFolderPath = URLHelpers.URLEncode(subFolderPath, true);
@ -170,7 +170,7 @@ public string GetUriPath(string filename)
path = URLHelpers.CombineURL(path, subFolderPath); path = URLHelpers.CombineURL(path, subFolderPath);
} }
path = URLHelpers.CombineURL(path, filename); path = URLHelpers.CombineURL(path, fileName);
string remoteProtocol = RemoteProtocol.GetDescription(); string remoteProtocol = RemoteProtocol.GetDescription();

View file

@ -90,7 +90,7 @@ public override UploadResult UploadText(string text, string fileName)
if (UseFileExtension) if (UseFileExtension)
{ {
string ext = Helpers.GetFilenameExtension(fileName); string ext = Helpers.GetFileNameExtension(fileName);
if (!string.IsNullOrEmpty(ext) && !ext.Equals("txt", StringComparison.InvariantCultureIgnoreCase)) if (!string.IsNullOrEmpty(ext) && !ext.Equals("txt", StringComparison.InvariantCultureIgnoreCase))
{ {

View file

@ -46,9 +46,9 @@ public UploaderFilter(string uploader, params string[] extensions)
Extensions = extensions.ToList(); Extensions = extensions.ToList();
} }
public bool IsValidFilter(string filename) public bool IsValidFilter(string fileName)
{ {
string extension = Helpers.GetFilenameExtension(filename); string extension = Helpers.GetFileNameExtension(fileName);
return !string.IsNullOrEmpty(extension) && Extensions.Any(x => x.TrimStart('.').Equals(extension, StringComparison.OrdinalIgnoreCase)); return !string.IsNullOrEmpty(extension) && Extensions.Any(x => x.TrimStart('.').Equals(extension, StringComparison.OrdinalIgnoreCase));
} }

View file

@ -64,7 +64,7 @@ public AfterCaptureForm(TaskMetadata metadata, TaskSettings taskSettings) : this
btnCopy.Enabled = true; btnCopy.Enabled = true;
} }
FileName = TaskHelpers.GetFilename(TaskSettings, null, metadata); FileName = TaskHelpers.GetFileName(TaskSettings, null, metadata);
txtFileName.Text = FileName; txtFileName.Text = FileName;
} }

View file

@ -33,22 +33,22 @@ namespace ShareX
{ {
public partial class FileExistForm : Form public partial class FileExistForm : Form
{ {
public string Filepath { get; private set; } public string FilePath { get; private set; }
private string filename; private string fileName;
private string uniqueFilepath; private string uniqueFilePath;
public FileExistForm(string filepath) public FileExistForm(string filePath)
{ {
InitializeComponent(); InitializeComponent();
ShareXResources.ApplyTheme(this); ShareXResources.ApplyTheme(this);
Filepath = filepath; FilePath = filePath;
filename = Path.GetFileNameWithoutExtension(Filepath); fileName = Path.GetFileNameWithoutExtension(FilePath);
txtNewName.Text = filename; txtNewName.Text = fileName;
btnOverwrite.Text += Path.GetFileName(Filepath); btnOverwrite.Text += Path.GetFileName(FilePath);
uniqueFilepath = Helpers.GetUniqueFilePath(Filepath); uniqueFilePath = Helpers.GetUniqueFilePath(FilePath);
btnUniqueName.Text += Path.GetFileName(uniqueFilepath); btnUniqueName.Text += Path.GetFileName(uniqueFilePath);
} }
private void FileExistForm_Shown(object sender, EventArgs e) private void FileExistForm_Shown(object sender, EventArgs e)
@ -56,46 +56,46 @@ private void FileExistForm_Shown(object sender, EventArgs e)
this.ForceActivate(); this.ForceActivate();
} }
private string GetNewFilename() private string GetNewFileName()
{ {
string newFilename = txtNewName.Text; string newFileName = txtNewName.Text;
if (!string.IsNullOrEmpty(newFilename)) if (!string.IsNullOrEmpty(newFileName))
{ {
return newFilename + Path.GetExtension(Filepath); return newFileName + Path.GetExtension(FilePath);
} }
return ""; return "";
} }
private void UseNewFilename() private void UseNewFileName()
{ {
string newFilename = GetNewFilename(); string newFileName = GetNewFileName();
if (!string.IsNullOrEmpty(newFilename)) if (!string.IsNullOrEmpty(newFileName))
{ {
Filepath = Path.Combine(Path.GetDirectoryName(Filepath), newFilename); FilePath = Path.Combine(Path.GetDirectoryName(FilePath), newFileName);
Close(); Close();
} }
} }
private void UseUniqueFilename() private void UseUniqueFileName()
{ {
Filepath = uniqueFilepath; FilePath = uniqueFilePath;
Close(); Close();
} }
private void Cancel() private void Cancel()
{ {
Filepath = ""; FilePath = "";
Close(); Close();
} }
private void txtNewName_TextChanged(object sender, EventArgs e) private void txtNewName_TextChanged(object sender, EventArgs e)
{ {
string newFilename = txtNewName.Text; string newFileName = txtNewName.Text;
btnNewName.Enabled = !string.IsNullOrEmpty(newFilename) && !newFilename.Equals(filename, StringComparison.InvariantCultureIgnoreCase); btnNewName.Enabled = !string.IsNullOrEmpty(newFileName) && !newFileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase);
btnNewName.Text = Resources.FileExistForm_txtNewName_TextChanged_Use_new_name__ + GetNewFilename(); btnNewName.Text = Resources.FileExistForm_txtNewName_TextChanged_Use_new_name__ + GetNewFileName();
} }
private void txtNewName_KeyDown(object sender, KeyEventArgs e) private void txtNewName_KeyDown(object sender, KeyEventArgs e)
@ -110,17 +110,17 @@ private void txtNewName_KeyUp(object sender, KeyEventArgs e)
{ {
if (e.KeyData == Keys.Enter) if (e.KeyData == Keys.Enter)
{ {
string newFilename = txtNewName.Text; string newFileName = txtNewName.Text;
if (!string.IsNullOrEmpty(newFilename)) if (!string.IsNullOrEmpty(newFileName))
{ {
if (newFilename.Equals(filename, StringComparison.InvariantCultureIgnoreCase)) if (newFileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase))
{ {
Close(); Close();
} }
else else
{ {
UseNewFilename(); UseNewFileName();
} }
} }
} }
@ -132,7 +132,7 @@ private void txtNewName_KeyUp(object sender, KeyEventArgs e)
private void btnNewName_Click(object sender, EventArgs e) private void btnNewName_Click(object sender, EventArgs e)
{ {
UseNewFilename(); UseNewFileName();
} }
private void btnOverwrite_Click(object sender, EventArgs e) private void btnOverwrite_Click(object sender, EventArgs e)
@ -142,7 +142,7 @@ private void btnOverwrite_Click(object sender, EventArgs e)
private void btnUniqueName_Click(object sender, EventArgs e) private void btnUniqueName_Click(object sender, EventArgs e)
{ {
UseUniqueFilename(); UseUniqueFileName();
} }
private void btnCancel_Click(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e)

View file

@ -179,7 +179,7 @@ public static string PersonalFolder
} }
} }
public const string HistoryFilename = "History.json"; public const string HistoryFileName = "History.json";
public static string HistoryFilePath public static string HistoryFilePath
{ {
@ -187,11 +187,11 @@ public static string HistoryFilePath
{ {
if (Sandbox) return null; if (Sandbox) return null;
return Path.Combine(PersonalFolder, HistoryFilename); return Path.Combine(PersonalFolder, HistoryFileName);
} }
} }
public const string HistoryFilenameOld = "History.xml"; public const string HistoryFileNameOld = "History.xml";
public static string HistoryFilePathOld public static string HistoryFilePathOld
{ {
@ -199,20 +199,20 @@ public static string HistoryFilePathOld
{ {
if (Sandbox) return null; if (Sandbox) return null;
return Path.Combine(PersonalFolder, HistoryFilenameOld); return Path.Combine(PersonalFolder, HistoryFileNameOld);
} }
} }
public const string LogsFoldername = "Logs"; public const string LogsFolderName = "Logs";
public static string LogsFolder => Path.Combine(PersonalFolder, LogsFoldername); public static string LogsFolder => Path.Combine(PersonalFolder, LogsFolderName);
public static string LogsFilePath public static string LogsFilePath
{ {
get get
{ {
string filename = string.Format("ShareX-Log-{0:yyyy-MM}.txt", DateTime.Now); string fileName = string.Format("ShareX-Log-{0:yyyy-MM}.txt", DateTime.Now);
return Path.Combine(LogsFolder, filename); return Path.Combine(LogsFolder, fileName);
} }
} }

View file

@ -47,7 +47,7 @@ public string FileName
text = URL; text = URL;
} }
return Helpers.GetFilenameSafe(text); return Helpers.GetFileNameSafe(text);
} }
} }

View file

@ -190,7 +190,7 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
extension = taskSettings.CaptureSettings.FFmpegOptions.Extension; extension = taskSettings.CaptureSettings.FFmpegOptions.Extension;
} }
string screenshotsFolder = TaskHelpers.GetScreenshotsFolder(taskSettings, metadata); string screenshotsFolder = TaskHelpers.GetScreenshotsFolder(taskSettings, metadata);
string fileName = TaskHelpers.GetFilename(taskSettings, extension, metadata); string fileName = TaskHelpers.GetFileName(taskSettings, extension, metadata);
path = TaskHelpers.HandleExistsFile(screenshotsFolder, fileName, taskSettings); path = TaskHelpers.HandleExistsFile(screenshotsFolder, fileName, taskSettings);
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
@ -291,10 +291,10 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
{ {
if (!string.IsNullOrEmpty(customFileName)) if (!string.IsNullOrEmpty(customFileName))
{ {
string currentFilename = Path.GetFileNameWithoutExtension(path); string currentFileName = Path.GetFileNameWithoutExtension(path);
string ext = Path.GetExtension(path); string ext = Path.GetExtension(path);
if (!currentFilename.Equals(customFileName, StringComparison.InvariantCultureIgnoreCase)) if (!currentFileName.Equals(customFileName, StringComparison.InvariantCultureIgnoreCase))
{ {
path = Helpers.RenameFile(path, customFileName + ext); path = Helpers.RenameFile(path, customFileName + ext);
} }
@ -322,7 +322,7 @@ private static void ScreenRecorder_EncodingProgressChanged(int progress)
private static string ProcessTwoPassEncoding(string input, TaskMetadata metadata, TaskSettings taskSettings, bool deleteInputFile = true) private static string ProcessTwoPassEncoding(string input, TaskMetadata metadata, TaskSettings taskSettings, bool deleteInputFile = true)
{ {
string screenshotsFolder = TaskHelpers.GetScreenshotsFolder(taskSettings, metadata); string screenshotsFolder = TaskHelpers.GetScreenshotsFolder(taskSettings, metadata);
string fileName = TaskHelpers.GetFilename(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension, metadata); string fileName = TaskHelpers.GetFileName(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension, metadata);
string output = Path.Combine(screenshotsFolder, fileName); string output = Path.Combine(screenshotsFolder, fileName);
try try

View file

@ -41,7 +41,7 @@ namespace ShareX
{ {
internal static class SettingManager internal static class SettingManager
{ {
private const string ApplicationConfigFilename = "ApplicationConfig.json"; private const string ApplicationConfigFileName = "ApplicationConfig.json";
private static string ApplicationConfigFilePath private static string ApplicationConfigFilePath
{ {
@ -49,11 +49,11 @@ private static string ApplicationConfigFilePath
{ {
if (Program.Sandbox) return null; if (Program.Sandbox) return null;
return Path.Combine(Program.PersonalFolder, ApplicationConfigFilename); return Path.Combine(Program.PersonalFolder, ApplicationConfigFileName);
} }
} }
private const string UploadersConfigFilename = "UploadersConfig.json"; private const string UploadersConfigFileName = "UploadersConfig.json";
private static string UploadersConfigFilePath private static string UploadersConfigFilePath
{ {
@ -72,11 +72,11 @@ private static string UploadersConfigFilePath
uploadersConfigFolder = Program.PersonalFolder; uploadersConfigFolder = Program.PersonalFolder;
} }
return Path.Combine(uploadersConfigFolder, UploadersConfigFilename); return Path.Combine(uploadersConfigFolder, UploadersConfigFileName);
} }
} }
private const string HotkeysConfigFilename = "HotkeysConfig.json"; private const string HotkeysConfigFileName = "HotkeysConfig.json";
private static string HotkeysConfigFilePath private static string HotkeysConfigFilePath
{ {
@ -95,7 +95,7 @@ private static string HotkeysConfigFilePath
hotkeysConfigFolder = Program.PersonalFolder; hotkeysConfigFolder = Program.PersonalFolder;
} }
return Path.Combine(hotkeysConfigFolder, HotkeysConfigFilename); return Path.Combine(hotkeysConfigFolder, HotkeysConfigFileName);
} }
} }
@ -364,13 +364,13 @@ public static bool Export(string archivePath, bool settings, bool history)
if (settings) if (settings)
{ {
msApplicationConfig = Settings.SaveToMemoryStream(false); msApplicationConfig = Settings.SaveToMemoryStream(false);
entries.Add(new ZipEntryInfo(msApplicationConfig, ApplicationConfigFilename)); entries.Add(new ZipEntryInfo(msApplicationConfig, ApplicationConfigFileName));
msUploadersConfig = UploadersConfig.SaveToMemoryStream(false); msUploadersConfig = UploadersConfig.SaveToMemoryStream(false);
entries.Add(new ZipEntryInfo(msUploadersConfig, UploadersConfigFilename)); entries.Add(new ZipEntryInfo(msUploadersConfig, UploadersConfigFileName));
msHotkeysConfig = HotkeysConfig.SaveToMemoryStream(false); msHotkeysConfig = HotkeysConfig.SaveToMemoryStream(false);
entries.Add(new ZipEntryInfo(msHotkeysConfig, HotkeysConfigFilename)); entries.Add(new ZipEntryInfo(msHotkeysConfig, HotkeysConfigFileName));
} }
if (history) if (history)

View file

@ -298,12 +298,12 @@ public static ImageData PrepareImage(Image img, TaskSettings taskSettings)
return imageData; return imageData;
} }
public static string CreateThumbnail(Bitmap bmp, string folder, string filename, TaskSettings taskSettings) public static string CreateThumbnail(Bitmap bmp, string folder, string fileName, TaskSettings taskSettings)
{ {
if ((taskSettings.ImageSettings.ThumbnailWidth > 0 || taskSettings.ImageSettings.ThumbnailHeight > 0) && (!taskSettings.ImageSettings.ThumbnailCheckSize || if ((taskSettings.ImageSettings.ThumbnailWidth > 0 || taskSettings.ImageSettings.ThumbnailHeight > 0) && (!taskSettings.ImageSettings.ThumbnailCheckSize ||
(bmp.Width > taskSettings.ImageSettings.ThumbnailWidth && bmp.Height > taskSettings.ImageSettings.ThumbnailHeight))) (bmp.Width > taskSettings.ImageSettings.ThumbnailWidth && bmp.Height > taskSettings.ImageSettings.ThumbnailHeight)))
{ {
string thumbnailFileName = Path.GetFileNameWithoutExtension(filename) + taskSettings.ImageSettings.ThumbnailName + ".jpg"; string thumbnailFileName = Path.GetFileNameWithoutExtension(fileName) + taskSettings.ImageSettings.ThumbnailName + ".jpg";
string thumbnailFilePath = HandleExistsFile(folder, thumbnailFileName, taskSettings); string thumbnailFilePath = HandleExistsFile(folder, thumbnailFileName, taskSettings);
if (!string.IsNullOrEmpty(thumbnailFilePath)) if (!string.IsNullOrEmpty(thumbnailFilePath))
@ -370,7 +370,7 @@ public static void SaveImageAsFile(Bitmap bmp, TaskSettings taskSettings, bool o
using (ImageData imageData = PrepareImage(bmp, taskSettings)) using (ImageData imageData = PrepareImage(bmp, taskSettings))
{ {
string screenshotsFolder = GetScreenshotsFolder(taskSettings); string screenshotsFolder = GetScreenshotsFolder(taskSettings);
string fileName = GetFilename(taskSettings, imageData.ImageFormat.GetDescription(), bmp); string fileName = GetFileName(taskSettings, imageData.ImageFormat.GetDescription(), bmp);
string filePath = Path.Combine(screenshotsFolder, fileName); string filePath = Path.Combine(screenshotsFolder, fileName);
if (!overwriteFile) if (!overwriteFile)
@ -386,15 +386,15 @@ public static void SaveImageAsFile(Bitmap bmp, TaskSettings taskSettings, bool o
} }
} }
public static string GetFilename(TaskSettings taskSettings, string extension, Bitmap bmp) public static string GetFileName(TaskSettings taskSettings, string extension, Bitmap bmp)
{ {
TaskMetadata metadata = new TaskMetadata(bmp); TaskMetadata metadata = new TaskMetadata(bmp);
return GetFilename(taskSettings, extension, metadata); return GetFileName(taskSettings, extension, metadata);
} }
public static string GetFilename(TaskSettings taskSettings, string extension = null, TaskMetadata metadata = null) public static string GetFileName(TaskSettings taskSettings, string extension = null, TaskMetadata metadata = null)
{ {
string filename; string fileName;
NameParser nameParser = new NameParser(NameParserType.FileName) NameParser nameParser = new NameParser(NameParserType.FileName)
{ {
@ -418,21 +418,21 @@ public static string GetFilename(TaskSettings taskSettings, string extension = n
if (!string.IsNullOrEmpty(taskSettings.UploadSettings.NameFormatPatternActiveWindow) && !string.IsNullOrEmpty(nameParser.WindowText)) if (!string.IsNullOrEmpty(taskSettings.UploadSettings.NameFormatPatternActiveWindow) && !string.IsNullOrEmpty(nameParser.WindowText))
{ {
filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPatternActiveWindow); fileName = nameParser.Parse(taskSettings.UploadSettings.NameFormatPatternActiveWindow);
} }
else else
{ {
filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPattern); fileName = nameParser.Parse(taskSettings.UploadSettings.NameFormatPattern);
} }
Program.Settings.NameParserAutoIncrementNumber = nameParser.AutoIncrementNumber; Program.Settings.NameParserAutoIncrementNumber = nameParser.AutoIncrementNumber;
if (!string.IsNullOrEmpty(extension)) if (!string.IsNullOrEmpty(extension))
{ {
filename += "." + extension.TrimStart('.'); fileName += "." + extension.TrimStart('.');
} }
return filename; return fileName;
} }
public static string GetScreenshotsFolder(TaskSettings taskSettings = null, TaskMetadata metadata = null) public static string GetScreenshotsFolder(TaskSettings taskSettings = null, TaskMetadata metadata = null)
@ -596,9 +596,9 @@ private static void AddExternalProgramFromRegistry(TaskSettings taskSettings, st
} }
} }
public static string HandleExistsFile(string folder, string filename, TaskSettings taskSettings) public static string HandleExistsFile(string folder, string fileName, TaskSettings taskSettings)
{ {
string filepath = Path.Combine(folder, filename); string filepath = Path.Combine(folder, fileName);
return HandleExistsFile(filepath, taskSettings); return HandleExistsFile(filepath, taskSettings);
} }
@ -612,7 +612,7 @@ public static string HandleExistsFile(string filepath, TaskSettings taskSettings
using (FileExistForm form = new FileExistForm(filepath)) using (FileExistForm form = new FileExistForm(filepath))
{ {
form.ShowDialog(); form.ShowDialog();
filepath = form.Filepath; filepath = form.FilePath;
} }
break; break;
case FileExistAction.UniqueName: case FileExistAction.UniqueName:
@ -952,7 +952,7 @@ public static Bitmap AnnotateImage(Bitmap bmp, string filePath, TaskSettings tas
if (string.IsNullOrEmpty(newFilePath)) if (string.IsNullOrEmpty(newFilePath))
{ {
string screenshotsFolder = GetScreenshotsFolder(taskSettings); string screenshotsFolder = GetScreenshotsFolder(taskSettings);
string fileName = GetFilename(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output); string fileName = GetFileName(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output);
newFilePath = Path.Combine(screenshotsFolder, fileName); newFilePath = Path.Combine(screenshotsFolder, fileName);
} }
@ -969,7 +969,7 @@ public static Bitmap AnnotateImage(Bitmap bmp, string filePath, TaskSettings tas
if (string.IsNullOrEmpty(newFilePath)) if (string.IsNullOrEmpty(newFilePath))
{ {
string screenshotsFolder = GetScreenshotsFolder(taskSettings); string screenshotsFolder = GetScreenshotsFolder(taskSettings);
string fileName = GetFilename(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output); string fileName = GetFileName(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output);
newFilePath = Path.Combine(screenshotsFolder, fileName); newFilePath = Path.Combine(screenshotsFolder, fileName);
} }

View file

@ -449,13 +449,13 @@ public static void UploadText(string text, TaskSettings taskSettings = null, boo
} }
} }
public static void UploadImageStream(Stream stream, string filename, TaskSettings taskSettings = null) public static void UploadImageStream(Stream stream, string fileName, TaskSettings taskSettings = null)
{ {
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings(); if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
if (stream != null && stream.Length > 0 && !string.IsNullOrEmpty(filename)) if (stream != null && stream.Length > 0 && !string.IsNullOrEmpty(fileName))
{ {
WorkerTask task = WorkerTask.CreateDataUploaderTask(EDataType.Image, stream, filename, taskSettings); WorkerTask task = WorkerTask.CreateDataUploaderTask(EDataType.Image, stream, fileName, taskSettings);
TaskManager.Start(task); TaskManager.Start(task);
} }
} }

View file

@ -107,8 +107,8 @@ public static WorkerTask CreateFileUploaderTask(string filePath, TaskSettings ta
if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern) if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern)
{ {
string ext = Helpers.GetFilenameExtension(task.Info.FilePath); string ext = Helpers.GetFileNameExtension(task.Info.FilePath);
task.Info.FileName = TaskHelpers.GetFilename(task.Info.TaskSettings, ext); task.Info.FileName = TaskHelpers.GetFileName(task.Info.TaskSettings, ext);
} }
if (task.Info.TaskSettings.AdvancedSettings.ProcessImagesDuringFileUpload && task.Info.DataType == EDataType.Image) if (task.Info.TaskSettings.AdvancedSettings.ProcessImagesDuringFileUpload && task.Info.DataType == EDataType.Image)
@ -141,7 +141,7 @@ public static WorkerTask CreateImageUploaderTask(TaskMetadata metadata, TaskSett
} }
else else
{ {
task.Info.FileName = TaskHelpers.GetFilename(taskSettings, "bmp", metadata); task.Info.FileName = TaskHelpers.GetFileName(taskSettings, "bmp", metadata);
} }
task.Info.Metadata = metadata; task.Info.Metadata = metadata;
@ -154,7 +154,7 @@ public static WorkerTask CreateTextUploaderTask(string text, TaskSettings taskSe
WorkerTask task = new WorkerTask(taskSettings); WorkerTask task = new WorkerTask(taskSettings);
task.Info.Job = TaskJob.TextUpload; task.Info.Job = TaskJob.TextUpload;
task.Info.DataType = EDataType.Text; task.Info.DataType = EDataType.Text;
task.Info.FileName = TaskHelpers.GetFilename(taskSettings, taskSettings.AdvancedSettings.TextFileExtension); task.Info.FileName = TaskHelpers.GetFileName(taskSettings, taskSettings.AdvancedSettings.TextFileExtension);
task.Text = text; task.Text = text;
return task; return task;
} }
@ -187,13 +187,13 @@ public static WorkerTask CreateFileJobTask(string filePath, TaskMetadata metadat
if (!string.IsNullOrEmpty(customFileName)) if (!string.IsNullOrEmpty(customFileName))
{ {
string ext = Helpers.GetFilenameExtension(task.Info.FilePath); string ext = Helpers.GetFileNameExtension(task.Info.FilePath);
task.Info.FileName = Helpers.AppendExtension(customFileName, ext); task.Info.FileName = Helpers.AppendExtension(customFileName, ext);
} }
else if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern) else if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern)
{ {
string ext = Helpers.GetFilenameExtension(task.Info.FilePath); string ext = Helpers.GetFileNameExtension(task.Info.FilePath);
task.Info.FileName = TaskHelpers.GetFilename(task.Info.TaskSettings, ext); task.Info.FileName = TaskHelpers.GetFileName(task.Info.TaskSettings, ext);
} }
task.Info.Metadata = metadata; task.Info.Metadata = metadata;
@ -212,22 +212,22 @@ public static WorkerTask CreateDownloadTask(string url, bool upload, TaskSetting
WorkerTask task = new WorkerTask(taskSettings); WorkerTask task = new WorkerTask(taskSettings);
task.Info.Job = upload ? TaskJob.DownloadUpload : TaskJob.Download; task.Info.Job = upload ? TaskJob.DownloadUpload : TaskJob.Download;
string filename = URLHelpers.URLDecode(url, 10); string fileName = URLHelpers.URLDecode(url, 10);
filename = URLHelpers.GetFileName(filename); fileName = URLHelpers.GetFileName(fileName);
filename = Helpers.GetValidFileName(filename); fileName = Helpers.GetValidFileName(fileName);
if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern) if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern)
{ {
string ext = Helpers.GetFilenameExtension(filename); string ext = Helpers.GetFileNameExtension(fileName);
filename = TaskHelpers.GetFilename(task.Info.TaskSettings, ext); fileName = TaskHelpers.GetFileName(task.Info.TaskSettings, ext);
} }
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(fileName))
{ {
return null; return null;
} }
task.Info.FileName = filename; task.Info.FileName = fileName;
task.Info.DataType = TaskHelpers.FindDataType(task.Info.FileName, taskSettings); task.Info.DataType = TaskHelpers.FindDataType(task.Info.FileName, taskSettings);
task.Info.Result.URL = url; task.Info.Result.URL = url;
return task; return task;
@ -443,7 +443,7 @@ private void DoUploadJob()
} }
} }
private bool DoUpload(Stream data, string filename, int retry = 0) private bool DoUpload(Stream data, string fileName, int retry = 0)
{ {
bool isError = false; bool isError = false;
@ -472,18 +472,18 @@ private bool DoUpload(Stream data, string filename, int retry = 0)
sslBypassHelper = new SSLBypassHelper(); sslBypassHelper = new SSLBypassHelper();
} }
if (!CheckUploadFilters(data, filename)) if (!CheckUploadFilters(data, fileName))
{ {
switch (Info.UploadDestination) switch (Info.UploadDestination)
{ {
case EDataType.Image: case EDataType.Image:
Info.Result = UploadImage(data, filename); Info.Result = UploadImage(data, fileName);
break; break;
case EDataType.Text: case EDataType.Text:
Info.Result = UploadText(data, filename); Info.Result = UploadText(data, fileName);
break; break;
case EDataType.File: case EDataType.File:
Info.Result = UploadFile(data, filename); Info.Result = UploadFile(data, fileName);
break; break;
} }
} }
@ -689,20 +689,20 @@ private bool DoAfterCaptureJobs()
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile)) if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
{ {
string thumbnailFilename, thumbnailFolder; string thumbnailFileName, thumbnailFolder;
if (!string.IsNullOrEmpty(Info.FilePath)) if (!string.IsNullOrEmpty(Info.FilePath))
{ {
thumbnailFilename = Path.GetFileName(Info.FilePath); thumbnailFileName = Path.GetFileName(Info.FilePath);
thumbnailFolder = Path.GetDirectoryName(Info.FilePath); thumbnailFolder = Path.GetDirectoryName(Info.FilePath);
} }
else else
{ {
thumbnailFilename = Info.FileName; thumbnailFileName = Info.FileName;
thumbnailFolder = TaskHelpers.GetScreenshotsFolder(Info.TaskSettings, Info.Metadata); thumbnailFolder = TaskHelpers.GetScreenshotsFolder(Info.TaskSettings, Info.Metadata);
} }
Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(Image, thumbnailFolder, thumbnailFilename, Info.TaskSettings); Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(Image, thumbnailFolder, thumbnailFileName, Info.TaskSettings);
if (!string.IsNullOrEmpty(Info.ThumbnailFilePath)) if (!string.IsNullOrEmpty(Info.ThumbnailFilePath))
{ {
@ -747,8 +747,8 @@ private void DoFileJobs()
if (isFileModified) if (isFileModified)
{ {
string extension = Helpers.GetFilenameExtension(Info.FilePath); string extension = Helpers.GetFileNameExtension(Info.FilePath);
Info.FileName = Helpers.ChangeFilenameExtension(fileName, extension); Info.FileName = Helpers.ChangeFileNameExtension(fileName, extension);
LoadFileStream(); LoadFileStream();
} }
@ -927,11 +927,11 @@ public UploadResult UploadData(IGenericUploaderService service, Stream stream, s
return null; return null;
} }
private bool CheckUploadFilters(Stream stream, string filename) private bool CheckUploadFilters(Stream stream, string fileName)
{ {
if (Info.TaskSettings.UploadSettings.UploaderFilters != null && !string.IsNullOrEmpty(filename) && stream != null) if (Info.TaskSettings.UploadSettings.UploaderFilters != null && !string.IsNullOrEmpty(fileName) && stream != null)
{ {
UploaderFilter filter = Info.TaskSettings.UploadSettings.UploaderFilters.FirstOrDefault(x => x.IsValidFilter(filename)); UploaderFilter filter = Info.TaskSettings.UploadSettings.UploaderFilters.FirstOrDefault(x => x.IsValidFilter(fileName));
if (filter != null) if (filter != null)
{ {
@ -939,7 +939,7 @@ private bool CheckUploadFilters(Stream stream, string filename)
if (service != null) if (service != null)
{ {
Info.Result = UploadData(service, stream, filename); Info.Result = UploadData(service, stream, fileName);
return true; return true;
} }