Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Sep 20, 2023
1 parent a894f29 commit 5fe81a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
32 changes: 18 additions & 14 deletions src/EmptyFiles/AllFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,28 @@ static AllFiles()

internal static string FindEmptyFilesDirectory()
{
var currentDomainEmptyFiles = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmptyFiles");
if (Directory.Exists(currentDomainEmptyFiles))
var directories = FindDirectories()
.Select(_ => Path.Combine(_, "EmptyFiles"))
.ToList();
foreach (var directory in directories)
{
return currentDomainEmptyFiles;
}

var codebaseEmptyFiles = Path.Combine(AssemblyLocation.CurrentDirectory, "EmptyFiles");
if (Directory.Exists(codebaseEmptyFiles))
{
return codebaseEmptyFiles;
if (Directory.Exists(directory))
{
return directory;
}
}

throw new($"""
Could not find empty files directory. Searched:
* {currentDomainEmptyFiles}
* {codebaseEmptyFiles}
throw new(
$"""
Could not find empty files directory. Searched:
{string.Join(Environment.NewLine, directories)}
""");
}

""");
static IEnumerable<string> FindDirectories()
{
yield return AppDomain.CurrentDomain.BaseDirectory;
yield return AssemblyLocation.Directory;
yield return Environment.CurrentDirectory;
}

Expand Down
4 changes: 2 additions & 2 deletions src/EmptyFiles/AssemblyLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ static AssemblyLocation()
var path = Uri.UnescapeDataString(uri.Path);
#endif

CurrentDirectory = Path.GetDirectoryName(path)!;
Directory = Path.GetDirectoryName(path)!;
}

public static string CurrentDirectory;
public static string Directory;
}

0 comments on commit 5fe81a6

Please sign in to comment.