wasSharp – Diff between revs 27 and 28

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 27 Rev 28
Line 13... Line 13...
13   13  
14 namespace wasSharp 14 namespace wasSharp
15 { 15 {
16 public static class IO 16 public static class IO
17 { -  
18 /////////////////////////////////////////////////////////////////////////// -  
19 // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // -  
20 /////////////////////////////////////////////////////////////////////////// -  
21 /// <summary> -  
22 /// Combine multiple paths. -  
23 /// </summary> -  
24 /// <param name="paths">an array of paths</param> -  
25 /// <returns>a combined path</returns> -  
26 public static string PathCombine(string separator = @"\", params string[] paths) -  
27 { -  
28 return string.Join(separator, paths); -  
29 } -  
30   17 {
31 /// <summary> 18 /// <summary>
32 /// Strip characters that are incompatible with file names. 19 /// Strip characters that are incompatible with file names.
33 /// </summary> 20 /// </summary>
34 /// <param name="fileName">the name of the file</param> 21 /// <param name="fileName">the name of the file</param>
Line 130... Line 117...
130 /// </summary> 117 /// </summary>
131 /// <param name="path">the path to split</param> 118 /// <param name="path">the path to split</param>
132 /// <param name="separator">the separator character</param> 119 /// <param name="separator">the separator character</param>
133 /// <param name="escape">the escape character</param> 120 /// <param name="escape">the escape character</param>
134 /// <returns>path parts</returns> 121 /// <returns>path parts</returns>
135 public static IEnumerable<string> PathSplit(this string path, char separator, char? escape) 122 public static IEnumerable<string> PathSplit(this string path, char separator, char? escape = null)
136 { 123 {
137 var s = new Stack<char>(); 124 var s = new Stack<char>();
138 var p = new StringBuilder(); 125 var p = new StringBuilder();
139 foreach (var c in path) 126 foreach (var c in path)
140 { 127 {
Line 145... Line 132...
145 } 132 }
146 if (c == separator) 133 if (c == separator)
147 { 134 {
148 if (s.Count.Equals(0) || !s.Peek().Equals(escape)) 135 if (s.Count.Equals(0) || !s.Peek().Equals(escape))
149 { 136 {
-   137 if (p.Length.Equals(0))
-   138 {
-   139 p.Append(c);
-   140 continue;
-   141 }
150 yield return p.ToString(); 142 yield return p.ToString();
151 p = new StringBuilder(); 143 p = new StringBuilder();
152 continue; 144 continue;
153 } 145 }
154 s.Pop(); 146 s.Pop();