mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-14 20:29:07 +00:00
Included epub library in plugin project
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace VersOne.Epub.Internal
|
||||
{
|
||||
internal static class XmlUtils
|
||||
{
|
||||
public static async Task<XDocument> LoadDocumentAsync(Stream stream)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
await stream.CopyToAsync(memoryStream).ConfigureAwait(false);
|
||||
memoryStream.Position = 0;
|
||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
|
||||
{
|
||||
DtdProcessing = DtdProcessing.Ignore,
|
||||
Async = true
|
||||
};
|
||||
using (XmlReader xmlReader = XmlReader.Create(memoryStream, xmlReaderSettings))
|
||||
{
|
||||
return await Task.Run(() => XDocument.Load(memoryStream)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace VersOne.Epub.Internal
|
||||
{
|
||||
internal static class ZipPathUtils
|
||||
{
|
||||
public static string GetDirectoryPath(string filePath)
|
||||
{
|
||||
int lastSlashIndex = filePath.LastIndexOf('/');
|
||||
if (lastSlashIndex == -1)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return filePath.Substring(0, lastSlashIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Combine(string directory, string fileName)
|
||||
{
|
||||
if (String.IsNullOrEmpty(directory))
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Concat(directory, "/", fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user