Skip to content

Commit

Permalink
Change paths
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Jun 24, 2021
1 parent ec54c14 commit 74d5a5c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# http://EditorConfig.org

root = true

[*]
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true

[*.cs]
indent_style = space
indent_size = 4

[*.xml]
indent_style = space
indent_size = 2

[*.config]
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions src/BingImageDownload.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{3A0CE9
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BingImageDownload", "BingImageDownload\BingImageDownload.csproj", "{3497DF69-D5A9-4745-B422-4A15C29AAFC4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{23477B16-D905-4A36-98E5-A9F158491465}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
28 changes: 19 additions & 9 deletions src/BingImageDownload/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace BingImageDownload
{
internal class Paths
{
internal string BasePath { get; }
internal string SavePath { get; }
internal string ArchivePath { get; }
internal string AppData { get; }
Expand All @@ -16,22 +17,31 @@ internal Paths(string basePath)
{
if (string.IsNullOrWhiteSpace(basePath))
{
basePath = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX ? Environment.GetEnvironmentVariable("HOME") : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
var homeDir = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX ? Environment.GetEnvironmentVariable("HOME") : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");

if (string.IsNullOrWhiteSpace(basePath))
if (string.IsNullOrWhiteSpace(homeDir))
{
throw new NullReferenceException("No directory passed & unable to locate 'HOME' path");
}

basePath = Path.Combine(basePath, "BingImageDownload");
BasePath = Path.Combine(homeDir, "BingImageDownload");
}
else
{
BasePath = basePath;
}

SavePath = Path.Combine(BasePath, "Images"); ;
ArchivePath = Path.Combine(BasePath, "Archive");
AppData = Path.Combine(BasePath, "App_Data");
DownloadPath = Path.Combine(BasePath, "App_Data", "Temp");
HistogramPath = Path.Combine(BasePath, "App_Data", "TempHistogram");
LogPath = Path.Combine(BasePath, "Logs");

SavePath = basePath;
ArchivePath = Path.Combine(basePath, "Archive");
AppData = Path.Combine(basePath, "App_Data");
DownloadPath = Path.Combine(basePath, "App_Data", "Temp");
HistogramPath = Path.Combine(basePath, "App_Data", "TempHistogram");
LogPath = Path.Combine(basePath, "Logs");
if (!Directory.Exists(BasePath))
{
Directory.CreateDirectory(BasePath);
}

if (!Directory.Exists(SavePath))
{
Expand Down
2 changes: 1 addition & 1 deletion src/BingImageDownload/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"commandLineArgs": "-p \"F:\\Bing Wallpaper\" -a 1"
}
}
}
}

0 comments on commit 74d5a5c

Please sign in to comment.