diff options
author | Cameron Youell <cameronyouell@gmail.com> | 2023-03-22 02:36:18 +1100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-21 19:03:21 +0000 |
commit | 752f06f228119a70c59e844dcd2b9560e757b0ff (patch) | |
tree | 639eb770fb4db090adc69bfa77a19655fea4fa77 /Userland/Libraries | |
parent | 492e5c3c14e4c15c2a655b876f4c77c1df30bb00 (diff) | |
download | serenity-752f06f228119a70c59e844dcd2b9560e757b0ff.zip |
LibFileSystem: Move `TempFile` from `LibCore` to `LibFileSystem`
As suggested in commit de18485
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibFileSystem/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibFileSystem/TempFile.cpp (renamed from Userland/Libraries/LibCore/TempFile.cpp) | 32 | ||||
-rw-r--r-- | Userland/Libraries/LibFileSystem/TempFile.h (renamed from Userland/Libraries/LibCore/TempFile.h) | 6 |
4 files changed, 20 insertions, 20 deletions
diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt index 6dee12a65c..1a5b3fcbd3 100644 --- a/Userland/Libraries/LibCore/CMakeLists.txt +++ b/Userland/Libraries/LibCore/CMakeLists.txt @@ -30,7 +30,6 @@ set(SOURCES System.cpp SystemServerTakeover.cpp TCPServer.cpp - TempFile.cpp Timer.cpp UDPServer.cpp Version.cpp diff --git a/Userland/Libraries/LibFileSystem/CMakeLists.txt b/Userland/Libraries/LibFileSystem/CMakeLists.txt index 1e4e1871ff..e9ec24bdbf 100644 --- a/Userland/Libraries/LibFileSystem/CMakeLists.txt +++ b/Userland/Libraries/LibFileSystem/CMakeLists.txt @@ -1,5 +1,6 @@ set(SOURCES FileSystem.cpp + TempFile.cpp ) serenity_lib(LibFileSystem filesystem) diff --git a/Userland/Libraries/LibCore/TempFile.cpp b/Userland/Libraries/LibFileSystem/TempFile.cpp index 8558847e43..9f433acaea 100644 --- a/Userland/Libraries/LibCore/TempFile.cpp +++ b/Userland/Libraries/LibFileSystem/TempFile.cpp @@ -1,14 +1,27 @@ /* * Copyright (c) 2020-2023, the SerenityOS developers. + * Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com> * * SPDX-License-Identifier: BSD-2-Clause */ -#include "TempFile.h" -#include <LibCore/DeprecatedFile.h> #include <LibCore/System.h> +#include <LibFileSystem/FileSystem.h> +#include <LibFileSystem/TempFile.h> -namespace Core { +namespace FileSystem { + +TempFile::~TempFile() +{ + // Temporary files aren't removed by anyone else, so we must do it ourselves. + auto recursion_mode = RecursionMode::Disallowed; + if (m_type == Type::Directory) + recursion_mode = RecursionMode::Allowed; + + auto result = FileSystem::remove(m_path, recursion_mode); + if (result.is_error()) + warnln("Removal of temporary file failed '{}': {}", m_path, result.error().string_literal()); +} ErrorOr<NonnullOwnPtr<TempFile>> TempFile::create_temp_directory() { @@ -27,17 +40,4 @@ ErrorOr<NonnullOwnPtr<TempFile>> TempFile::create_temp_file() return adopt_nonnull_own_or_enomem(new (nothrow) TempFile(Type::File, string)); } -TempFile::~TempFile() -{ - // Temporary files aren't removed by anyone else, so we must do it ourselves. - auto recursion_mode = DeprecatedFile::RecursionMode::Disallowed; - if (m_type == Type::Directory) - recursion_mode = DeprecatedFile::RecursionMode::Allowed; - - auto result = DeprecatedFile::remove(m_path, recursion_mode); - if (result.is_error()) { - warnln("Removal of temporary file failed: {}", result.error().string_literal()); - } -} - } diff --git a/Userland/Libraries/LibCore/TempFile.h b/Userland/Libraries/LibFileSystem/TempFile.h index ac1743a165..038978f916 100644 --- a/Userland/Libraries/LibCore/TempFile.h +++ b/Userland/Libraries/LibFileSystem/TempFile.h @@ -1,16 +1,16 @@ /* * 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/Error.h> -#include <AK/NonnullOwnPtr.h> +#include <AK/Forward.h> #include <AK/String.h> -namespace Core { +namespace FileSystem { class TempFile { |