clickhouse-native 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clickhouse_native/client.cpp +847 -0
  3. data/ext/clickhouse_native/extconf.rb +101 -0
  4. data/ext/clickhouse_native/vendor/clickhouse-cpp/.clang-format +11 -0
  5. data/ext/clickhouse_native/vendor/clickhouse-cpp/.git +1 -0
  6. data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitattributes +63 -0
  7. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/CODEOWNERS +1 -0
  8. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/linux.yml +139 -0
  9. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/macos.yml +87 -0
  10. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_mingw.yml +102 -0
  11. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_msvc.yml +74 -0
  12. data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitignore +280 -0
  13. data/ext/clickhouse_native/vendor/clickhouse-cpp/.travis.yml +62 -0
  14. data/ext/clickhouse_native/vendor/clickhouse-cpp/CMakeLists.txt +157 -0
  15. data/ext/clickhouse_native/vendor/clickhouse-cpp/LICENSE +206 -0
  16. data/ext/clickhouse_native/vendor/clickhouse-cpp/README.md +260 -0
  17. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt +246 -0
  18. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/buffer.h +10 -0
  19. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp +258 -0
  20. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.h +48 -0
  21. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.cpp +20 -0
  22. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.h +34 -0
  23. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.cpp +96 -0
  24. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.h +103 -0
  25. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/open_telemetry.h +23 -0
  26. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.cpp +119 -0
  27. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.h +142 -0
  28. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.cpp +1 -0
  29. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.h +33 -0
  30. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/projected_iterator.h +55 -0
  31. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/singleton.h +11 -0
  32. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.cpp +489 -0
  33. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.h +177 -0
  34. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.cpp +307 -0
  35. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.h +111 -0
  36. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_utils.h +28 -0
  37. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_view.h +142 -0
  38. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/uuid.h +10 -0
  39. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.cpp +177 -0
  40. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.h +79 -0
  41. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.cpp +134 -0
  42. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.h +114 -0
  43. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.cpp +1269 -0
  44. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.h +320 -0
  45. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.cpp +175 -0
  46. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.h +321 -0
  47. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.cpp +24 -0
  48. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.h +107 -0
  49. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.cpp +365 -0
  50. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.h +245 -0
  51. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp +255 -0
  52. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.h +50 -0
  53. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp +123 -0
  54. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.h +65 -0
  55. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp +285 -0
  56. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.h +14 -0
  57. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.cpp +108 -0
  58. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.h +79 -0
  59. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.cpp +117 -0
  60. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.h +71 -0
  61. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.cpp +108 -0
  62. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.h +66 -0
  63. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.cpp +101 -0
  64. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.h +86 -0
  65. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp +527 -0
  66. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.h +221 -0
  67. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinalityadaptor.h +63 -0
  68. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.cpp +87 -0
  69. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.h +257 -0
  70. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nothing.h +87 -0
  71. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.cpp +109 -0
  72. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.h +153 -0
  73. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.cpp +126 -0
  74. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.h +88 -0
  75. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.cpp +333 -0
  76. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.h +145 -0
  77. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.cpp +155 -0
  78. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.h +118 -0
  79. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.cpp +106 -0
  80. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.h +178 -0
  81. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/utils.h +41 -0
  82. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.cpp +80 -0
  83. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.h +58 -0
  84. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/error_codes.h +595 -0
  85. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/exceptions.h +66 -0
  86. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/protocol.h +54 -0
  87. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.cpp +25 -0
  88. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.h +246 -0
  89. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/server_exception.h +16 -0
  90. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.cpp +314 -0
  91. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.h +89 -0
  92. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.cpp +484 -0
  93. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.h +397 -0
  94. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/version.h +14 -0
  95. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findcityhash.cmake +26 -0
  96. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findlz4.cmake +39 -0
  97. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findzstd.cmake +39 -0
  98. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/cpp17.cmake +8 -0
  99. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/openssl.cmake +8 -0
  100. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/subdirs.cmake +5 -0
  101. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/version.cmake +87 -0
  102. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/CMakeLists.txt +9 -0
  103. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/attributes.h +682 -0
  104. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/config.h +714 -0
  105. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/internal/bits.h +219 -0
  106. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/macros.h +147 -0
  107. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/optimization.h +241 -0
  108. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/options.h +238 -0
  109. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/policy_checks.h +111 -0
  110. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/port.h +26 -0
  111. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.cc +390 -0
  112. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.h +1092 -0
  113. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_have_intrinsic.inc +302 -0
  114. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_no_intrinsic.inc +308 -0
  115. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/BUCK +13 -0
  116. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/CMakeLists.txt +7 -0
  117. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/COPYING +19 -0
  118. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.cc +469 -0
  119. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.h +90 -0
  120. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/citycrc.h +43 -0
  121. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/config.h +118 -0
  122. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/BUCK +14 -0
  123. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/CMakeLists.txt +4 -0
  124. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/LICENSE +28 -0
  125. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/README.md +1 -0
  126. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-death-test.h +346 -0
  127. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-matchers.h +930 -0
  128. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-message.h +219 -0
  129. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-param-test.h +507 -0
  130. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-printers.h +1029 -0
  131. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-spi.h +238 -0
  132. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-test-part.h +184 -0
  133. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-typed-test.h +329 -0
  134. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest.h +2495 -0
  135. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_pred_impl.h +359 -0
  136. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_prod.h +61 -0
  137. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/README.md +56 -0
  138. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-port.h +37 -0
  139. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-printers.h +42 -0
  140. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest.h +37 -0
  141. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-death-test-internal.h +304 -0
  142. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-filepath.h +211 -0
  143. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-internal.h +1560 -0
  144. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-param-util.h +947 -0
  145. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port-arch.h +114 -0
  146. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port.h +2389 -0
  147. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-string.h +175 -0
  148. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-type-util.h +183 -0
  149. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-all.cc +48 -0
  150. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-death-test.cc +1644 -0
  151. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-filepath.cc +369 -0
  152. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-internal-inl.h +1221 -0
  153. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-matchers.cc +97 -0
  154. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-port.cc +1433 -0
  155. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-printers.cc +533 -0
  156. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-test-part.cc +108 -0
  157. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-typed-test.cc +107 -0
  158. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest.cc +6746 -0
  159. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest_main.cc +54 -0
  160. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/BUCK +13 -0
  161. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/CMakeLists.txt +8 -0
  162. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/LICENSE +24 -0
  163. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.c +2402 -0
  164. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.h +764 -0
  165. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.c +1554 -0
  166. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.h +438 -0
  167. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/BUCK +232 -0
  168. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/CMakeLists.txt +115 -0
  169. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/LICENSE +30 -0
  170. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/allocations.h +55 -0
  171. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bits.h +200 -0
  172. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bitstream.h +437 -0
  173. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/compiler.h +358 -0
  174. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/cpu.h +213 -0
  175. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.c +24 -0
  176. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.h +107 -0
  177. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/entropy_common.c +340 -0
  178. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.c +63 -0
  179. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.h +159 -0
  180. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse.h +639 -0
  181. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse_decompress.c +311 -0
  182. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/huf.h +273 -0
  183. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/mem.h +435 -0
  184. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.c +371 -0
  185. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.h +90 -0
  186. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/portability_macros.h +156 -0
  187. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.c +176 -0
  188. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.h +150 -0
  189. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.c +24 -0
  190. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.h +5686 -0
  191. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_common.c +48 -0
  192. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_deps.h +111 -0
  193. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_internal.h +392 -0
  194. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_trace.h +163 -0
  195. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/clevels.h +134 -0
  196. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/fse_compress.c +624 -0
  197. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.c +181 -0
  198. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.h +75 -0
  199. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/huf_compress.c +1435 -0
  200. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress.c +7032 -0
  201. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_internal.h +1532 -0
  202. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.c +235 -0
  203. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.h +39 -0
  204. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.c +442 -0
  205. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.h +54 -0
  206. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.c +577 -0
  207. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.h +32 -0
  208. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_cwksp.h +742 -0
  209. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.c +758 -0
  210. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.h +39 -0
  211. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.c +960 -0
  212. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.h +38 -0
  213. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.c +2157 -0
  214. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.h +127 -0
  215. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.c +724 -0
  216. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.h +117 -0
  217. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm_geartab.h +106 -0
  218. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.c +1472 -0
  219. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.h +56 -0
  220. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.c +1867 -0
  221. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.h +113 -0
  222. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress.c +1882 -0
  223. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress_amd64.S +576 -0
  224. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.c +244 -0
  225. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.h +44 -0
  226. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress.c +2355 -0
  227. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.c +2192 -0
  228. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.h +73 -0
  229. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_internal.h +238 -0
  230. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.c +1257 -0
  231. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.h +158 -0
  232. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.c +1913 -0
  233. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.h +67 -0
  234. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/fastcover.c +766 -0
  235. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/zdict.c +1127 -0
  236. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_legacy.h +422 -0
  237. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.c +2125 -0
  238. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.h +94 -0
  239. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.c +3477 -0
  240. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.h +93 -0
  241. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.c +3117 -0
  242. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.h +93 -0
  243. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.c +3605 -0
  244. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.h +142 -0
  245. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.c +4004 -0
  246. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.h +162 -0
  247. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.c +4113 -0
  248. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.h +172 -0
  249. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.c +4498 -0
  250. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.h +187 -0
  251. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zdict.h +474 -0
  252. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd.h +3020 -0
  253. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd_errors.h +114 -0
  254. data/lib/clickhouse_native/clickhouse_native.bundle +0 -0
  255. data/lib/clickhouse_native/client.rb +50 -0
  256. data/lib/clickhouse_native/errors.rb +23 -0
  257. data/lib/clickhouse_native/pool.rb +49 -0
  258. data/lib/clickhouse_native/version.rb +3 -0
  259. data/lib/clickhouse_native.rb +8 -0
  260. metadata +369 -0
