diff --git a/Apewer/Internals/NtfsUnlocker.cs b/Apewer/Internals/NtfsUnlocker.cs
index 3f3e5f0..58a0f27 100644
--- a/Apewer/Internals/NtfsUnlocker.cs
+++ b/Apewer/Internals/NtfsUnlocker.cs
@@ -26,30 +26,38 @@ namespace Apewer.Internals
public const string Postfix = ":Zone.Identifier";
- public static bool FileExists(string path) => GetFileAttributes(path) != -1;
-
- public static string DeleteZoneIdentifier(string path)
+ /// 获取标记的路径。
+ public static string GetZoneIdentifier(string path)
{
- if (!FileExists(path)) return "文件不存在。";
+ if (!File.Exists(path)) return null;
try
{
var info = new FileInfo(path);
- var streamPath = info.FullName + Postfix;
-
- var streamExists = FileExists(streamPath);
- if (!streamExists) return null;
-
- var deleted = DeleteFile(streamPath);
- if (!deleted) return $"未能删除 {streamPath}。";
- return null;
+ var zoneIdentifier = info.FullName + Postfix;
+ return zoneIdentifier;
}
- catch (Exception ex)
+ catch
{
- return ex.Message;
+ return null;
}
}
+ /// 检查标记是否存在。
+ public static bool ZoneIdentifierExists(string zoneIdentifier)
+ {
+ var attributes = GetFileAttributes(zoneIdentifier);
+ var exists = attributes != -1;
+ return exists;
+ }
+
+ /// 删除标记。
+ public static bool DeleteZoneIdentifier(string zoneIdentifier)
+ {
+ var deleted = DeleteFile(zoneIdentifier);
+ return deleted;
+ }
+
}
}
diff --git a/Apewer/StorageUtility.cs b/Apewer/StorageUtility.cs
index 710de58..63d0b42 100644
--- a/Apewer/StorageUtility.cs
+++ b/Apewer/StorageUtility.cs
@@ -23,19 +23,14 @@ namespace Apewer
#region NTFS 流
- /// 搜索文件是否在 NTFS 流中附带了锁定标记。
- /// 此方法仅支持 Windows 系统。
- public static bool HasZoneIdentifier(string path)
- {
- var info = new FileInfo(path);
- var streamPath = info.FullName + NtfsUnlocker.Postfix;
- var streamExists = NtfsUnlocker.FileExists(streamPath);
- return streamExists;
- }
+ /// 获取标记的路径。
+ public static string GetZoneIdentifier(string path) => NtfsUnlocker.GetZoneIdentifier(path);
+
+ /// 检查标记是否存在。
+ public static bool ZoneIdentifierExists(string zoneIdentifier) => NtfsUnlocker.ZoneIdentifierExists(zoneIdentifier);
- /// 解锁下载的文件。
- /// 此方法仅支持 Windows 系统。
- public static string DeleteZoneIdentifier(string path) => NtfsUnlocker.DeleteZoneIdentifier(path);
+ /// 删除标记。
+ public static bool DeleteZoneIdentifier(string zoneIdentifier) => NtfsUnlocker.DeleteZoneIdentifier(zoneIdentifier);
#endregion
diff --git a/Apewer/Web/StaticController.cs b/Apewer/Web/StaticController.cs
index 1b0068c..b419816 100644
--- a/Apewer/Web/StaticController.cs
+++ b/Apewer/Web/StaticController.cs
@@ -631,3 +631,4 @@ namespace Apewer.Web
}
}
+;
\ No newline at end of file