summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibFileSystem/TempFile.h
blob: 038978f91656a96e9bb933ec6be221e596a75d67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2020-2023, the SerenityOS developers.
 * Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Forward.h>
#include <AK/String.h>

namespace FileSystem {

class TempFile {

public:
    static ErrorOr<NonnullOwnPtr<TempFile>> create_temp_directory();
    static ErrorOr<NonnullOwnPtr<TempFile>> create_temp_file();

    ~TempFile();

    String const& path() const { return m_path; }

private:
    enum class Type {
        Directory,
        File
    };

    TempFile(Type type, String path)
        : m_type(type)
        , m_path(move(path))
    {
    }

    Type m_type;
    String m_path;
};

}