@@ -0,0 +1,369 @@
1
+ // Copyright 2008, Google Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ #include "gtest/internal/gtest-filepath.h"
31
+
32
+ #include <stdlib.h>
33
+ #include "gtest/internal/gtest-port.h"
34
+ #include "gtest/gtest-message.h"
35
+
36
+ #if GTEST_OS_WINDOWS_MOBILE
37
+ # include <windows.h>
38
+ #elif GTEST_OS_WINDOWS
39
+ # include <direct.h>
40
+ # include <io.h>
41
+ #else
42
+ # include <limits.h>
43
+ # include <climits> // Some Linux distributions define PATH_MAX here.
44
+ #endif // GTEST_OS_WINDOWS_MOBILE
45
+
46
+ #include "gtest/internal/gtest-string.h"
47
+
48
+ #if GTEST_OS_WINDOWS
49
+ # define GTEST_PATH_MAX_ _MAX_PATH
50
+ #elif defined(PATH_MAX)
51
+ # define GTEST_PATH_MAX_ PATH_MAX
52
+ #elif defined(_XOPEN_PATH_MAX)
53
+ # define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
54
+ #else
55
+ # define GTEST_PATH_MAX_ _POSIX_PATH_MAX
56
+ #endif // GTEST_OS_WINDOWS
57
+
58
+ namespace testing {
59
+ namespace internal {
60
+
61
+ #if GTEST_OS_WINDOWS
62
+ // On Windows, '\\' is the standard path separator, but many tools and the
63
+ // Windows API also accept '/' as an alternate path separator. Unless otherwise
64
+ // noted, a file path can contain either kind of path separators, or a mixture
65
+ // of them.
66
+ const char kPathSeparator = '\\';
67
+ const char kAlternatePathSeparator = '/';
68
+ const char kAlternatePathSeparatorString[] = "/";
69
+ # if GTEST_OS_WINDOWS_MOBILE
70
+ // Windows CE doesn't have a current directory. You should not use
71
+ // the current directory in tests on Windows CE, but this at least
72
+ // provides a reasonable fallback.
73
+ const char kCurrentDirectoryString[] = "\\";
74
+ // Windows CE doesn't define INVALID_FILE_ATTRIBUTES
75
+ const DWORD kInvalidFileAttributes = 0xffffffff;
76
+ # else
77
+ const char kCurrentDirectoryString[] = ".\\";
78
+ # endif // GTEST_OS_WINDOWS_MOBILE
79
+ #else
80
+ const char kPathSeparator = '/';
81
+ const char kCurrentDirectoryString[] = "./";
82
+ #endif // GTEST_OS_WINDOWS
83
+
84
+ // Returns whether the given character is a valid path separator.
85
+ static bool IsPathSeparator(char c) {
86
+ #if GTEST_HAS_ALT_PATH_SEP_
87
+ return (c == kPathSeparator) || (c == kAlternatePathSeparator);
88
+ #else
89
+ return c == kPathSeparator;
90
+ #endif
91
+ }
92
+
93
+ // Returns the current working directory, or "" if unsuccessful.
94
+ FilePath FilePath::GetCurrentDir() {
95
+ #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
96
+ GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_ESP32 || \
97
+ GTEST_OS_XTENSA
98
+ // These platforms do not have a current directory, so we just return
99
+ // something reasonable.
100
+ return FilePath(kCurrentDirectoryString);
101
+ #elif GTEST_OS_WINDOWS
102
+ char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
103
+ return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
104
+ #else
105
+ char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
106
+ char* result = getcwd(cwd, sizeof(cwd));
107
+ # if GTEST_OS_NACL
108
+ // getcwd will likely fail in NaCl due to the sandbox, so return something
109
+ // reasonable. The user may have provided a shim implementation for getcwd,
110
+ // however, so fallback only when failure is detected.
111
+ return FilePath(result == nullptr ? kCurrentDirectoryString : cwd);
112
+ # endif // GTEST_OS_NACL
113
+ return FilePath(result == nullptr ? "" : cwd);
114
+ #endif // GTEST_OS_WINDOWS_MOBILE
115
+ }
116
+
117
+ // Returns a copy of the FilePath with the case-insensitive extension removed.
118
+ // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
119
+ // FilePath("dir/file"). If a case-insensitive extension is not
120
+ // found, returns a copy of the original FilePath.
121
+ FilePath FilePath::RemoveExtension(const char* extension) const {
122
+ const std::string dot_extension = std::string(".") + extension;
123
+ if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {
124
+ return FilePath(pathname_.substr(
125
+ 0, pathname_.length() - dot_extension.length()));
126
+ }
127
+ return *this;
128
+ }
129
+
130
+ // Returns a pointer to the last occurrence of a valid path separator in
131
+ // the FilePath. On Windows, for example, both '/' and '\' are valid path
132
+ // separators. Returns NULL if no path separator was found.
133
+ const char* FilePath::FindLastPathSeparator() const {
134
+ const char* const last_sep = strrchr(c_str(), kPathSeparator);
135
+ #if GTEST_HAS_ALT_PATH_SEP_
136
+ const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);
137
+ // Comparing two pointers of which only one is NULL is undefined.
138
+ if (last_alt_sep != nullptr &&
139
+ (last_sep == nullptr || last_alt_sep > last_sep)) {
140
+ return last_alt_sep;
141
+ }
142
+ #endif
143
+ return last_sep;
144
+ }
145
+
146
+ // Returns a copy of the FilePath with the directory part removed.
147
+ // Example: FilePath("path/to/file").RemoveDirectoryName() returns
148
+ // FilePath("file"). If there is no directory part ("just_a_file"), it returns
149
+ // the FilePath unmodified. If there is no file part ("just_a_dir/") it
150
+ // returns an empty FilePath ("").
151
+ // On Windows platform, '\' is the path separator, otherwise it is '/'.
152
+ FilePath FilePath::RemoveDirectoryName() const {
153
+ const char* const last_sep = FindLastPathSeparator();
154
+ return last_sep ? FilePath(last_sep + 1) : *this;
155
+ }
156
+
157
+ // RemoveFileName returns the directory path with the filename removed.
158
+ // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
159
+ // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
160
+ // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
161
+ // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
162
+ // On Windows platform, '\' is the path separator, otherwise it is '/'.
163
+ FilePath FilePath::RemoveFileName() const {
164
+ const char* const last_sep = FindLastPathSeparator();
165
+ std::string dir;
166
+ if (last_sep) {
167
+ dir = std::string(c_str(), static_cast<size_t>(last_sep + 1 - c_str()));
168
+ } else {
169
+ dir = kCurrentDirectoryString;
170
+ }
171
+ return FilePath(dir);
172
+ }
173
+
174
+ // Helper functions for naming files in a directory for xml output.
175
+
176
+ // Given directory = "dir", base_name = "test", number = 0,
177
+ // extension = "xml", returns "dir/test.xml". If number is greater
178
+ // than zero (e.g., 12), returns "dir/test_12.xml".
179
+ // On Windows platform, uses \ as the separator rather than /.
180
+ FilePath FilePath::MakeFileName(const FilePath& directory,
181
+ const FilePath& base_name,
182
+ int number,
183
+ const char* extension) {
184
+ std::string file;
185
+ if (number == 0) {
186
+ file = base_name.string() + "." + extension;
187
+ } else {
188
+ file = base_name.string() + "_" + StreamableToString(number)
189
+ + "." + extension;
190
+ }
191
+ return ConcatPaths(directory, FilePath(file));
192
+ }
193
+
194
+ // Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".
195
+ // On Windows, uses \ as the separator rather than /.
196
+ FilePath FilePath::ConcatPaths(const FilePath& directory,
197
+ const FilePath& relative_path) {
198
+ if (directory.IsEmpty())
199
+ return relative_path;
200
+ const FilePath dir(directory.RemoveTrailingPathSeparator());
201
+ return FilePath(dir.string() + kPathSeparator + relative_path.string());
202
+ }
203
+
204
+ // Returns true if pathname describes something findable in the file-system,
205
+ // either a file, directory, or whatever.
206
+ bool FilePath::FileOrDirectoryExists() const {
207
+ #if GTEST_OS_WINDOWS_MOBILE
208
+ LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
209
+ const DWORD attributes = GetFileAttributes(unicode);
210
+ delete [] unicode;
211
+ return attributes != kInvalidFileAttributes;
212
+ #else
213
+ posix::StatStruct file_stat{};
214
+ return posix::Stat(pathname_.c_str(), &file_stat) == 0;
215
+ #endif // GTEST_OS_WINDOWS_MOBILE
216
+ }
217
+
218
+ // Returns true if pathname describes a directory in the file-system
219
+ // that exists.
220
+ bool FilePath::DirectoryExists() const {
221
+ bool result = false;
222
+ #if GTEST_OS_WINDOWS
223
+ // Don't strip off trailing separator if path is a root directory on
224
+ // Windows (like "C:\\").
225
+ const FilePath& path(IsRootDirectory() ? *this :
226
+ RemoveTrailingPathSeparator());
227
+ #else
228
+ const FilePath& path(*this);
229
+ #endif
230
+
231
+ #if GTEST_OS_WINDOWS_MOBILE
232
+ LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
233
+ const DWORD attributes = GetFileAttributes(unicode);
234
+ delete [] unicode;
235
+ if ((attributes != kInvalidFileAttributes) &&
236
+ (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
237
+ result = true;
238
+ }
239
+ #else
240
+ posix::StatStruct file_stat{};
241
+ result = posix::Stat(path.c_str(), &file_stat) == 0 &&
242
+ posix::IsDir(file_stat);
243
+ #endif // GTEST_OS_WINDOWS_MOBILE
244
+
245
+ return result;
246
+ }
247
+
248
+ // Returns true if pathname describes a root directory. (Windows has one
249
+ // root directory per disk drive.)
250
+ bool FilePath::IsRootDirectory() const {
251
+ #if GTEST_OS_WINDOWS
252
+ return pathname_.length() == 3 && IsAbsolutePath();
253
+ #else
254
+ return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);
255
+ #endif
256
+ }
257
+
258
+ // Returns true if pathname describes an absolute path.
259
+ bool FilePath::IsAbsolutePath() const {
260
+ const char* const name = pathname_.c_str();
261
+ #if GTEST_OS_WINDOWS
262
+ return pathname_.length() >= 3 &&
263
+ ((name[0] >= 'a' && name[0] <= 'z') ||
264
+ (name[0] >= 'A' && name[0] <= 'Z')) &&
265
+ name[1] == ':' &&
266
+ IsPathSeparator(name[2]);
267
+ #else
268
+ return IsPathSeparator(name[0]);
269
+ #endif
270
+ }
271
+
272
+ // Returns a pathname for a file that does not currently exist. The pathname
273
+ // will be directory/base_name.extension or
274
+ // directory/base_name_<number>.extension if directory/base_name.extension
275
+ // already exists. The number will be incremented until a pathname is found
276
+ // that does not already exist.
277
+ // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
278
+ // There could be a race condition if two or more processes are calling this
279
+ // function at the same time -- they could both pick the same filename.
280
+ FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
281
+ const FilePath& base_name,
282
+ const char* extension) {
283
+ FilePath full_pathname;
284
+ int number = 0;
285
+ do {
286
+ full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
287
+ } while (full_pathname.FileOrDirectoryExists());
288
+ return full_pathname;
289
+ }
290
+
291
+ // Returns true if FilePath ends with a path separator, which indicates that
292
+ // it is intended to represent a directory. Returns false otherwise.
293
+ // This does NOT check that a directory (or file) actually exists.
294
+ bool FilePath::IsDirectory() const {
295
+ return !pathname_.empty() &&
296
+ IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);
297
+ }
298
+
299
+ // Create directories so that path exists. Returns true if successful or if
300
+ // the directories already exist; returns false if unable to create directories
301
+ // for any reason.
302
+ bool FilePath::CreateDirectoriesRecursively() const {
303
+ if (!this->IsDirectory()) {
304
+ return false;
305
+ }
306
+
307
+ if (pathname_.length() == 0 || this->DirectoryExists()) {
308
+ return true;
309
+ }
310
+
311
+ const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());
312
+ return parent.CreateDirectoriesRecursively() && this->CreateFolder();
313
+ }
314
+
315
+ // Create the directory so that path exists. Returns true if successful or
316
+ // if the directory already exists; returns false if unable to create the
317
+ // directory for any reason, including if the parent directory does not
318
+ // exist. Not named "CreateDirectory" because that's a macro on Windows.
319
+ bool FilePath::CreateFolder() const {
320
+ #if GTEST_OS_WINDOWS_MOBILE
321
+ FilePath removed_sep(this->RemoveTrailingPathSeparator());
322
+ LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
323
+ int result = CreateDirectory(unicode, nullptr) ? 0 : -1;
324
+ delete [] unicode;
325
+ #elif GTEST_OS_WINDOWS
326
+ int result = _mkdir(pathname_.c_str());
327
+ #elif GTEST_OS_ESP8266 || GTEST_OS_XTENSA
328
+ // do nothing
329
+ int result = 0;
330
+ #else
331
+ int result = mkdir(pathname_.c_str(), 0777);
332
+ #endif // GTEST_OS_WINDOWS_MOBILE
333
+
334
+ if (result == -1) {
335
+ return this->DirectoryExists(); // An error is OK if the directory exists.
336
+ }
337
+ return true; // No error.
338
+ }
339
+
340
+ // If input name has a trailing separator character, remove it and return the
341
+ // name, otherwise return the name string unmodified.
342
+ // On Windows platform, uses \ as the separator, other platforms use /.
343
+ FilePath FilePath::RemoveTrailingPathSeparator() const {
344
+ return IsDirectory()
345
+ ? FilePath(pathname_.substr(0, pathname_.length() - 1))
346
+ : *this;
347
+ }
348
+
349
+ // Removes any redundant separators that might be in the pathname.
350
+ // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
351
+ // redundancies that might be in a pathname involving "." or "..".
352
+ void FilePath::Normalize() {
353
+ auto out = pathname_.begin();
354
+
355
+ for (const char character : pathname_) {
356
+ if (!IsPathSeparator(character)) {
357
+ *(out++) = character;
358
+ } else if (out == pathname_.begin() || *std::prev(out) != kPathSeparator) {
359
+ *(out++) = kPathSeparator;
360
+ } else {
361
+ continue;
362
+ }
363
+ }
364
+
365
+ pathname_.erase(out, pathname_.end());
366
+ }
367
+
368
+ } // namespace internal
369
+ } // namespace testing