forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPathUtil.cs
29 lines (27 loc) · 863 Bytes
/
PathUtil.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace GitCommands
{
class PathUtil
{
/// <summary>
/// Code guideline: "A directory path should always end with / or \.
/// Better use Path.Combine instead of Setting.PathSeparator"
///
/// This method can be used to add (or keep) a trailing path separator character to a directory path.
/// </summary>
/// <param name="dirPath"></param>
/// <returns></returns>
public static string EnsureTrailingPathSeparator(string dirPath)
{
if (!dirPath.IsNullOrEmpty() && !dirPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
dirPath += Path.DirectorySeparatorChar;
}
return dirPath;
}
}
}