diff --git a/Catswords.DataType.Client/Catswords.DataType.Client.csproj b/Catswords.DataType.Client/Catswords.DataType.Client.csproj index 7f92756..38554c2 100644 --- a/Catswords.DataType.Client/Catswords.DataType.Client.csproj +++ b/Catswords.DataType.Client/Catswords.DataType.Client.csproj @@ -61,6 +61,9 @@ True True + + ..\packages\System.IO.Packaging.8.0.0\lib\net462\System.IO.Packaging.dll + ..\packages\System.IO.Pipelines.8.0.0\lib\net462\System.IO.Pipelines.dll @@ -87,12 +90,14 @@ + ..\packages\XmpCore.6.1.10.1\lib\net35\XmpCore.dll + @@ -108,7 +113,7 @@ UserControl2.cs - + diff --git a/Catswords.DataType.Client/Helper/CbpfExtractor.cs b/Catswords.DataType.Client/Helper/CbpfExtractor.cs deleted file mode 100644 index 97d37ae..0000000 --- a/Catswords.DataType.Client/Helper/CbpfExtractor.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Catswords.DataType.Client.Helper -{ - public class CbpfExtractor - { - private string FilePath; - - public CbpfExtractor(string filePath) - { - FilePath = filePath; - } - - - } -} diff --git a/Catswords.DataType.Client/Helper/CfbfExtractor.cs b/Catswords.DataType.Client/Helper/CfbfExtractor.cs new file mode 100644 index 0000000..7d693e3 --- /dev/null +++ b/Catswords.DataType.Client/Helper/CfbfExtractor.cs @@ -0,0 +1,71 @@ +using Catswords.DataType.Client.Model; +using System.Collections.Generic; +using System.IO.Packaging; +using System.IO; + +namespace Catswords.DataType.Client.Helper +{ + public class CfbfExtractor + { + private string FilePath; + + public CfbfExtractor(string filePath) + { + FilePath = filePath; + } + + public List GetParts() + { + List partInfoList = new List(); + + if (!IsValidFormat()) + { + return partInfoList; + } + + using (Package package = Package.Open(FilePath, FileMode.Open, FileAccess.Read)) + { + foreach (PackagePart part in package.GetParts()) + { + CfbfPartInfo partInfo = new CfbfPartInfo(); + partInfo.URI = part.Uri.ToString(); + partInfo.ContentType = part.ContentType; + + using (Stream stream = part.GetStream(FileMode.Open, FileAccess.Read)) + { + using (StreamReader reader = new StreamReader(stream)) + { + partInfo.Content = reader.ReadToEnd(); + } + } + + partInfoList.Add(partInfo); + } + } + + return partInfoList; + } + + public bool IsValidFormat() + { + // CFBF 파일 시그니처 확인 + byte[] signatureBytes = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }; + byte[] fileBytes = new byte[signatureBytes.Length]; + + using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read)) + { + fileStream.Read(fileBytes, 0, signatureBytes.Length); + } + + for (int i = 0; i < signatureBytes.Length; i++) + { + if (fileBytes[i] != signatureBytes[i]) + { + return false; + } + } + + return true; + } + } +} diff --git a/Catswords.DataType.Client/Model/CfbfPartInfo.cs b/Catswords.DataType.Client/Model/CfbfPartInfo.cs new file mode 100644 index 0000000..5b76f70 --- /dev/null +++ b/Catswords.DataType.Client/Model/CfbfPartInfo.cs @@ -0,0 +1,9 @@ +namespace Catswords.DataType.Client.Model +{ + public class CfbfPartInfo: Timestamp + { + public string URI { get; set; } + public string ContentType { get; set; } + public string Content { get; set; } + } +} diff --git a/Catswords.DataType.Client/Worker1.cs b/Catswords.DataType.Client/Worker1.cs index cb4eca4..5bd1feb 100644 --- a/Catswords.DataType.Client/Worker1.cs +++ b/Catswords.DataType.Client/Worker1.cs @@ -1,5 +1,6 @@ using Catswords.DataType.Client.Helper; using Catswords.DataType.Client.Model; +using MetadataExtractor; using System; using System.Threading.Tasks; @@ -140,6 +141,16 @@ namespace Catswords.DataType.Client } } + public void FormCfbf() + { + var extractor = new CfbfExtractor(Parent.FilePath); + var parts = extractor.GetParts(); + foreach (CfbfPartInfo part in parts) + { + Parent.AddIndicator(DateTime.Now, $"CFBF: {part.Content} ({part.ContentType}, {part.URI})", 5); + } + } + public void Run() { new Task(() => @@ -148,7 +159,8 @@ namespace Catswords.DataType.Client FromAndroidManifest(); // Get data from Android manifest FromTimeline(); // Get data from timeline FromLinks(); // Get links from file - FromExif(); // Get EXIF tags from file + FromExif(); // Get EXIF tags from file + FormCfbf(); // Get CFBF (aka. OLE) parts from file }).Start(); } } diff --git a/Catswords.DataType.Client/packages.config b/Catswords.DataType.Client/packages.config index 6d04474..b2d7bb9 100644 --- a/Catswords.DataType.Client/packages.config +++ b/Catswords.DataType.Client/packages.config @@ -6,6 +6,7 @@ +