summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/TempFile.h
blob: d691365a0445f68dda895bf6cc7062fea7e05b96 (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
/*
 * Copyright (c) 2020-2021, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

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

namespace Core {

class TempFile {
    AK_MAKE_NONCOPYABLE(TempFile);
    AK_MAKE_NONMOVABLE(TempFile);

public:
    enum class Type {
        File,
        Directory
    };

    static NonnullOwnPtr<TempFile> create(Type = Type::File);
    ~TempFile();

    String path() const { return m_path; }

private:
    TempFile(Type);
    static String create_temp(Type);

    Type m_type { Type::File };
    String m_path;
};

}