syscall.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef NATIVE_LIBHDFSPP_LIB_CROSS_PLATFORM_SYSCALL
  19. #define NATIVE_LIBHDFSPP_LIB_CROSS_PLATFORM_SYSCALL
  20. #include <string>
  21. /**
  22. * The {@link XPlatform} namespace contains components that
  23. * aid in writing cross-platform code.
  24. */
  25. namespace XPlatform {
  26. class Syscall {
  27. public:
  28. /**
  29. * Writes the given string to the application's
  30. * standard output stream.
  31. *
  32. * @param message The string to write to stdout.
  33. * @returns A boolean indicating whether the write
  34. * was successful.
  35. */
  36. static bool WriteToStdout(const std::string& message);
  37. /**
  38. * Writes the given char pointer to the application's
  39. * standard output stream.
  40. *
  41. * @param message The char pointer to write to stdout.
  42. * @returns A boolean indicating whether the write
  43. * was successful.
  44. */
  45. static int WriteToStdout(const char* message);
  46. /**
  47. * Checks whether the {@link str} argument matches the {@link pattern}
  48. * argument, which is a shell wildcard pattern.
  49. *
  50. * @param pattern The wildcard pattern to use.
  51. * @param str The string to match.
  52. * @returns A boolean indicating whether the given {@link str}
  53. * matches {@link pattern}.
  54. */
  55. static bool FnMatch(const std::string& pattern, const std::string& str);
  56. private:
  57. static bool WriteToStdoutImpl(const char* message);
  58. };
  59. } // namespace XPlatform
  60. #endif