TempFile.h 596 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2020-2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Noncopyable.h>
  8. #include <AK/String.h>
  9. namespace Core {
  10. class TempFile {
  11. AK_MAKE_NONCOPYABLE(TempFile);
  12. AK_MAKE_NONMOVABLE(TempFile);
  13. public:
  14. enum class Type {
  15. File,
  16. Directory
  17. };
  18. static NonnullOwnPtr<TempFile> create(Type = Type::File);
  19. ~TempFile();
  20. String path() const { return m_path; }
  21. private:
  22. TempFile(Type);
  23. static String create_temp(Type);
  24. Type m_type { Type::File };
  25. String m_path;
  26. };
  27. }