include/llfio/v2.0/directory_handle.hpp
/*! Create a directory handle creating a uniquely named file on a path.
  The file is opened exclusively with `creation::only_if_not_exist` so it
  will never collide with nor overwrite any existing entry.

  \errors Any of the values POSIX open() or CreateFile() can return.
  */
Create a directory handle creating a uniquely named file on a path.
The file is opened exclusively with `creation::only_if_not_exist` so it
will never collide with nor overwrite any existing entry.

\errors Any of the values POSIX open() or CreateFile() can return.
Create a directory handle creating a uniquely named file on a path . The file is opened exclusively with ` creation :: only_if_not_exist ` so it will never collide with nor overwrite any existing entry . \ errors Any of the values POSIX open () or CreateFile () can return .
LLFIO_MAKE_FREE_FUNCTION
  static inline result<directory_handle> uniquely_named_directory(const path_handle &dirpath, mode _mode = mode::write, caching _caching = caching::temporary, flag flags = flag::none) noexcept
  {
    try
    {
      for(;;)
      {
        auto randomname = utils::random_string(32);
        result<directory_handle> ret = directory(dirpath, randomname, _mode, creation::only_if_not_exist, _caching, flags);
        if(ret || (!ret && ret.error() != errc::file_exists))
        {
          return ret;
        }
      }
    }
    catch(...)
    {
      return error_from_exception();
    }
  }
LLFIO_MAKE_FREE_FUNCTION static inline result < directory_handle > uniquely_named_directory ( const path_handle & dirpath , mode _mode = mode :: write , caching _caching = caching :: temporary , flag flags = flag :: none ) noexcept { try { for ( ; ; ) { auto randomname = utils :: random_string ( 32 ) ; result < directory_handle > ret = directory ( dirpath , randomname , _mode , creation :: only_if_not_exist , _caching , flags ) ; if ( ret || ( ! ret && ret . error ( ) != errc :: file_exists ) ) { return ret ; } } } catch ( ... ) { return error_from_exception ( ) ; } }
Create a directory handle creating a uniquely named file on a path.
Create a directory handle creating a uniquely named file on a path .