|
|
@ -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) |
|
|
|
/// <summary>获取标记的路径。</summary>
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>检查标记是否存在。</summary>
|
|
|
|
public static bool ZoneIdentifierExists(string zoneIdentifier) |
|
|
|
{ |
|
|
|
var attributes = GetFileAttributes(zoneIdentifier); |
|
|
|
var exists = attributes != -1; |
|
|
|
return exists; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>删除标记。</summary>
|
|
|
|
public static bool DeleteZoneIdentifier(string zoneIdentifier) |
|
|
|
{ |
|
|
|
var deleted = DeleteFile(zoneIdentifier); |
|
|
|
return deleted; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|