You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.4 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: platformstl/filesystem/filesystem_traits.hpp
  3. *
  4. * Purpose: Platform header for the filesystem_traits components.
  5. *
  6. * Created: 20th March 2005
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2005-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file platformstl/filesystem/filesystem_traits.hpp
  40. *
  41. * \brief [C++ only] Definition of the platformstl::filesystem_traits
  42. * type
  43. * (\ref group__library__filesystem "File System" Library).
  44. */
  45. #ifndef PLATFORMSTL_INCL_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
  46. #define PLATFORMSTL_INCL_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
  47. /* File version */
  48. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  49. # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MAJOR 2
  50. # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MINOR 1
  51. # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 1
  52. # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 19
  53. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * Includes
  56. */
  57. #ifndef PLATFORMSTL_INCL_PLATFORMSTL_FILESYSTEM_HPP_PLATFORMSTL
  58. # include <platformstl/platformstl.hpp>
  59. #endif /* !PLATFORMSTL_INCL_PLATFORMSTL_FILESYSTEM_HPP_PLATFORMSTL */
  60. #if defined(PLATFORMSTL_OS_IS_UNIX)
  61. # ifndef UNIXSTL_INCL_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
  62. # include <unixstl/filesystem/filesystem_traits.hpp>
  63. # endif /* !UNIXSTL_INCL_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS */
  64. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  65. # ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
  66. # include <winstl/filesystem/filesystem_traits.hpp>
  67. # endif /* !WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS */
  68. #else /* ? operating system */
  69. # error Operating system not discriminated
  70. #endif /* operating system */
  71. /* /////////////////////////////////////////////////////////////////////////
  72. * Namespace
  73. */
  74. #if defined(_STLSOFT_NO_NAMESPACE) || \
  75. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  76. /* There is no stlsoft namespace, so must define ::platformstl */
  77. namespace platformstl
  78. {
  79. #else
  80. /* Define stlsoft::platformstl_project */
  81. namespace stlsoft
  82. {
  83. namespace platformstl_project
  84. {
  85. #endif /* _STLSOFT_NO_NAMESPACE */
  86. /* ////////////////////////////////////////////////////////////////////// */
  87. #if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  88. /** \brief Traits class for file-system operations.
  89. *
  90. * \ingroup group__library__filesystem
  91. *
  92. * The class is not actually defined in the
  93. * \link ::platformstl platformstl\endlink namespace. Rather, it
  94. * resolves to the appropriate type for the given platform, relying on
  95. * \ref section__principle__conformance__intersecting_conformance "Intersecting Conformance"
  96. * of the resolved platform-specific types.
  97. *
  98. * When compiling on UNIX platforms, the platformstl::filesystem_traits
  99. * type resolves to the unixstl::filesystem_traits class. On Windows
  100. * platforms it resolves to the winstl::filesystem_traits class. It
  101. * is not defined for other platforms.
  102. */
  103. template< ss_typename_param_k C
  104. >
  105. class filesystem_traits
  106. {};
  107. #elif defined(PLATFORMSTL_OS_IS_UNIX)
  108. // Because early incarnations of Visual C++ are pretty stupid, we need to
  109. // work around their inability to introduce a template via using by
  110. // defining and deriving here
  111. # if defined(STLSOFT_COMPILER_IS_MSVC) && \
  112. _MSC_VER < 1310
  113. template <ss_typename_param_k C>
  114. struct filesystem_traits;
  115. STLSOFT_TEMPLATE_SPECIALISATION
  116. struct filesystem_traits<unixstl_ns_qual(us_char_a_t)>
  117. : public unixstl_ns_qual(filesystem_traits)<unixstl_ns_qual(us_char_a_t)>
  118. {};
  119. #if 0
  120. STLSOFT_TEMPLATE_SPECIALISATION
  121. struct filesystem_traits<unixstl_ns_qual(us_char_w_t)>
  122. : public unixstl_ns_qual(filesystem_traits)<unixstl_ns_qual(us_char_w_t)>
  123. {};
  124. #endif /* 0 */
  125. # else /* ? compiler */
  126. # ifdef _UNIXSTL_NO_NAMESPACE
  127. using ::filesystem_traits;
  128. # else /* ? _UNIXSTL_NO_NAMESPACE */
  129. using ::unixstl::filesystem_traits;
  130. # endif /* _UNIXSTL_NO_NAMESPACE */
  131. # endif /* compiler */
  132. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  133. // Because early incarnations of Visual C++ are pretty stupid, we need to
  134. // work around their inability to introduce a template via using by
  135. // defining and deriving here
  136. # if defined(STLSOFT_COMPILER_IS_MSVC) && \
  137. _MSC_VER < 1310
  138. template <ss_typename_param_k C>
  139. struct filesystem_traits;
  140. STLSOFT_TEMPLATE_SPECIALISATION
  141. struct filesystem_traits<winstl_ns_qual(ws_char_a_t)>
  142. : public winstl_ns_qual(filesystem_traits)<winstl_ns_qual(ws_char_a_t)>
  143. {};
  144. STLSOFT_TEMPLATE_SPECIALISATION
  145. struct filesystem_traits<winstl_ns_qual(ws_char_w_t)>
  146. : public winstl_ns_qual(filesystem_traits)<winstl_ns_qual(ws_char_w_t)>
  147. {};
  148. # else /* ? compiler */
  149. # ifdef _WINSTL_NO_NAMESPACE
  150. using ::filesystem_traits;
  151. # else /* ? _WINSTL_NO_NAMESPACE */
  152. using ::winstl::filesystem_traits;
  153. # endif /* _WINSTL_NO_NAMESPACE */
  154. # endif /* compiler */
  155. #else /* ? operating system */
  156. # error Operating system not discriminated
  157. #endif /* operating system */
  158. /* ////////////////////////////////////////////////////////////////////// */
  159. #if defined(_STLSOFT_NO_NAMESPACE) || \
  160. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  161. } // namespace platformstl
  162. #else
  163. } // namespace platformstl_project
  164. } // namespace stlsoft
  165. #endif /* _STLSOFT_NO_NAMESPACE */
  166. /* ////////////////////////////////////////////////////////////////////// */
  167. #endif /* !PLATFORMSTL_INCL_PLATFORMSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS */
  168. /* ///////////////////////////// end of file //////////////////////////// */