fileutilities.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef FILEUTILITIES_H
  2. #define FILEUTILITIES_H
  3. #include <QList>
  4. #include <QPair>
  5. #include <QSharedPointer>
  6. class QDir;
  7. #include "generatoroutputview.h"
  8. #include "generatordata.h"
  9. #include "hybridplugin.h"
  10. #include "defines.h"
  11. class FileUtilities
  12. {
  13. public:
  14. FileUtilities(GeneratorOutputView &outputView, GeneratorData &generatorData);
  15. bool updateMainFile();
  16. bool updateMainWindowFile();
  17. bool updateProjectFile(QString filename);
  18. void createWidgetResourceFile();
  19. bool createWidgetProjectFile(const QList< QSharedPointer<HybridPlugin> > &plugins);
  20. bool createPluginsProjectFile(const QList< QSharedPointer<HybridPlugin> > &plugins);
  21. bool configXmlToInfoPlistFile(WidgetType widgetType);
  22. bool directoryToInfoPlistFile();
  23. QString getMainHTMLFileFullPath();
  24. QString getWidgetIdentifier();
  25. /**
  26. * Finds a file recursively under a directory.
  27. *
  28. * @param dir under which the file is to be found, directly or
  29. * indirectly
  30. *
  31. * @param fileName the name of the file to be found.
  32. *
  33. * @return the absolute path to the file, if found, empty string
  34. * otherwise.
  35. */
  36. static QString findFile(const QDir & dir,
  37. const QString & fileName);
  38. /**
  39. * Makes sure that tmpDir exists and it is empty.
  40. */
  41. static bool clearUpDir(QDir tmpDir);
  42. /**
  43. * Unzips a widget file to a directory. Blocking (sync) call.
  44. *
  45. * @return true iff successful
  46. */
  47. static bool syncUnzipWidgetFile(const QString & wgzFile,
  48. const QString & unzipDir);
  49. /**
  50. * Figures out the app name(s) for a widget File.
  51. *
  52. * @param widgetFilePath path to a widget file or widget directory
  53. *
  54. * @return a pair of <app-name, app-display-name> values.
  55. */
  56. static QPair<QString, QString> sniffAppNames(const QString & widgetFilePath);
  57. private:
  58. bool readTemplateFile(const QString &fileName, QString &fileContent, const QString &onErrorMessage);
  59. void processTemplateProjectFileLine(QString &templateFileLine);
  60. GeneratorOutputView &m_outputView;
  61. GeneratorData &m_generatorData;
  62. QString m_infoPlistFileNameNoSpaces;
  63. };
  64. #endif // FILEUTILITIES_H