cmCPackDragNDropGenerator.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <cstddef>
  6. #include <sstream>
  7. #include <string>
  8. #include <vector>
  9. #include "cmCPackGenerator.h"
  10. class cmGeneratedFileStream;
  11. class cmXMLWriter;
  12. /** \class cmCPackDragNDropGenerator
  13. * \brief A generator for OSX drag-n-drop installs
  14. */
  15. class cmCPackDragNDropGenerator : public cmCPackGenerator
  16. {
  17. public:
  18. cmCPackTypeMacro(cmCPackDragNDropGenerator, cmCPackGenerator);
  19. cmCPackDragNDropGenerator();
  20. ~cmCPackDragNDropGenerator() override;
  21. protected:
  22. int InitializeInternal() override;
  23. const char* GetOutputExtension() override;
  24. int PackageFiles() override;
  25. bool SupportsComponentInstallation() const override;
  26. bool CopyFile(std::ostringstream& source, std::ostringstream& target);
  27. bool CreateEmptyFile(std::ostringstream& target, size_t size);
  28. bool RunCommand(std::string const& command, std::string* output = nullptr);
  29. std::string GetComponentInstallDirNameSuffix(
  30. const std::string& componentName) override;
  31. int CreateDMG(const std::string& src_dir, const std::string& output_file);
  32. private:
  33. std::string slaDirectory;
  34. bool singleLicense;
  35. struct RezDict
  36. {
  37. std::string Name;
  38. size_t ID;
  39. std::vector<unsigned char> Data;
  40. };
  41. struct RezArray
  42. {
  43. std::string Key;
  44. std::vector<RezDict> Entries;
  45. };
  46. struct RezDoc
  47. {
  48. RezArray LPic = { "LPic", {} };
  49. RezArray Menu = { "STR#", {} };
  50. RezArray Text = { "TEXT", {} };
  51. RezArray RTF = { "RTF ", {} };
  52. };
  53. void WriteRezXML(std::string const& file, RezDoc const& rez);
  54. void WriteRezArray(cmXMLWriter& xml, RezArray const& array);
  55. void WriteRezDict(cmXMLWriter& xml, RezDict const& dict);
  56. bool WriteLicense(RezDoc& rez, size_t licenseNumber,
  57. std::string licenseLanguage,
  58. const std::string& licenseFile, std::string* error);
  59. void EncodeLicense(RezDict& dict, std::vector<std::string> const& lines);
  60. void EncodeMenu(RezDict& dict, std::vector<std::string> const& lines);
  61. bool ReadFile(std::string const& file, std::vector<std::string>& lines,
  62. std::string* error);
  63. bool BreakLongLine(const std::string& line, std::vector<std::string>& lines,
  64. std::string* error);
  65. };