version.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _VERSION_H
  2. #define _VERSION_H
  3. // These variables are autogenerated and compiled
  4. // into the library by the version.cmake script
  5. extern "C"
  6. {
  7. extern const char* GIT_TAG;
  8. extern const char* GIT_REV;
  9. extern const char* GIT_BRANCH;
  10. extern const char* BUILD_TIME;
  11. }
  12. #include <string>
  13. #include <string.h>
  14. #include "Helper.h"
  15. #include <fstream>
  16. const char* build_time(void)
  17. {
  18. return BUILD_TIME;
  19. }
  20. const char* libfive_git_version(void)
  21. {
  22. return GIT_TAG;
  23. }
  24. const char* libfive_git_revision(void)
  25. {
  26. return GIT_REV;
  27. }
  28. const char* libfive_git_branch(void)
  29. {
  30. return GIT_BRANCH;
  31. }
  32. std::string getHTMLversion(void){
  33. char buf[100]="?\0";
  34. FILE* pFile;
  35. string fn = FormatFileName("/sdcard/html/version.txt");
  36. pFile = fopen(fn.c_str(), "r");
  37. if (pFile == NULL)
  38. return std::string(buf);
  39. fgets(buf, sizeof(buf), pFile); // Line 1: Version
  40. fclose(pFile);
  41. return std::string(buf);
  42. }
  43. std::string getHTMLcommit(void){
  44. char buf[100]="?\0";
  45. FILE* pFile;
  46. string fn = FormatFileName("/sdcard/html/version.txt");
  47. pFile = fopen(fn.c_str(), "r");
  48. if (pFile == NULL)
  49. return std::string(buf);
  50. fgets(buf, sizeof(buf), pFile); // Line 1: Version -> ignored
  51. fgets(buf, sizeof(buf), pFile); // Line 2: Commit
  52. fclose(pFile);
  53. return std::string(buf);
  54. }
  55. #endif // _VERSION_H