Skip to content

Commit

Permalink
Added stub for developing GEDZIP support (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Dec 17, 2023
1 parent a536bef commit 366644d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
68 changes: 68 additions & 0 deletions projects/GKCore/GDModel/Providers/GEDZIP/GEDZIPProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2023 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System.IO;
using System.Text;
using GDModel.Providers.GEDCOM;
using GKCore;

namespace GDModel.Providers.GEDZIP
{
/// <summary>
/// Processing the GEDZIP format is one part of the Genealogical Data Model (GDM).
/// </summary>
public class GEDZIPProvider : FileProvider
{
static GEDZIPProvider()
{
// Static initialization of the GEDCOMProvider is needed,
// otherwise the standard tag identifiers are out of sync
SysUtils.DoNotInline(GEDCOMProvider.GEDCOMFormats);
}

public GEDZIPProvider(GDMTree tree) : base(tree)
{
}

public override string GetFilesFilter()
{
return "GEDZIP files (*.gdz,*.zip)|*.gdz,*.zip";
}

protected override Encoding GetDefaultEncoding()
{
return Encoding.UTF8;
}

protected override string DetectCharset(Stream inputStream, bool charsetDetection)
{
string streamCharset = null;
return streamCharset;
}

public override void LoadFromStreamExt(Stream fileStream, Stream inputStream, bool charsetDetection = false)
{
}

protected override void LoadFromReader(Stream fileStream, StreamReader reader, string streamCharset = null)
{
}
}
}
1 change: 1 addition & 0 deletions projects/GKCore/GKCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="GDModel\Providers\GEDZIP\GEDZIPProvider.cs" />
<Compile Include="GKCore\Design\Controls\IFilterControl.cs" />
<Compile Include="GKCore\Design\Controls\ISplitter.cs" />
<Compile Include="GKCore\Design\IForm.cs" />
Expand Down
3 changes: 3 additions & 0 deletions projects/GKCore/GKCore/BaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using GDModel.Providers.FamilyShow;
using GDModel.Providers.GEDCOM;
using GDModel.Providers.GedML;
using GDModel.Providers.GEDZIP;
using GKCore.Controllers;
using GKCore.Cultures;
using GKCore.Design;
Expand Down Expand Up @@ -1387,6 +1388,8 @@ public async Task<bool> FileLoad(string fileName, bool loadSecure, bool showProg
fileProvider = new GedMLProvider(fTree);
} else if (ext == ".familyx") {
fileProvider = new FamilyXProvider(fTree);
} else if (ext == ".gdz" || ext == ".zip") {
fileProvider = new GEDZIPProvider(fTree);
} else {
// TODO: message?
return false;
Expand Down
5 changes: 5 additions & 0 deletions projects/GKCore/GKCore/Controllers/BaseWinController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#define GEDML_SUPPORT
#define FAMX_SUPPORT
//#define GDZ_SUPPORT

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -157,6 +158,10 @@ private void PrepareLoadFile(out string homePath, out string filters)
#if FAMX_SUPPORT
filters += "|" + "Family.Show files (*.familyx)|*.familyx";
#endif

#if GDZ_SUPPORT
filters += "|" + "GEDZIP files (*.gdz,*.zip)|*.gdz,*.zip";
#endif
}

public async Task LoadFileEx()
Expand Down

0 comments on commit 366644d

Please sign in to comment.