1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 05:44:58 +00:00

AppFile: Add helpers for dealing with AppFile paths

This commit is contained in:
david072 2023-11-04 19:31:08 +01:00 committed by Andreas Kling
parent 5af6e1c042
commit 124611b256
3 changed files with 17 additions and 3 deletions

View file

@ -12,13 +12,23 @@
#include <LibCore/DirIterator.h>
#include <LibCore/Process.h>
#include <LibDesktop/AppFile.h>
#include <LibFileSystem/FileSystem.h>
namespace Desktop {
DeprecatedString AppFile::app_file_path_for_app(StringView app_name)
{
return DeprecatedString::formatted("{}/{}.af", APP_FILES_DIRECTORY, app_name);
}
bool AppFile::exists_for_app(StringView app_name)
{
return FileSystem::exists(app_file_path_for_app(app_name));
}
NonnullRefPtr<AppFile> AppFile::get_for_app(StringView app_name)
{
auto path = DeprecatedString::formatted("{}/{}.af", APP_FILES_DIRECTORY, app_name);
return open(path);
return open(app_file_path_for_app(app_name));
}
NonnullRefPtr<AppFile> AppFile::open(StringView path)

View file

@ -17,6 +17,10 @@ class AppFile : public RefCounted<AppFile> {
public:
static constexpr auto APP_FILES_DIRECTORY = "/res/apps"sv;
static bool exists_for_app(StringView app_name);
static DeprecatedString file_for_app(StringView app_name);
static DeprecatedString app_file_path_for_app(StringView app_name);
static NonnullRefPtr<AppFile> get_for_app(StringView app_name);
static NonnullRefPtr<AppFile> open(StringView path);
static void for_each(Function<void(NonnullRefPtr<AppFile>)>, StringView directory = APP_FILES_DIRECTORY);

View file

@ -10,4 +10,4 @@ set(GENERATED_SOURCES
)
serenity_lib(LibDesktop desktop)
target_link_libraries(LibDesktop PRIVATE LibCore LibIPC LibGfx LibGUI)
target_link_libraries(LibDesktop PRIVATE LibCore LibIPC LibGfx LibGUI LibFileSystem)