Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Dahlby <dahlbyk@gmail.com>2013-06-13 00:40:03 +0400
committernulltoken <emeric.fermas@gmail.com>2013-06-17 10:08:42 +0400
commit7b8472d0afefb06b3668061f35baa619054e2637 (patch)
treea335f99fce03d13dfc4b38ed9b8a2f1e7330e06a /LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
parent39716ec93b7be33e2c8c5117124d352a68ae6c69 (diff)
Touch() should ensure parent directory exists
Diffstat (limited to 'LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs')
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs13
1 files changed, 6 insertions, 7 deletions
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index 1c17c77c..eb9c2905 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -213,14 +214,12 @@ namespace LibGit2Sharp.Tests.TestHelpers
protected string Touch(string parent, string file, string content = null)
{
- var lastIndex = file.LastIndexOf('/');
- if (lastIndex > 0)
- {
- var parents = file.Substring(0, lastIndex);
- Directory.CreateDirectory(Path.Combine(parent, parents));
- }
+ string filePath = Path.Combine(parent, file);
+ string dir = Path.GetDirectoryName(filePath);
+ Debug.Assert(dir != null);
+
+ Directory.CreateDirectory(dir);
- var filePath = Path.Combine(parent, file);
File.AppendAllText(filePath, content ?? string.Empty, Encoding.ASCII);
return file;