-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
There was a problem hiding this 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!
TruePath/Temporary.cs
Outdated
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
b32239f
to
feea9ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Closes #76