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.

75 lines
1.6 KiB

  1. /*
  2. ISC License
  3. Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted, provided that the above
  6. copyright notice and this permission notice appear in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. */
  15. #pragma once
  16. #include <string>
  17. #include <fcntl.h>
  18. #include <sys/stat.h>
  19. #include <sys/types.h>
  20. namespace fs
  21. {
  22. static
  23. inline
  24. int
  25. open(const char *path_,
  26. const int flags_)
  27. {
  28. return ::open(path_,flags_);
  29. }
  30. static
  31. inline
  32. int
  33. open(const char *path_,
  34. const int flags_,
  35. const mode_t mode_)
  36. {
  37. return ::open(path_,flags_,mode_);
  38. }
  39. static
  40. inline
  41. int
  42. open(const std::string &path_,
  43. const int flags_)
  44. {
  45. return fs::open(path_.c_str(),flags_);
  46. }
  47. static
  48. inline
  49. int
  50. open(const std::string &path_,
  51. const int flags_,
  52. const mode_t mode_)
  53. {
  54. return fs::open(path_.c_str(),flags_,mode_);
  55. }
  56. static
  57. inline
  58. int
  59. open_dir_ro(const std::string &path_)
  60. {
  61. return fs::open(path_,O_RDONLY|O_DIRECTORY);
  62. }
  63. }