├── RolerFileToolkit ├── Samples │ ├── FileToolkitSample.UWP │ │ ├── Assets │ │ │ ├── StoreLogo.png │ │ │ ├── SplashScreen.scale-200.png │ │ │ ├── LockScreenLogo.scale-200.png │ │ │ ├── Square150x150Logo.scale-200.png │ │ │ ├── Square44x44Logo.scale-200.png │ │ │ ├── Wide310x150Logo.scale-200.png │ │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── App.xaml │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── Default.rd.xml │ │ ├── MainPage.xaml │ │ ├── Package.appxmanifest │ │ ├── MainPage.xaml.cs │ │ ├── App.xaml.cs │ │ └── FileToolkitSample.UWP.csproj │ └── FileToolkitSample.WPF │ │ ├── App.config │ │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ │ ├── App.xaml.cs │ │ ├── App.xaml │ │ ├── MainWindow.xaml │ │ ├── MainWindow.xaml.cs │ │ └── FileToolkitSample.WPF.csproj ├── Roler.Toolkit.File.Epub │ ├── Entity │ │ ├── Ncx │ │ │ ├── NavInfo.cs │ │ │ ├── NavPointLabel.cs │ │ │ ├── NavPointContent.cs │ │ │ ├── Ncx.cs │ │ │ ├── NavMap.cs │ │ │ └── NavPoint.cs │ │ ├── Nav │ │ │ ├── NavSpan.cs │ │ │ ├── NavHead.cs │ │ │ ├── Nav.cs │ │ │ ├── NavA.cs │ │ │ ├── NavOl.cs │ │ │ ├── NavLi.cs │ │ │ └── NavElement.cs │ │ ├── Container.cs │ │ └── Opf │ │ │ ├── Manifest.cs │ │ │ ├── SpineItemRef.cs │ │ │ ├── LinkElement.cs │ │ │ ├── DcElement.cs │ │ │ ├── Spine.cs │ │ │ ├── ManifestItem.cs │ │ │ ├── Package.cs │ │ │ ├── MetaElement.cs │ │ │ └── Metadata.cs │ ├── Chapter.cs │ ├── ContentFile.cs │ ├── Define │ │ └── Const.cs │ ├── Helper │ │ └── PathHelper.cs │ ├── Structure.cs │ ├── Roler.Toolkit.File.Epub.csproj │ ├── ExtendMethod.cs │ ├── Epub.cs │ ├── Engine │ │ ├── ContainerEngine.cs │ │ ├── NcxEngine.cs │ │ ├── NavEngine.cs │ │ └── OpfEngine.cs │ └── EpubReader.cs ├── Roler.Toolkit.File.Mobi │ ├── Entity │ │ ├── IndxHeader │ │ │ ├── IndexType.cs │ │ │ └── IndxHeader.cs │ │ ├── MobiHeader │ │ │ ├── TextEncoding.cs │ │ │ ├── MobiType.cs │ │ │ └── MobiHeader.cs │ │ ├── AudiRecord.cs │ │ ├── VideRecord.cs │ │ ├── PalmDOCHeader │ │ │ ├── EncryptionType.cs │ │ │ ├── CompressionType.cs │ │ │ └── PalmDOCHeader.cs │ │ ├── PalmDB │ │ │ ├── PalmDBRecordAttribute.cs │ │ │ ├── PalmDBRecordInfo.cs │ │ │ ├── PalmDBAttribute.cs │ │ │ └── PalmDB.cs │ │ ├── CmetRecord.cs │ │ ├── ExthHeader │ │ │ ├── ExthHeader.cs │ │ │ ├── ExthRecord.cs │ │ │ └── ExthRecordType.cs │ │ ├── SrcsRecord.cs │ │ ├── FlisRecord.cs │ │ └── FcisRecord.cs │ ├── Compression │ │ ├── ICompression.cs │ │ ├── NoneCompression.cs │ │ ├── BitReader.cs │ │ ├── PalmDocCompression.cs │ │ └── HuffCdicCompression.cs │ ├── Define │ │ └── Const.cs │ ├── PalmDBRecord.cs │ ├── ContentFile.cs │ ├── Roler.Toolkit.File.Mobi.csproj │ ├── Structure.cs │ ├── Mobi.cs │ ├── MobiReadingConfiguration.cs │ ├── Engine │ │ ├── PalmDOCHeaderEngine.cs │ │ ├── IndxHeaderEngine.cs │ │ ├── PalmDBEngine.cs │ │ ├── ExthHeaderEngine.cs │ │ ├── RecordEngine.cs │ │ └── MobiHeaderEngine.cs │ ├── ExtendMethod.cs │ └── MobiReader.cs └── RolerFileToolkit.sln ├── LICENSE.md ├── README.md └── .gitignore /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/StoreLogo.png -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Ncx/NavInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavInfo 4 | { 5 | public string Text { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/NavSpan.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavSpan 4 | { 5 | public string Value { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Ncx/NavPointLabel.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavPointLabel 4 | { 5 | public string Text { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/IndxHeader/IndexType.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum IndexType : uint 4 | { 5 | Normal, 6 | 7 | Inflections = 2, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/NavHead.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavHead 4 | { 5 | public string Name { get; set; } 6 | public string Value { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.WPF/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolerzhang/RolerFileToolkit/HEAD/RolerFileToolkit/Samples/FileToolkitSample.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Ncx/NavPointContent.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavPointContent 4 | { 5 | public string Id { get; set; } 6 | public string Source { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Compression/ICompression.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Compression 2 | { 3 | internal interface ICompression 4 | { 5 | byte[] Compress(byte[] bytes); 6 | byte[] Decompress(byte[] bytes); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/MobiHeader/TextEncoding.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum TextEncoding : uint 4 | { 5 | Unkown, 6 | 7 | CP1252 = 1252, 8 | 9 | UTF8 = 65001, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.WPF/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/Nav.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class Nav 6 | { 7 | public IList NavElements { get; } = new List(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/NavA.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavA 4 | { 5 | public string Href { get; set; } 6 | public string Title { get; set; } 7 | public string Value { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Ncx/Ncx.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class Ncx 4 | { 5 | public string Version { get; set; } 6 | public string Language { get; set; } 7 | public NavMap NavMap { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Container.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class Container 4 | { 5 | public string Namespace { get; set; } 6 | public string FullPath { get; set; } 7 | public string MediaType { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Ncx/NavMap.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class NavMap 6 | { 7 | public NavInfo NavInfo { get; set; } 8 | public IList NavPoints { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Define/Const.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Define 2 | { 3 | internal class Const 4 | { 5 | public const int ByteBitLength = 8; 6 | public const int ShortBitLength = 2 * 8; 7 | public const int IntBitLength = 4 * 8; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/Manifest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class Manifest 6 | { 7 | public string Id { get; set; } 8 | public IList Items { get; } = new List(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/NavOl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class NavOl 6 | { 7 | public string Id { get; set; } 8 | public bool IsHidden { get; set; } 9 | public IList Items { get; } = new List(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/SpineItemRef.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class SpineItemRef 4 | { 5 | public string IdRef { get; set; } 6 | public string Linear { get; set; } 7 | public string Id { get; set; } 8 | public string Properties { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/NavLi.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavLi 4 | { 5 | public string Id { get; set; } 6 | public bool IsHidden { get; set; } 7 | public NavA A { get; set; } 8 | public NavSpan Span { get; set; } 9 | public NavOl Ol { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Nav/NavElement.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class NavElement 4 | { 5 | public string Type { get; set; } 6 | public string Id { get; set; } 7 | public bool IsHidden { get; set; } 8 | public NavHead NavHead { get; set; } 9 | public NavOl Ol { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/LinkElement.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class LinkElement 4 | { 5 | public string Href { get; set; } 6 | public string Rel { get; set; } 7 | public string Id { get; set; } 8 | public string Refines { get; set; } 9 | public string MediaType { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Chapter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub 4 | { 5 | public class Chapter 6 | { 7 | public string Title { get; set; } 8 | public string ContentFilePath { get; set; } 9 | public string SecondPath { get; set; } 10 | public IList Chapters { get; } = new List(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/PalmDBRecord.cs: -------------------------------------------------------------------------------- 1 | using Roler.Toolkit.File.Mobi.Entity; 2 | 3 | namespace Roler.Toolkit.File.Mobi 4 | { 5 | internal class PalmDBRecord 6 | { 7 | public PalmDBRecordInfo Info { get; } 8 | public int Length { get; set; } 9 | 10 | public PalmDBRecord(PalmDBRecordInfo info) 11 | { 12 | this.Info = info; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/DcElement.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | /// 4 | /// The Element of DCMES. 5 | /// 6 | public class DcElement 7 | { 8 | public string Id { get; set; } 9 | public string Language { get; set; } 10 | public string Dir { get; set; } 11 | public string Value { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Compression/NoneCompression.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Compression 2 | { 3 | internal class NoneCompression : ICompression 4 | { 5 | public byte[] Compress(byte[] bytes) 6 | { 7 | return bytes; 8 | } 9 | 10 | public byte[] Decompress(byte[] bytes) 11 | { 12 | return bytes; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/ContentFile.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Roler.Toolkit.File.Mobi 3 | { 4 | public class ContentFile 5 | { 6 | public string MediaType { get; set; } 7 | public string Source { get; private set; } 8 | 9 | public ContentFile(string mediaType, string source) 10 | { 11 | MediaType = mediaType; 12 | Source = source; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/Spine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class Spine 6 | { 7 | public string Id { get; set; } 8 | public string Toc { get; set; } 9 | public string PageProgressionDirection { get; set; } 10 | public IList Items { get; } = new List(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/ContentFile.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Roler.Toolkit.File.Epub 3 | { 4 | public class ContentFile 5 | { 6 | public string MediaType { get; set; } 7 | public string FilePath { get; private set; } 8 | 9 | public ContentFile(string mediaType, string filePath) 10 | { 11 | MediaType = mediaType; 12 | FilePath = filePath; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Define/Const.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | 3 | namespace Roler.Toolkit.File.Epub.Define 4 | { 5 | internal class Const 6 | { 7 | public const string CONTAINER_PATH = @"META-INF/container.xml"; 8 | 9 | public readonly static XName ATTRIBUTE_LANGUAGE = XNamespace.Xml + "lang"; 10 | public readonly static XNamespace EPUB_NAMESPACE = @"http://www.idpf.org/2007/ops"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.WPF/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace FileToolkitSample.WPF 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/ManifestItem.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class ManifestItem 4 | { 5 | public string Id { get; set; } 6 | public string Href { get; set; } 7 | public string MediaType { get; set; } 8 | public string Fallback { get; set; } 9 | public string Properties { get; set; } 10 | public string MediaOverlay { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Ncx/NavPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class NavPoint 6 | { 7 | public string Id { get; set; } 8 | public string PlayOrder { get; set; } 9 | public NavPointLabel Label { get; set; } 10 | public NavPointContent Content { get; set; } 11 | public IList Children { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.WPF/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Helper/PathHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Roler.Toolkit.File.Epub.Helper 4 | { 5 | internal static class PathHelper 6 | { 7 | public static string Combine(params string[] paths) 8 | { 9 | var path = Path.Combine(paths); 10 | if (path != null) 11 | { 12 | path = path.Replace(@"\", "/"); 13 | } 14 | return path; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/AudiRecord.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class AudiRecord 4 | { 5 | /// 6 | /// Gets or sets the identifier, always 'AUDI'. 7 | /// 8 | public string Identifier { get; set; } 9 | 10 | /// 11 | /// Gets or sets the media data continues to the end of this record. 12 | /// 13 | public byte[] Media { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/VideRecord.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class VideRecord 4 | { 5 | /// 6 | /// Gets or sets the identifier, always 'VIDE'. 7 | /// 8 | public string Identifier { get; set; } 9 | 10 | /// 11 | /// Gets or sets the media data continues to the end of this record. 12 | /// 13 | public byte[] Media { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/PalmDOCHeader/EncryptionType.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum EncryptionType : ushort 4 | { 5 | /// 6 | /// No encryption. 7 | /// 8 | None = 0, 9 | 10 | /// 11 | /// Old Mobipocket Encryption. 12 | /// 13 | OldMobi = 1, 14 | 15 | /// 16 | /// Mobipocket Encryption. 17 | /// 18 | Mobi = 2, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/PalmDOCHeader/CompressionType.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum CompressionType : ushort 4 | { 5 | Unkown, 6 | 7 | /// 8 | /// No compression. 9 | /// 10 | No = 1, 11 | 12 | /// 13 | /// PalmDOC compression. 14 | /// 15 | PalmDOC = 2, 16 | 17 | /// 18 | /// HUFF/CDIC compression. 19 | /// 20 | HUFF_CDIC = 17480, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/Package.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class Package 4 | { 5 | public float Version { get; set; } 6 | public string Identifier { get; set; } 7 | public string Prefix { get; set; } 8 | public string Language { get; set; } 9 | public string Dir { get; set; } 10 | public string Id { get; set; } 11 | public Metadata Metadata { get; set; } 12 | public Manifest Manifest { get; set; } 13 | public Spine Spine { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Structure.cs: -------------------------------------------------------------------------------- 1 | using Roler.Toolkit.File.Epub.Entity; 2 | 3 | namespace Roler.Toolkit.File.Epub 4 | { 5 | public class Structure 6 | { 7 | public Container Container { get; set; } 8 | public Package Package { get; set; } 9 | 10 | /// 11 | /// 获取或设置ncx相关信息,仅在Epub3.0之前有效,3.0以后请使用Nav属性。 12 | /// 13 | public Ncx Ncx { get; set; } 14 | 15 | /// 16 | /// 获取或设置导航文件信息,仅在Epub3.0之后有效,3.0之前请使用Ncx属性。 17 | /// 18 | public Nav Nav { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Roler.Toolkit.File.Mobi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | RolerZhang 6 | .NET Standard Class Library for Mobi File. 7 | Apache-2.0 8 | https://github.com/rolerzhang/RolerFileToolkit 9 | mobi 10 | 1.0.5 11 | 1.0.5.0 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Structure.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Roler.Toolkit.File.Mobi.Entity; 3 | 4 | namespace Roler.Toolkit.File.Mobi 5 | { 6 | public class Structure 7 | { 8 | public string FullName { get; set; } 9 | public PalmDB PalmDB { get; set; } 10 | public PalmDOCHeader PalmDOCHeader { get; set; } 11 | public MobiHeader MobiHeader { get; set; } 12 | public ExthHeader ExthHeader { get; set; } 13 | public IndxHeader IndxHeader { get; set; } 14 | public FlisRecord FlisRecord { get; set; } 15 | public FcisRecord FcisRecord { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/PalmDB/PalmDBRecordAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum PalmDBRecordAttribute : byte 4 | { 5 | Unkown, 6 | 7 | /// 8 | /// Secret record bit. 9 | /// 10 | Secret = 0x10, 11 | 12 | /// 13 | /// Record in use (busy bit). 14 | /// 15 | InUse = 0x20, 16 | 17 | /// 18 | /// Dirty record bit. 19 | /// 20 | Dirty = 0x40, 21 | 22 | /// 23 | /// Delete record on next HotSync. 24 | /// 25 | Delete = 0x80, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Roler.Toolkit.File.Epub.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | RolerZhang 6 | Roler.Toolkit.File.Epub 7 | epub 8 | .NET Standard Class Library for Epub File. support EPUB 3.0 9 | Apache-2.0 10 | https://github.com/rolerzhang/RolerFileToolkit 11 | 12 | 1.0.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/PalmDB/PalmDBRecordInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class PalmDBRecordInfo 4 | { 5 | /// 6 | /// Gets or sets the offset of record n from the start of the PDB of this record. 7 | /// 8 | public uint Offset { get; set; } 9 | 10 | public PalmDBRecordAttribute Attribute { get; set; } 11 | 12 | /// 13 | /// Gets or sets the unique ID for this record. Often just a sequential count from 0. 14 | /// 15 | public uint UniqueID { get; set; } 16 | 17 | public override string ToString() 18 | { 19 | return $"{UniqueID}, {this.Attribute} , {Offset}"; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/MetaElement.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Epub.Entity 2 | { 3 | public class MetaElement 4 | { 5 | public string Id { get; set; } 6 | public string Language { get; set; } 7 | public string Dir { get; set; } 8 | public string Scheme { get; set; } 9 | public string Property { get; set; } 10 | public string Refines { get; set; } 11 | public string Value { get; set; } 12 | 13 | /// 14 | /// Attribute name, Only Epub2.0 15 | /// 16 | public string Name { get; set; } 17 | 18 | /// 19 | /// Attribute content, Only Epub2.0 20 | /// 21 | public string Content { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Mobi.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Roler.Toolkit.File.Mobi 3 | { 4 | public class Mobi 5 | { 6 | public Structure Structure { get; set; } 7 | 8 | public string Title { get; set; } 9 | public string Creator { get; set; } 10 | public string Publisher { get; set; } 11 | public string Description { get; set; } 12 | public string Subject { get; set; } 13 | public string Date { get; set; } 14 | public string Contributor { get; set; } 15 | public string Rights { get; set; } 16 | public string Type { get; set; } 17 | public string Source { get; set; } 18 | public string Language { get; set; } 19 | public ContentFile Cover { get; set; } 20 | 21 | public string Text { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/CmetRecord.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class CmetRecord 4 | { 5 | /// 6 | /// Gets or sets the identifier, always 'CMET'. 7 | /// 8 | public string Identifier { get; set; } 9 | 10 | /// 11 | /// Gets or sets the value0, fixed value: 0x0000000C. 12 | /// 13 | public uint Value0 { get; set; } 14 | 15 | /// 16 | /// Gets or sets the length of the text. 17 | /// 18 | public uint TextLength { get; set; } 19 | 20 | /// 21 | /// Gets or sets the compilation output text, line endings are CRLF. 22 | /// 23 | public string Text { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/ExtendMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Roler.Toolkit.File.Epub.Entity; 4 | 5 | namespace Roler.Toolkit.File.Epub 6 | { 7 | internal static class ExtendMethod 8 | { 9 | private const string XML_1_0_START = " 8 | /// Gets or sets the identifier, always 'EXTH'. 9 | /// 10 | public string Identifier { get; set; } 11 | 12 | /// 13 | /// Gets or sets the length of the EXTH header, including the previous 4 bytes. 14 | /// 15 | public uint Length { get; set; } 16 | 17 | /// 18 | /// Gets or sets the number of records in the EXTH header. the rest of the EXTH header consists of repeated EXTH records to the end of the EXTH length. 19 | /// 20 | public uint RecordCount { get; set; } 21 | 22 | public IList RecordList { get; } = new List(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/SrcsRecord.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class SrcsRecord 4 | { 5 | /// 6 | /// Gets or sets the identifier, always 'SRCS'. 7 | /// 8 | public string Identifier { get; set; } 9 | 10 | /// 11 | /// Gets or sets the value0, fixed value: 0x00000010. 12 | /// 13 | public uint Value0 { get; set; } 14 | 15 | /// 16 | /// Gets or sets the value1, fixed value: 0x0000002f. 17 | /// 18 | public uint Value1 { get; set; } 19 | 20 | /// 21 | /// Gets or sets the value2, fixed value: 0x00000001. 22 | /// 23 | public uint Value2 { get; set; } 24 | 25 | /// 26 | /// Gets or sets the zip archive continues to the end of this record. 27 | /// 28 | public byte[] Zip { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/MobiHeader/MobiType.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum MobiType : uint 4 | { 5 | Unkown, 6 | 7 | /// 8 | /// Mobipocket Book. 9 | /// 10 | Mobipocket = 2, 11 | 12 | /// 13 | /// PalmDoc Book. 14 | /// 15 | PalmDoc = 3, 16 | 17 | /// 18 | /// Audio. 19 | /// 20 | Audio = 4, 21 | 22 | /// 23 | /// mobipocket? generated by kindlegen1.2. 24 | /// 25 | Mobipocket_Kindlegen_1_2 = 232, 26 | 27 | /// 28 | /// generated by kindlegen2. 29 | /// 30 | KF8 = 248, 31 | 32 | News = 257, 33 | 34 | News_Feed = 258, 35 | 36 | News_Magazine = 259, 37 | 38 | PICS = 513, 39 | 40 | WORD = 514, 41 | 42 | XLS = 515, 43 | 44 | PPT = 516, 45 | 46 | TEXT = 517, 47 | 48 | HTML = 518, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/PalmDB/PalmDBAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public enum PalmDBAttribute : ushort 4 | { 5 | Unkown, 6 | 7 | /// 8 | /// Read-Only. 9 | /// 10 | ReadOnly = 0x0002, 11 | 12 | /// 13 | /// Dirty AppInfoArea. 14 | /// 15 | DirtyAppInfoArea = 0x0004, 16 | 17 | /// 18 | /// Backup this database. 19 | /// 20 | Backup = 0x0008, 21 | 22 | /// 23 | /// Okay to install newer over existing copy, if present on PalmPilot. 24 | /// 25 | OverInstall = 0x0010, 26 | 27 | /// 28 | /// Force the PalmPilot to reset after this database is installed. 29 | /// 30 | ResetAfterInstall = 0x0020, 31 | 32 | /// 33 | /// Don't allow copy of file to be beamed to other Pilot. 34 | /// 35 | DisallowCopy = 0x0040, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 RolerZhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/ExthHeader/ExthRecord.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class ExthRecord 4 | { 5 | /// 6 | /// Gets or sets the Exth Record type. Just a number identifying what's stored in the record. 7 | /// 8 | public ExthRecordType Type { get; set; } 9 | 10 | /// 11 | /// Gets or sets the length of the EXTH record = L , including the 8 bytes in the type and length fields. 12 | /// 13 | public uint Length { get; set; } 14 | 15 | /// 16 | /// Gets or sets the Data of the EXTH record. 17 | /// 18 | public byte[] Data { get; set; } 19 | 20 | public string DataAsString() 21 | { 22 | if (this.Data != null) 23 | { 24 | return System.Text.Encoding.UTF8.GetString(this.Data); 25 | } 26 | return null; 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return $"{this.Type} : {this.Data}"; 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FileToolkitSample.UWP")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FileToolkitSample.UWP")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.WPF/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FileToolkitSample.WPF.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Epub.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub 4 | { 5 | public class Epub 6 | { 7 | public Structure Structure { get; set; } 8 | 9 | public string Contributor { get; set; } 10 | public string Coverage { get; set; } 11 | public string Creator { get; set; } 12 | public string Date { get; set; } 13 | public string Description { get; set; } 14 | public string Format { get; set; } 15 | public string Identifier { get; set; } 16 | public string Language { get; set; } 17 | public string Publisher { get; set; } 18 | public string Relation { get; set; } 19 | public string Rights { get; set; } 20 | public string Source { get; set; } 21 | public string Subject { get; set; } 22 | public string Title { get; set; } 23 | public string Type { get; set; } 24 | public ContentFile Cover { get; set; } 25 | public IList Chapters { get; } = new List(); 26 | public IList ReadingFiles { get; } = new List(); 27 | public IList AllFiles { get; } = new List(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Compression/BitReader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Mobi 4 | { 5 | internal class BitReader 6 | { 7 | private readonly IList _data; 8 | private readonly int _nbits; 9 | 10 | private uint _pos = 0; 11 | 12 | public bool IsEnd => this._nbits > this._pos; 13 | 14 | public BitReader(byte[] bytes) 15 | { 16 | this._data = new List(bytes) 17 | { 18 | 0, 19 | 0, 20 | 0, 21 | 0 22 | }; 23 | this._nbits = (this._data.Count - 4) * 8; 24 | } 25 | 26 | public ulong Peek(ulong n) 27 | { 28 | ulong r = 0; 29 | ulong g = 0; 30 | while (g < n) 31 | { 32 | r = (r << 8) | (char)(_data[(int)((long)(_pos + g >> 3))]); 33 | g = g + 8 - ((_pos + g) & 7); 34 | } 35 | return r >> (int)((long)(g - n)) & ((ulong)(1) << (int)n) - 1; 36 | } 37 | 38 | public bool Eat(uint n) 39 | { 40 | _pos += n; 41 | return _pos <= _nbits; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/Entity/PalmDOCHeader/PalmDOCHeader.cs: -------------------------------------------------------------------------------- 1 | namespace Roler.Toolkit.File.Mobi.Entity 2 | { 3 | public class PalmDOCHeader 4 | { 5 | public CompressionType Compression { get; set; } 6 | 7 | /// 8 | /// Always zero. 9 | /// 10 | public short Unused { get; } 11 | 12 | /// 13 | /// Gets or sets the uncompressed length of the entire text of the book. 14 | /// 15 | public uint TextLength { get; set; } 16 | 17 | /// 18 | /// Gets or sets the number of PDB records used for the text of the book. 19 | /// 20 | public ushort RecordCount { get; set; } 21 | 22 | /// 23 | /// Gets or sets the maximum size of each record containing text, always 4096. 24 | /// 25 | public ushort RecordSize { get; set; } 26 | 27 | /// 28 | /// Gets or sets the current reading position, as an offset into the uncompressed text. 29 | /// 30 | public uint CurrentPosition { get; set; } 31 | 32 | /// 33 | /// Gets or sets the encryption type, Only HUFF/CDIC compression. 34 | /// 35 | public EncryptionType Encryption { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Entity/Opf/Metadata.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Roler.Toolkit.File.Epub.Entity 4 | { 5 | public class Metadata 6 | { 7 | public IList Contributors { get; } = new List(); 8 | public IList Coverages { get; } = new List(); 9 | public IList Creators { get; } = new List(); 10 | public DcElement Date { get; set; } 11 | public IList Descriptions { get; } = new List(); 12 | public IList Formats { get; } = new List(); 13 | public IList Identifiers { get; } = new List(); 14 | public IList Languages { get; } = new List(); 15 | public IList Publishers { get; } = new List(); 16 | public IList Relations { get; } = new List(); 17 | public IList Rights { get; } = new List(); 18 | public IList Sources { get; } = new List(); 19 | public IList Subjects { get; } = new List(); 20 | public IList Titles { get; } = new List(); 21 | public IList Types { get; } = new List(); 22 | public IList Metas { get; } = new List(); 23 | public IList Links { get; } = new List(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Epub/Engine/ContainerEngine.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using System.Xml.Linq; 4 | using Roler.Toolkit.File.Epub.Entity; 5 | 6 | namespace Roler.Toolkit.File.Epub.Engine 7 | { 8 | internal static class ContainerEngine 9 | { 10 | #region Const String 11 | 12 | private const string FULLPATH = "full-path"; 13 | private const string MEDIATYPE = "media-type"; 14 | private const string ROOTFILE = "rootfile"; 15 | 16 | #endregion 17 | 18 | public static Container Read(Stream stream) 19 | { 20 | Container result = null; 21 | using (var streamReader = new StreamReader(stream)) 22 | { 23 | string xmlStr = streamReader.ReadToEnd(); 24 | var document = XElement.Parse(xmlStr.FixXml()); 25 | 26 | var xNamespace = document.GetDefaultNamespace(); 27 | result = new Container 28 | { 29 | Namespace = xNamespace.NamespaceName 30 | }; 31 | 32 | var xElement = document.Descendants(xNamespace + ROOTFILE).FirstOrDefault(); 33 | if (xElement != null) 34 | { 35 | result.FullPath = xElement.Attribute(FULLPATH).Value; 36 | result.MediaType = xElement.Attribute(MEDIATYPE).Value; 37 | } 38 | } 39 | return result; 40 | } 41 | 42 | public static void Write(Container file, Stream stream) 43 | { 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /RolerFileToolkit/Roler.Toolkit.File.Mobi/MobiReadingConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Roler.Toolkit.File.Mobi.Engine; 3 | using Roler.Toolkit.File.Mobi.Entity; 4 | 5 | namespace Roler.Toolkit.File.Mobi 6 | { 7 | public class MobiReadingConfiguration 8 | { 9 | public virtual int FindFirstTextRecordIndex(MobiHeader mobiHeader) 10 | { 11 | if (mobiHeader is null) 12 | { 13 | throw new ArgumentNullException(nameof(mobiHeader)); 14 | } 15 | 16 | return mobiHeader.FirstContentRecordOffset > 0 ? mobiHeader.FirstContentRecordOffset : 1; 17 | } 18 | 19 | public virtual long FindFirstNonTextRecordIndex(MobiHeader mobiHeader, long recordCount) 20 | { 21 | if (mobiHeader is null) 22 | { 23 | throw new ArgumentNullException(nameof(mobiHeader)); 24 | } 25 | 26 | long result; 27 | if (mobiHeader.FirstNonBookIndex != MobiHeaderEngine.UnavailableIndex && 28 | mobiHeader.FirstNonBookIndex < recordCount) 29 | { 30 | result = mobiHeader.FirstNonBookIndex; 31 | } 32 | else 33 | { 34 | result = Math.Min(mobiHeader.LastContentRecordOffset, mobiHeader.INDXRecordOffset); 35 | result = Math.Min(result, mobiHeader.FLISRecordOffset); 36 | result = Math.Min(result, mobiHeader.FCISRecordOffset); 37 | result = Math.Min(result, recordCount); 38 | } 39 | return result; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /RolerFileToolkit/Samples/FileToolkitSample.UWP/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 |