Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "vfs 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_VFS_LIST_INCLUDED 14 : #define GDALALG_VFS_LIST_INCLUDED 15 : 16 : #include "gdalalgorithm.h" 17 : 18 : #include "cpl_json_streaming_writer.h" 19 : 20 : //! @cond Doxygen_Suppress 21 : 22 : /************************************************************************/ 23 : /* GDALVFSListAlgorithm */ 24 : /************************************************************************/ 25 : 26 : struct VSIDIREntry; 27 : 28 : class GDALVFSListAlgorithm 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 file systems (VSI)."; 34 : static constexpr const char *HELP_URL = "/programs/gdal_vfs_list.html"; 35 : 36 40 : static std::vector<std::string> GetAliasesStatic() 37 : { 38 80 : return {"ls"}; 39 : } 40 : 41 : GDALVFSListAlgorithm(); 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