Skip to content

Commit 5fee960

Browse files
committed
Move 'gdal sozip' as 'gdal vsi sozip'
1 parent 7af673c commit 5fee960

File tree

9 files changed

+142
-117
lines changed

9 files changed

+142
-117
lines changed

apps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ add_library(
4545
gdalalg_raster_tri.cpp
4646
gdalalg_raster_unscale.cpp
4747
gdalalg_raster_write.cpp
48-
gdalalg_sozip.cpp
4948
gdalalg_vector.cpp
5049
gdalalg_vector_info.cpp
5150
gdalalg_vector_clip.cpp
@@ -80,6 +79,7 @@ add_library(
8079
gdalalg_vsi_copy.cpp
8180
gdalalg_vsi_delete.cpp
8281
gdalalg_vsi_list.cpp
82+
gdalalg_vsi_sozip.cpp
8383
gdalinfo_lib.cpp
8484
gdalbuildvrt_lib.cpp
8585
gdal_grid_lib.cpp

apps/gdalalg_vsi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "gdalalg_vsi_copy.h"
1616
#include "gdalalg_vsi_delete.h"
1717
#include "gdalalg_vsi_list.h"
18+
#include "gdalalg_vsi_sozip.h"
1819

1920
/************************************************************************/
2021
/* GDALVSIAlgorithm */
@@ -33,6 +34,7 @@ class GDALVSIAlgorithm final : public GDALAlgorithm
3334
RegisterSubAlgorithm<GDALVSICopyAlgorithm>();
3435
RegisterSubAlgorithm<GDALVSIDeleteAlgorithm>();
3536
RegisterSubAlgorithm<GDALVSIListAlgorithm>();
37+
RegisterSubAlgorithm<GDALVSISOZIPAlgorithm>();
3638
}
3739

3840
private:

apps/gdalalg_sozip.cpp renamed to apps/gdalalg_vsi_sozip.cpp

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* SPDX-License-Identifier: MIT
1111
****************************************************************************/
1212

13-
#include "gdalalgorithm.h"
13+
#include "gdalalg_vsi_sozip.h"
1414

1515
#include "cpl_conv.h"
1616
#include "cpl_string.h"
@@ -25,15 +25,16 @@
2525
#endif
2626

2727
/************************************************************************/
28-
/* GDALSOZIPCreateBaseAlgorithm */
28+
/* GDALVSISOZIPCreateBaseAlgorithm */
2929
/************************************************************************/
3030

31-
class GDALSOZIPCreateBaseAlgorithm /* non final */ : public GDALAlgorithm
31+
class GDALVSISOZIPCreateBaseAlgorithm /* non final */ : public GDALAlgorithm
3232
{
3333
protected:
34-
GDALSOZIPCreateBaseAlgorithm(const std::string &name,
35-
const std::string &description,
36-
const std::string &helpURL, bool optimizeFrom)
34+
GDALVSISOZIPCreateBaseAlgorithm(const std::string &name,
35+
const std::string &description,
36+
const std::string &helpURL,
37+
bool optimizeFrom)
3738
: GDALAlgorithm(name, description, helpURL),
3839
m_optimizeFrom(optimizeFrom)
3940
{
@@ -143,11 +144,11 @@ class GDALSOZIPCreateBaseAlgorithm /* non final */ : public GDALAlgorithm
143144
};
144145

145146
/************************************************************************/
146-
/* GDALSOZIPCreateBaseAlgorithm::RunImpl() */
147+
/* GDALVSISOZIPCreateBaseAlgorithm::RunImpl() */
147148
/************************************************************************/
148149

149-
bool GDALSOZIPCreateBaseAlgorithm::RunImpl(GDALProgressFunc pfnProgress,
150-
void *pProgressData)
150+
bool GDALVSISOZIPCreateBaseAlgorithm::RunImpl(GDALProgressFunc pfnProgress,
151+
void *pProgressData)
151152
{
152153
CPLStringList aosOptions;
153154
aosOptions.SetNameValue("SOZIP_ENABLED", m_mode.c_str());
@@ -343,54 +344,55 @@ bool GDALSOZIPCreateBaseAlgorithm::RunImpl(GDALProgressFunc pfnProgress,
343344
}
344345

345346
/************************************************************************/
346-
/* GDALSOZIPCreateAlgorithm */
347+
/* GDALVSISOZIPCreateAlgorithm */
347348
/************************************************************************/
348349

349-
class GDALSOZIPCreateAlgorithm final : public GDALSOZIPCreateBaseAlgorithm
350+
class GDALVSISOZIPCreateAlgorithm final : public GDALVSISOZIPCreateBaseAlgorithm
350351
{
351352
public:
352353
static constexpr const char *NAME = "create";
353354
static constexpr const char *DESCRIPTION =
354355
"Create a Seek-optimized ZIP (SOZIP) file.";
355-
static constexpr const char *HELP_URL = "/programs/gdal_sozip.html";
356+
static constexpr const char *HELP_URL = "/programs/gdal_vsi_sozip.html";
356357

357-
GDALSOZIPCreateAlgorithm()
358-
: GDALSOZIPCreateBaseAlgorithm(NAME, DESCRIPTION, HELP_URL, false)
358+
GDALVSISOZIPCreateAlgorithm()
359+
: GDALVSISOZIPCreateBaseAlgorithm(NAME, DESCRIPTION, HELP_URL, false)
359360
{
360361
}
361362
};
362363

363364
/************************************************************************/
364-
/* GDALSOZIPOptimizeAlgorithm */
365+
/* GDALVSISOZIPOptimizeAlgorithm */
365366
/************************************************************************/
366367

367-
class GDALSOZIPOptimizeAlgorithm final : public GDALSOZIPCreateBaseAlgorithm
368+
class GDALVSISOZIPOptimizeAlgorithm final
369+
: public GDALVSISOZIPCreateBaseAlgorithm
368370
{
369371
public:
370372
static constexpr const char *NAME = "optimize";
371373
static constexpr const char *DESCRIPTION =
372374
"Create a Seek-optimized ZIP (SOZIP) file from a regular ZIP file.";
373-
static constexpr const char *HELP_URL = "/programs/gdal_sozip.html";
375+
static constexpr const char *HELP_URL = "/programs/gdal_vsi_sozip.html";
374376

375-
GDALSOZIPOptimizeAlgorithm()
376-
: GDALSOZIPCreateBaseAlgorithm(NAME, DESCRIPTION, HELP_URL, true)
377+
GDALVSISOZIPOptimizeAlgorithm()
378+
: GDALVSISOZIPCreateBaseAlgorithm(NAME, DESCRIPTION, HELP_URL, true)
377379
{
378380
}
379381
};
380382

381383
/************************************************************************/
382-
/* GDALSOZIPListAlgorithm */
384+
/* GDALVSISOZIPListAlgorithm */
383385
/************************************************************************/
384386

385-
class GDALSOZIPListAlgorithm final : public GDALAlgorithm
387+
class GDALVSISOZIPListAlgorithm final : public GDALAlgorithm
386388
{
387389
public:
388390
static constexpr const char *NAME = "list";
389391
static constexpr const char *DESCRIPTION =
390392
"List content of a ZIP file, with SOZIP related information.";
391-
static constexpr const char *HELP_URL = "/programs/gdal_sozip.html";
393+
static constexpr const char *HELP_URL = "/programs/gdal_vsi_sozip.html";
392394

393-
GDALSOZIPListAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
395+
GDALVSISOZIPListAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
394396
{
395397
AddArg("input", 'i', _("Input ZIP filename"), &m_zipFilename)
396398
.SetRequired()
@@ -406,10 +408,10 @@ class GDALSOZIPListAlgorithm final : public GDALAlgorithm
406408
};
407409

408410
/************************************************************************/
409-
/* GDALSOZIPListAlgorithm::RunImpl() */
411+
/* GDALVSISOZIPListAlgorithm::RunImpl() */
410412
/************************************************************************/
411413

412-
bool GDALSOZIPListAlgorithm::RunImpl(GDALProgressFunc, void *)
414+
bool GDALVSISOZIPListAlgorithm::RunImpl(GDALProgressFunc, void *)
413415
{
414416
std::unique_ptr<VSIDIR, decltype(&VSICloseDir)> psDir(
415417
VSIOpenDir(std::string("/vsizip/").append(m_zipFilename).c_str(), -1,
@@ -471,18 +473,18 @@ bool GDALSOZIPListAlgorithm::RunImpl(GDALProgressFunc, void *)
471473
}
472474

473475
/************************************************************************/
474-
/* GDALSOZIPValidateAlgorithm */
476+
/* GDALVSISOZIPValidateAlgorithm */
475477
/************************************************************************/
476478

477-
class GDALSOZIPValidateAlgorithm final : public GDALAlgorithm
479+
class GDALVSISOZIPValidateAlgorithm final : public GDALAlgorithm
478480
{
479481
public:
480482
static constexpr const char *NAME = "validate";
481483
static constexpr const char *DESCRIPTION =
482484
"Validate a ZIP file, possibly using SOZIP optimization.";
483-
static constexpr const char *HELP_URL = "/programs/gdal_sozip.html";
485+
static constexpr const char *HELP_URL = "/programs/gdal_vsi_sozip.html";
484486

485-
GDALSOZIPValidateAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
487+
GDALVSISOZIPValidateAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
486488
{
487489
AddArg("input", 'i', _("Input ZIP filename"), &m_zipFilename)
488490
.SetRequired()
@@ -523,10 +525,10 @@ class GDALSOZIPValidateAlgorithm final : public GDALAlgorithm
523525
};
524526

525527
/************************************************************************/
526-
/* GDALSOZIPValidateAlgorithm::RunImpl() */
528+
/* GDALVSISOZIPValidateAlgorithm::RunImpl() */
527529
/************************************************************************/
528530

529-
bool GDALSOZIPValidateAlgorithm::RunImpl(GDALProgressFunc, void *)
531+
bool GDALVSISOZIPValidateAlgorithm::RunImpl(GDALProgressFunc, void *)
530532
{
531533
std::unique_ptr<VSIDIR, decltype(&VSICloseDir)> psDir(
532534
VSIOpenDir(std::string("/vsizip/").append(m_zipFilename).c_str(), -1,
@@ -839,35 +841,16 @@ bool GDALSOZIPValidateAlgorithm::RunImpl(GDALProgressFunc, void *)
839841
}
840842

841843
/************************************************************************/
842-
/* GDALSOZIPAlgorithm */
844+
/* GDALVSISOZIPAlgorithm::GDALVSISOZIPAlgorithm() */
843845
/************************************************************************/
844846

845-
class GDALSOZIPAlgorithm final : public GDALAlgorithm
847+
GDALVSISOZIPAlgorithm::GDALVSISOZIPAlgorithm()
848+
: GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
846849
{
847-
public:
848-
static constexpr const char *NAME = "sozip";
849-
static constexpr const char *DESCRIPTION =
850-
"Seek-optimized ZIP (SOZIP) commands.";
851-
static constexpr const char *HELP_URL = "/programs/gdal_sozip.html";
852-
853-
GDALSOZIPAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
854-
{
855-
RegisterSubAlgorithm<GDALSOZIPCreateAlgorithm>();
856-
RegisterSubAlgorithm<GDALSOZIPOptimizeAlgorithm>();
857-
RegisterSubAlgorithm<GDALSOZIPListAlgorithm>();
858-
RegisterSubAlgorithm<GDALSOZIPValidateAlgorithm>();
859-
}
860-
861-
private:
862-
bool RunImpl(GDALProgressFunc, void *) override
863-
{
864-
CPLError(CE_Failure, CPLE_AppDefined,
865-
"The Run() method should not be called directly on the \"gdal "
866-
"sozip\" program.");
867-
return false;
868-
}
869-
};
870-
871-
GDAL_STATIC_REGISTER_ALG(GDALSOZIPAlgorithm);
850+
RegisterSubAlgorithm<GDALVSISOZIPCreateAlgorithm>();
851+
RegisterSubAlgorithm<GDALVSISOZIPOptimizeAlgorithm>();
852+
RegisterSubAlgorithm<GDALVSISOZIPListAlgorithm>();
853+
RegisterSubAlgorithm<GDALVSISOZIPValidateAlgorithm>();
854+
}
872855

873856
//! @endcond

apps/gdalalg_vsi_sozip.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/******************************************************************************
2+
*
3+
* Project: GDAL
4+
* Purpose: gdal "vsi sozip" subcommand
5+
* Author: Even Rouault <even dot rouault at spatialys.com>
6+
*
7+
******************************************************************************
8+
* Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
9+
*
10+
* SPDX-License-Identifier: MIT
11+
****************************************************************************/
12+
13+
#include "gdalalgorithm.h"
14+
15+
//! @cond Doxygen_Suppress
16+
17+
/************************************************************************/
18+
/* GDALVSISOZIPAlgorithm */
19+
/************************************************************************/
20+
21+
class GDALVSISOZIPAlgorithm final : public GDALAlgorithm
22+
{
23+
public:
24+
static constexpr const char *NAME = "sozip";
25+
static constexpr const char *DESCRIPTION =
26+
"Seek-optimized ZIP (SOZIP) commands.";
27+
static constexpr const char *HELP_URL = "/programs/gdal_vsi_sozip.html";
28+
29+
GDALVSISOZIPAlgorithm();
30+
31+
private:
32+
bool RunImpl(GDALProgressFunc, void *) override
33+
{
34+
CPLError(CE_Failure, CPLE_AppDefined,
35+
"The Run() method should not be called directly on the \"gdal "
36+
"sozip\" program.");
37+
return false;
38+
}
39+
};

0 commit comments

Comments
 (0)