GHOST_ISystemPaths.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software Foundation,
  14. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. *
  16. * The Original Code is Copyright (C) 2009 Blender Foundation.
  17. * All rights reserved.
  18. */
  19. /** \file
  20. * \ingroup GHOST
  21. */
  22. #ifndef __GHOST_ISYSTEMPATHS_H__
  23. #define __GHOST_ISYSTEMPATHS_H__
  24. #include "GHOST_Types.h"
  25. class GHOST_ISystemPaths {
  26. public:
  27. /**
  28. * Creates the one and only system.
  29. * \return An indication of success.
  30. */
  31. static GHOST_TSuccess create();
  32. /**
  33. * Disposes the one and only system.
  34. * \return An indication of success.
  35. */
  36. static GHOST_TSuccess dispose();
  37. /**
  38. * Returns a pointer to the one and only system (nil if it hasn't been created).
  39. * \return A pointer to the system.
  40. */
  41. static GHOST_ISystemPaths *get();
  42. protected:
  43. /**
  44. * Constructor.
  45. * Protected default constructor to force use of static createSystem member.
  46. */
  47. GHOST_ISystemPaths()
  48. {
  49. }
  50. /**
  51. * Destructor.
  52. * Protected default constructor to force use of static dispose member.
  53. */
  54. virtual ~GHOST_ISystemPaths()
  55. {
  56. }
  57. public:
  58. /**
  59. * Determine the base dir in which shared resources are located. It will first try to use
  60. * "unpack and run" path, then look for properly installed path, including versioning.
  61. * \return Unsigned char string pointing to system dir (eg /usr/share/blender/).
  62. */
  63. virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const = 0;
  64. /**
  65. * Determine the base dir in which user configuration is stored, including versioning.
  66. * If needed, it will create the base directory.
  67. * \return Unsigned char string pointing to user dir (eg ~/.blender/).
  68. */
  69. virtual const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const = 0;
  70. /**
  71. * Determine the directory of the current binary
  72. * \return Unsigned char string pointing to the binary dir
  73. */
  74. virtual const GHOST_TUns8 *getBinaryDir() const = 0;
  75. /**
  76. * Add the file to the operating system most recently used files
  77. */
  78. virtual void addToSystemRecentFiles(const char *filename) const = 0;
  79. private:
  80. /** The one and only system paths*/
  81. static GHOST_ISystemPaths *m_systemPaths;
  82. #ifdef WITH_CXX_GUARDEDALLOC
  83. MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystemPaths")
  84. #endif
  85. };
  86. #endif