Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
60 lines (49 loc) · 2.15 KB

File metadata and controls

60 lines (49 loc) · 2.15 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
namespace SixLabors.Samples;
/// <summary>
/// Provides shared input and output path helpers for sample projects.
/// </summary>
internal static partial class SamplePaths
{
private const string SolutionFileName = "SixLabors.Samples.slnx";
/// <summary>
/// Gets the repository root used for shared sample output.
/// </summary>
public static string RepositoryDirectory { get; } = FindRepositoryDirectory();
/// <summary>
/// Gets the directory containing sample assets for the current project.
/// </summary>
public static string AssetDirectory { get; } = Path.Combine(AppContext.BaseDirectory, "assets", AssetFolderName);
/// <summary>
/// Gets the directory where the current project writes generated output.
/// </summary>
public static string OutputDirectory { get; } = Path.Combine(RepositoryDirectory, "output", OutputFolderName);
/// <summary>
/// Gets the full path to one sample asset.
/// </summary>
/// <param name="fileName">The asset file name.</param>
/// <returns>The full path to the sample asset.</returns>
public static string Asset(string fileName) => Path.Combine(AssetDirectory, fileName);
/// <summary>
/// Gets the full path for one generated output file.
/// </summary>
/// <param name="fileName">The output file name.</param>
/// <returns>The full output path.</returns>
public static string Output(string fileName) => Path.Combine(OutputDirectory, fileName);
private static string FindRepositoryDirectory()
{
DirectoryInfo? directory = new(AppContext.BaseDirectory);
while (directory is not null)
{
// Build output lives under artifacts/bin, so walk upward until the solution file
// identifies the sample repository root rather than relying on the launch directory.
if (File.Exists(Path.Combine(directory.FullName, SolutionFileName)))
{
return directory.FullName;
}
directory = directory.Parent;
}
return Directory.GetCurrentDirectory();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.