2022-01-07 09:22:39 -05:00
|
|
|
/*
|
2023-03-17 20:05:35 -04:00
|
|
|
* Copyright (c) 2020-2023, the SerenityOS developers.
|
2023-03-21 11:36:18 -04:00
|
|
|
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
|
2022-01-07 09:22:39 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-03-21 11:36:18 -04:00
|
|
|
#include <AK/Forward.h>
|
2023-03-17 20:05:35 -04:00
|
|
|
#include <AK/String.h>
|
2022-01-07 09:22:39 -05:00
|
|
|
|
2023-03-21 11:36:18 -04:00
|
|
|
namespace FileSystem {
|
2022-01-07 09:22:39 -05:00
|
|
|
|
|
|
|
class TempFile {
|
|
|
|
|
|
|
|
public:
|
2023-03-17 20:05:35 -04:00
|
|
|
static ErrorOr<NonnullOwnPtr<TempFile>> create_temp_directory();
|
|
|
|
static ErrorOr<NonnullOwnPtr<TempFile>> create_temp_file();
|
2022-01-07 09:22:39 -05:00
|
|
|
|
|
|
|
~TempFile();
|
|
|
|
|
2023-03-17 20:05:35 -04:00
|
|
|
String const& path() const { return m_path; }
|
2022-01-07 09:22:39 -05:00
|
|
|
|
|
|
|
private:
|
2023-03-17 20:05:35 -04:00
|
|
|
enum class Type {
|
|
|
|
Directory,
|
|
|
|
File
|
|
|
|
};
|
|
|
|
|
|
|
|
TempFile(Type type, String path)
|
|
|
|
: m_type(type)
|
|
|
|
, m_path(move(path))
|
|
|
|
{
|
|
|
|
}
|
2022-01-07 09:22:39 -05:00
|
|
|
|
2023-03-17 20:05:35 -04:00
|
|
|
Type m_type;
|
|
|
|
String m_path;
|
2022-01-07 09:22:39 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|