Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to get a system temp dir, create temp file and folder #79

Merged
merged 3 commits into from
Aug 11, 2024

Conversation

Illusion4
Copy link
Contributor

@Illusion4 Illusion4 commented Jul 19, 2024

Closes #76

@ForNeVeR ForNeVeR self-assigned this Jul 19, 2024
@ForNeVeR ForNeVeR self-requested a review July 19, 2024 15:47
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a minor issue, good to go!

Comment on lines 19 to 40
var tempPath = Path.GetTempPath();
return new AbsolutePath(tempPath);
}

/// <summary>
/// Creates a temporary file.
/// </summary>
/// <returns>An AbsolutePath representing the newly created temporary file.</returns>
public static AbsolutePath CreateTempFile()
{
var tempPath = Path.GetTempFileName();
return new AbsolutePath(tempPath);
}

/// <summary>
/// Creates a temporary folder with the specified prefix.
/// </summary>
/// <param name="prefix">An optional string to add to the beginning of the subdirectory name.</param>
/// <returns>An AbsolutePath representing newly created temporary folder</returns>
public static AbsolutePath CreateTempFolder(string? prefix = null)
{
var tempDirectoryInfo = Directory.CreateTempSubdirectory(prefix);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, any of these calls might return a relative path, so I'd suggest using AbsolutePath.CurrentWorkingDirectory / tempPath in all three cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified

@ForNeVeR ForNeVeR assigned Illusion4 and ForNeVeR and unassigned ForNeVeR and Illusion4 Jul 21, 2024
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ForNeVeR ForNeVeR merged commit feea9ca into ForNeVeR:main Aug 11, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Methods to get a system temp directory, create temp file, create temp folder
2 participants