include/llfio/v2.0/file_handle.hpp
/*! Create a file 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 file. Note also
  that caching defaults to temporary which hints to the OS to only
  flush changes to physical storage as lately as possible.

  \errors Any of the values POSIX open() or CreateFile() can return.
  */
Create a file 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 file. Note also
that caching defaults to temporary which hints to the OS to only
flush changes to physical storage as lately as possible.

\errors Any of the values POSIX open() or CreateFile() can return.
Create a file 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 file . Note also that caching defaults to temporary which hints to the OS to only flush changes to physical storage as lately as possible . \ errors Any of the values POSIX open () or CreateFile () can return .
LLFIO_MAKE_FREE_FUNCTION
  static inline result<file_handle> uniquely_named_file(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);
        randomname.append(".random");
        result<file_handle> ret = file(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 < file_handle > uniquely_named_file ( 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 ) ; randomname . append ( " " ) ; result < file_handle > ret = file ( 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 file handle creating a uniquely named file on a path.
Create a file handle creating a uniquely named file on a path .