Selaa lähdekoodia

Added method RemotePath.EscapeOperationMask to .NET assembly.

Source commit: fc47b7abc1174fb7cce7df1d3ce75a7bdee44aa3
Martin Prikryl 4 vuotta sitten
vanhempi
sitoutus
5d67fa58b7
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13 0
      dotnet/RemotePath.cs

+ 13 - 0
dotnet/RemotePath.cs

@@ -24,6 +24,19 @@ namespace WinSCP
             return path + mask;
         }
 
+        public static string EscapeOperationMask(string operationMask)
+        {
+            if (operationMask == null)
+            {
+                throw new ArgumentNullException(nameof(operationMask));
+            }
+            int lastSlash = operationMask.LastIndexOf('/');
+            string path = lastSlash > 0 ? operationMask.Substring(0, lastSlash + 1) : string.Empty;
+            string mask = lastSlash > 0 ? operationMask.Substring(lastSlash + 1) : operationMask;
+            mask = mask.Replace("\\", "\\\\").Replace("*", "\\*").Replace("?", "\\?");
+            return path + mask;
+        }
+
         [Obsolete("Use RemotePath.Combine method")]
         public static string CombinePaths(string path1, string path2)
         {