12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- namespace CommonMPQ.SharpZipLib.Core
- {
-
-
-
- public abstract class WindowsPathUtils
- {
-
-
-
- internal WindowsPathUtils()
- {
- }
-
-
-
-
-
-
-
- public static string DropPathRoot(string path)
- {
- string result = path;
-
- if ( (path != null) && (path.Length > 0) ) {
- if ((path[0] == '\\') || (path[0] == '/')) {
-
- if ((path.Length > 1) && ((path[1] == '\\') || (path[1] == '/'))) {
- int index = 2;
- int elements = 2;
-
- while ((index <= path.Length) &&
- (((path[index] != '\\') && (path[index] != '/')) || (--elements > 0))) {
- index++;
- }
- index++;
- if (index < path.Length) {
- result = path.Substring(index);
- }
- else {
- result = "";
- }
- }
- }
- else if ((path.Length > 1) && (path[1] == ':')) {
- int dropCount = 2;
- if ((path.Length > 2) && ((path[2] == '\\') || (path[2] == '/'))) {
- dropCount = 3;
- }
- result = result.Remove(0, dropCount);
- }
- }
- return result;
- }
- }
- }
|