Przeglądaj źródła

ref: 使用 DirectoryUtils.Create

龙腾猫跃 6 miesięcy temu
rodzic
commit
08b17e71bb
2 zmienionych plików z 4 dodań i 4 usunięć
  1. 2 2
      General/DirectoryUtils.cs
  2. 2 2
      General/MsDelta.cs

+ 2 - 2
General/DirectoryUtils.cs

@@ -23,8 +23,8 @@ namespace MeloongCore {
         /// 创建文件夹,或文件所在的文件夹。
         /// 创建文件夹,或文件所在的文件夹。
         /// 支持长路径,文件夹已存在时不会抛出异常。
         /// 支持长路径,文件夹已存在时不会抛出异常。
         /// </summary>
         /// </summary>
-        public static void Create(string path) {
-            if (!IsDirectoryFormat(path)) path = Path.GetDirectoryName(path);
+        public static void Create(string path, bool isFilePath = false) {
+            if (isFilePath) path = Path.GetDirectoryName(path);
             Directory.CreateDirectory(PathUtils.Shorten(path));
             Directory.CreateDirectory(PathUtils.Shorten(path));
         }
         }
 
 

+ 2 - 2
General/MsDelta.cs

@@ -18,7 +18,7 @@ namespace MeloongCore {
         public static void Create(string oldFilePath, string newFilePath, string deltaFilePath) {
         public static void Create(string oldFilePath, string newFilePath, string deltaFilePath) {
             if (!File.Exists(oldFilePath)) throw new FileNotFoundException($"旧文件不存在:{oldFilePath}", oldFilePath);
             if (!File.Exists(oldFilePath)) throw new FileNotFoundException($"旧文件不存在:{oldFilePath}", oldFilePath);
             if (!File.Exists(newFilePath)) throw new FileNotFoundException($"新文件不存在:{newFilePath}", newFilePath);
             if (!File.Exists(newFilePath)) throw new FileNotFoundException($"新文件不存在:{newFilePath}", newFilePath);
-            DirectoryUtils.Create(deltaFilePath);
+            DirectoryUtils.Create(deltaFilePath, isFilePath: true);
             // fileTypeSet:https://learn.microsoft.com/en-us/previous-versions/bb417345(v=msdn.10)?redirectedfrom=MSDN#file-type-sets (15L: DELTA_FILE_TYPE_SET_EXECUTABLES)
             // fileTypeSet:https://learn.microsoft.com/en-us/previous-versions/bb417345(v=msdn.10)?redirectedfrom=MSDN#file-type-sets (15L: DELTA_FILE_TYPE_SET_EXECUTABLES)
             // 131072L: IgnoreFileSizeLimit, 32u: Crc32
             // 131072L: IgnoreFileSizeLimit, 32u: Crc32
             if (!CreateDelta(15L, 131072L, 0L, 
             if (!CreateDelta(15L, 131072L, 0L, 
@@ -34,7 +34,7 @@ namespace MeloongCore {
         public static void Apply(string oldFilePath, string deltaFilePath, string newFilePath) {
         public static void Apply(string oldFilePath, string deltaFilePath, string newFilePath) {
             if (!File.Exists(oldFilePath)) throw new FileNotFoundException($"旧文件不存在:{oldFilePath}", oldFilePath);
             if (!File.Exists(oldFilePath)) throw new FileNotFoundException($"旧文件不存在:{oldFilePath}", oldFilePath);
             if (!File.Exists(deltaFilePath)) throw new FileNotFoundException($"补丁文件不存在:{deltaFilePath}", deltaFilePath);
             if (!File.Exists(deltaFilePath)) throw new FileNotFoundException($"补丁文件不存在:{deltaFilePath}", deltaFilePath);
-            DirectoryUtils.Create(newFilePath);
+            DirectoryUtils.Create(newFilePath, isFilePath: true);
             // 1L: AllowLegacy
             // 1L: AllowLegacy
             if (!ApplyDelta(1L, PathUtils.Shorten(oldFilePath), PathUtils.Shorten(deltaFilePath), PathUtils.Shorten(newFilePath)))
             if (!ApplyDelta(1L, PathUtils.Shorten(oldFilePath), PathUtils.Shorten(deltaFilePath), PathUtils.Shorten(newFilePath)))
                 throw new Win32Exception();
                 throw new Win32Exception();