-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use TemporaryFile for downloaded files.
- Loading branch information
Showing
9 changed files
with
68 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,39 @@ | |||
using System; | |||
using System.Diagnostics; | |||
using System.IO; | |||
|
|||
namespace Sep.Git.Tfs.Util | |||
{ | |||
public class TemporaryFile : IDisposable | |||
{ | |||
public TemporaryFile() : this(System.IO.Path.GetTempFileName()) | |||
{ | |||
} | |||
|
|||
public TemporaryFile(string path) | |||
{ | |||
Path = path; | |||
} | |||
|
|||
public string Path { get; private set; } | |||
|
|||
public static implicit operator string(TemporaryFile f) | |||
{ | |||
return f.Path; | |||
} | |||
|
|||
public void Dispose() | |||
{ | |||
try | |||
{ | |||
if (Path != null && File.Exists(Path)) | |||
File.Delete(Path); | |||
Path = null; | |||
} | |||
catch (Exception e) | |||
{ | |||
Trace.WriteLine("[TemporaryFile] Unable to remove " + Path + ": " + e); | |||
} | |||
} | |||
} | |||
} |