TempFile.h 701 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2020-2023, the SerenityOS developers.
  3. * Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Forward.h>
  9. #include <AK/String.h>
  10. namespace FileSystem {
  11. class TempFile {
  12. public:
  13. static ErrorOr<NonnullOwnPtr<TempFile>> create_temp_directory();
  14. static ErrorOr<NonnullOwnPtr<TempFile>> create_temp_file();
  15. ~TempFile();
  16. String const& path() const { return m_path; }
  17. private:
  18. enum class Type {
  19. Directory,
  20. File
  21. };
  22. TempFile(Type type, String path)
  23. : m_type(type)
  24. , m_path(move(path))
  25. {
  26. }
  27. Type m_type;
  28. String m_path;
  29. };
  30. }