sculpt: support for creating small files

This commit is contained in:
Norman Feske 2023-03-20 17:43:44 +01:00 committed by Christian Helmuth
parent 9834849e95
commit fb1865eb91

View File

@ -23,6 +23,11 @@ namespace Sculpt { struct File_operation_queue; }
struct Sculpt::File_operation_queue : Noncopyable
{
/*
* Content for 'new_small_file', as used for creating depot-user meta data
*/
struct Content { String<256> string; };
struct Operation : Interface
{
enum class State {
@ -32,16 +37,21 @@ struct Sculpt::File_operation_queue : Noncopyable
State state { State::PENDING };
enum class Type { REMOVE_FILE, COPY_ALL_FILES } type;
enum class Type { REMOVE_FILE, COPY_ALL_FILES, NEW_SMALL_FILE } type;
Path const from { };
Path const path; /* destination */
Content const content { };
Operation(Type type, Path const &path) : type(type), path(path) { }
Operation(Type type, Path const &from, Path const &to)
: type(type), from(from), path(to) { }
Operation(Path const &path, Content const &content)
: type(Type::NEW_SMALL_FILE), path(path), content(content) { }
void gen_fs_tool_config(Xml_generator &xml) const
{
if (state != State::IN_PROGRESS)
@ -59,6 +69,12 @@ struct Sculpt::File_operation_queue : Noncopyable
xml.attribute("from", from);
xml.attribute("to", path); });
break;
case Type::NEW_SMALL_FILE:
xml.node("new-file", [&] {
xml.attribute("path", path);
xml.append_sanitized(content.string.string()); });
break;
}
}
};
@ -100,6 +116,11 @@ struct Sculpt::File_operation_queue : Noncopyable
return result;
}
void new_small_file(Path const &path, Content const &content)
{
new (_alloc) Registered<Operation>(_operations, path, content);
}
bool any_operation_in_progress() const
{
bool any_in_progress = false;