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.
 
 
 

50 lines
967 B

  1. #pragma once
  2. #include <asyncpp/core/future/future.h>
  3. #include "directory.h"
  4. namespace asyncpp {
  5. namespace fs {
  6. namespace __directory {
  7. template<
  8. chaining_mode X_mode,
  9. typename X_self>
  10. inline auto create_impl(X_self&& p_self)
  11. {
  12. return lazy([self = std::forward<X_self>(p_self)] {
  13. if (!self.handle.exists())
  14. self.handle.create(false);
  15. return self; // TODO: use std::forward
  16. });
  17. }
  18. } } }
  19. namespace asyncpp {
  20. namespace fs {
  21. /* directory::create */
  22. template<chaining_mode X_mode>
  23. auto directory
  24. ::create() &
  25. {
  26. return __directory::create_impl<X_mode>(*this);
  27. }
  28. template<chaining_mode X_mode>
  29. auto directory
  30. ::create() &&
  31. {
  32. static_assert(
  33. X_mode != ref,
  34. "Can not store rvalue reference as lvalue reference!");
  35. return __directory::create_impl<X_mode>(std::move(*this));
  36. }
  37. } }