/src/gdal/apps/gdalalg_vsi_list.h
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: GDAL |
4 | | * Purpose: gdal "vsi list" 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 | | #ifndef GDALALG_VSI_LIST_INCLUDED |
14 | | #define GDALALG_VSI_LIST_INCLUDED |
15 | | |
16 | | #include "gdalalgorithm.h" |
17 | | |
18 | | #include "cpl_json_streaming_writer.h" |
19 | | |
20 | | //! @cond Doxygen_Suppress |
21 | | |
22 | | /************************************************************************/ |
23 | | /* GDALVSIListAlgorithm */ |
24 | | /************************************************************************/ |
25 | | |
26 | | struct VSIDIREntry; |
27 | | |
28 | | class GDALVSIListAlgorithm final : public GDALAlgorithm |
29 | | { |
30 | | public: |
31 | | static constexpr const char *NAME = "list"; |
32 | | static constexpr const char *DESCRIPTION = |
33 | | "List files of one of the GDAL Virtual System Interface (VSI)."; |
34 | | static constexpr const char *HELP_URL = "/programs/gdal_vsi_list.html"; |
35 | | |
36 | | static std::vector<std::string> GetAliasesStatic() |
37 | 0 | { |
38 | 0 | return {"ls"}; |
39 | 0 | } |
40 | | |
41 | | GDALVSIListAlgorithm(); |
42 | | |
43 | | private: |
44 | | CPLJSonStreamingWriter m_oWriter; |
45 | | std::string m_filename{}; |
46 | | std::string m_format{}; |
47 | | std::string m_output{}; |
48 | | int m_depth = -1; |
49 | | bool m_stdout = false; |
50 | | bool m_longListing = false; |
51 | | bool m_recursive = false; |
52 | | bool m_JSONAsTree = false; |
53 | | bool m_absolutePath = false; |
54 | | |
55 | | std::vector<std::string> m_stackNames{}; |
56 | | |
57 | | bool RunImpl(GDALProgressFunc, void *) override; |
58 | | void Print(const char *str); |
59 | | void PrintEntry(const VSIDIREntry *entry); |
60 | | static void JSONPrint(const char *pszTxt, void *pUserData); |
61 | | }; |
62 | | |
63 | | //! @endcond |
64 | | |
65 | | #endif |