mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
Everywhere: "file name" => "filename"
This commit is contained in:
parent
def1f1444a
commit
7ae7170d61
59 changed files with 181 additions and 181 deletions
|
@ -16,7 +16,7 @@ namespace AK {
|
||||||
class SourceLocation {
|
class SourceLocation {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] constexpr StringView function_name() const { return StringView(m_function); }
|
[[nodiscard]] constexpr StringView function_name() const { return StringView(m_function); }
|
||||||
[[nodiscard]] constexpr StringView file_name() const { return StringView(m_file); }
|
[[nodiscard]] constexpr StringView filename() const { return StringView(m_file); }
|
||||||
[[nodiscard]] constexpr u32 line_number() const { return m_line; }
|
[[nodiscard]] constexpr u32 line_number() const { return m_line; }
|
||||||
|
|
||||||
[[nodiscard]] static constexpr SourceLocation current(const char* const file = __builtin_FILE(), u32 line = __builtin_LINE(), const char* const function = __builtin_FUNCTION())
|
[[nodiscard]] static constexpr SourceLocation current(const char* const file = __builtin_FILE(), u32 line = __builtin_LINE(), const char* const function = __builtin_FUNCTION())
|
||||||
|
@ -45,7 +45,7 @@ template<>
|
||||||
struct AK::Formatter<AK::SourceLocation> : AK::Formatter<FormatString> {
|
struct AK::Formatter<AK::SourceLocation> : AK::Formatter<FormatString> {
|
||||||
void format(FormatBuilder& builder, AK::SourceLocation location)
|
void format(FormatBuilder& builder, AK::SourceLocation location)
|
||||||
{
|
{
|
||||||
return AK::Formatter<FormatString>::format(builder, "[{} @ {}:{}]", location.function_name(), location.file_name(), location.line_number());
|
return AK::Formatter<FormatString>::format(builder, "[{} @ {}:{}]", location.function_name(), location.filename(), location.line_number());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
TEST_CASE(basic_scenario)
|
TEST_CASE(basic_scenario)
|
||||||
{
|
{
|
||||||
auto location = SourceLocation::current();
|
auto location = SourceLocation::current();
|
||||||
EXPECT_EQ(StringView(__FILE__), location.file_name());
|
EXPECT_EQ(StringView(__FILE__), location.filename());
|
||||||
EXPECT_EQ(StringView(__FUNCTION__), location.function_name());
|
EXPECT_EQ(StringView(__FUNCTION__), location.function_name());
|
||||||
EXPECT_EQ(__LINE__ - 3u, location.line_number());
|
EXPECT_EQ(__LINE__ - 3u, location.line_number());
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,7 +664,7 @@ struct ext2_dir_entry {
|
||||||
__u32 inode; /* Inode number */
|
__u32 inode; /* Inode number */
|
||||||
__u16 rec_len; /* Directory entry length */
|
__u16 rec_len; /* Directory entry length */
|
||||||
__u16 name_len; /* Name length */
|
__u16 name_len; /* Name length */
|
||||||
char name[EXT2_NAME_LEN]; /* File name */
|
char name[EXT2_NAME_LEN]; /* Filename */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -678,7 +678,7 @@ struct ext2_dir_entry_2 {
|
||||||
__u16 rec_len; /* Directory entry length */
|
__u16 rec_len; /* Directory entry length */
|
||||||
__u8 name_len; /* Name length */
|
__u8 name_len; /* Name length */
|
||||||
__u8 file_type;
|
__u8 file_type;
|
||||||
char name[EXT2_NAME_LEN]; /* File name */
|
char name[EXT2_NAME_LEN]; /* Filename */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -362,7 +362,7 @@ void Thread::finalize()
|
||||||
ScopedSpinLock list_lock(m_holding_locks_lock);
|
ScopedSpinLock list_lock(m_holding_locks_lock);
|
||||||
for (auto& info : m_holding_locks_list) {
|
for (auto& info : m_holding_locks_list) {
|
||||||
const auto& location = info.source_location;
|
const auto& location = info.source_location;
|
||||||
dbgln(" - Lock: \"{}\" @ {} locked in function \"{}\" at \"{}:{}\" with a count of: {}", info.lock->name(), info.lock, location.function_name(), location.file_name(), location.line_number(), info.count);
|
dbgln(" - Lock: \"{}\" @ {} locked in function \"{}\" at \"{}:{}\" with a count of: {}", info.lock->name(), info.lock, location.function_name(), location.filename(), location.line_number(), info.count);
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ def report(filename, problem):
|
||||||
"""Print a lint problem to stdout.
|
"""Print a lint problem to stdout.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str): keymap file name
|
filename (str): keymap filename
|
||||||
problem (str): problem message
|
problem (str): problem message
|
||||||
"""
|
"""
|
||||||
print('{}: {}'.format(filename, problem))
|
print('{}: {}'.format(filename, problem))
|
||||||
|
@ -25,7 +25,7 @@ def validate_single_map(filename, mapname, values):
|
||||||
"""Validate a key map.
|
"""Validate a key map.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str): keymap file name
|
filename (str): keymap filename
|
||||||
mapname (str): map name (altgr_map, alt_map, shift_altgr_map)
|
mapname (str): map name (altgr_map, alt_map, shift_altgr_map)
|
||||||
values (list): key values
|
values (list): key values
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ def validate_fullmap(filename, fullmap):
|
||||||
"""Validate a full key map for all map names (including maps for key modifiers).
|
"""Validate a full key map for all map names (including maps for key modifiers).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str): keymap file name
|
filename (str): keymap filename
|
||||||
fullmap (dict): key mappings
|
fullmap (dict): key mappings
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -126,7 +126,7 @@ def list_files_here():
|
||||||
"""Retrieve a list of all '.json' files in the working directory.
|
"""Retrieve a list of all '.json' files in the working directory.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list: JSON file names
|
list: JSON filenames
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filelist = []
|
filelist = []
|
||||||
|
|
|
@ -31,7 +31,7 @@ def read_port_table(filename):
|
||||||
"""Open a file and find all PORT_TABLE_REGEX matches.
|
"""Open a file and find all PORT_TABLE_REGEX matches.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str): file name
|
filename (str): filename
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
set: all PORT_TABLE_REGEX matches
|
set: all PORT_TABLE_REGEX matches
|
||||||
|
|
|
@ -90,7 +90,7 @@ static bool insert_breakpoint_at_source_position(const String& file, size_t line
|
||||||
warnln("Could not insert breakpoint at {}:{}", file, line);
|
warnln("Could not insert breakpoint at {}:{}", file, line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outln("Breakpoint inserted [{}:{} ({}:{:p})]", result.value().file_name, result.value().line_number, result.value().library_name, result.value().address);
|
outln("Breakpoint inserted [{}:{} ({}:{:p})]", result.value().filename, result.value().line_number, result.value().library_name, result.value().address);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,14 +134,14 @@ String FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_
|
||||||
return String::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining);
|
return String::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, [[maybe_unused]] off_t current_file_done, [[maybe_unused]] off_t current_file_size, const StringView& current_file_name)
|
void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, [[maybe_unused]] off_t current_file_done, [[maybe_unused]] off_t current_file_size, const StringView& current_filename)
|
||||||
{
|
{
|
||||||
auto& files_copied_label = *find_descendant_of_type_named<GUI::Label>("files_copied_label");
|
auto& files_copied_label = *find_descendant_of_type_named<GUI::Label>("files_copied_label");
|
||||||
auto& current_file_label = *find_descendant_of_type_named<GUI::Label>("current_file_label");
|
auto& current_file_label = *find_descendant_of_type_named<GUI::Label>("current_file_label");
|
||||||
auto& overall_progressbar = *find_descendant_of_type_named<GUI::Progressbar>("overall_progressbar");
|
auto& overall_progressbar = *find_descendant_of_type_named<GUI::Progressbar>("overall_progressbar");
|
||||||
auto& estimated_time_label = *find_descendant_of_type_named<GUI::Label>("estimated_time_label");
|
auto& estimated_time_label = *find_descendant_of_type_named<GUI::Label>("estimated_time_label");
|
||||||
|
|
||||||
current_file_label.set_text(current_file_name);
|
current_file_label.set_text(current_filename);
|
||||||
|
|
||||||
files_copied_label.set_text(String::formatted("Copying file {} of {}", files_done, total_file_count));
|
files_copied_label.set_text(String::formatted("Copying file {} of {}", files_done, total_file_count));
|
||||||
estimated_time_label.set_text(estimate_time(bytes_done, total_byte_count));
|
estimated_time_label.set_text(estimate_time(bytes_done, total_byte_count));
|
||||||
|
|
|
@ -22,7 +22,7 @@ private:
|
||||||
|
|
||||||
void did_finish();
|
void did_finish();
|
||||||
void did_error(String message);
|
void did_error(String message);
|
||||||
void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, const StringView& current_file_name);
|
void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, const StringView& current_filename);
|
||||||
|
|
||||||
void close_pipe();
|
void close_pipe();
|
||||||
|
|
||||||
|
|
|
@ -123,12 +123,12 @@ void KeyboardMapperWidget::create_frame()
|
||||||
bottom_widget.layout()->add_spacer();
|
bottom_widget.layout()->add_spacer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardMapperWidget::load_from_file(String file_name)
|
void KeyboardMapperWidget::load_from_file(String filename)
|
||||||
{
|
{
|
||||||
auto result = Keyboard::CharacterMapFile::load_from_file(file_name);
|
auto result = Keyboard::CharacterMapFile::load_from_file(filename);
|
||||||
VERIFY(result.has_value());
|
VERIFY(result.has_value());
|
||||||
|
|
||||||
m_file_name = file_name;
|
m_filename = filename;
|
||||||
m_character_map = result.value();
|
m_character_map = result.value();
|
||||||
set_current_map("map");
|
set_current_map("map");
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ void KeyboardMapperWidget::load_from_system()
|
||||||
auto result = Keyboard::CharacterMap::fetch_system_map();
|
auto result = Keyboard::CharacterMap::fetch_system_map();
|
||||||
VERIFY(!result.is_error());
|
VERIFY(!result.is_error());
|
||||||
|
|
||||||
m_file_name = String::formatted("/res/keymaps/{}.json", result.value().character_map_name());
|
m_filename = String::formatted("/res/keymaps/{}.json", result.value().character_map_name());
|
||||||
m_character_map = result.value().character_map_data();
|
m_character_map = result.value().character_map_data();
|
||||||
set_current_map("map");
|
set_current_map("map");
|
||||||
|
|
||||||
|
@ -159,10 +159,10 @@ void KeyboardMapperWidget::load_from_system()
|
||||||
|
|
||||||
void KeyboardMapperWidget::save()
|
void KeyboardMapperWidget::save()
|
||||||
{
|
{
|
||||||
save_to_file(m_file_name);
|
save_to_file(m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardMapperWidget::save_to_file(const StringView& file_name)
|
void KeyboardMapperWidget::save_to_file(const StringView& filename)
|
||||||
{
|
{
|
||||||
JsonObject map_json;
|
JsonObject map_json;
|
||||||
|
|
||||||
|
@ -188,12 +188,12 @@ void KeyboardMapperWidget::save_to_file(const StringView& file_name)
|
||||||
// Write to file.
|
// Write to file.
|
||||||
String file_content = map_json.to_string();
|
String file_content = map_json.to_string();
|
||||||
|
|
||||||
auto file = Core::File::construct(file_name);
|
auto file = Core::File::construct(filename);
|
||||||
file->open(Core::IODevice::WriteOnly);
|
file->open(Core::IODevice::WriteOnly);
|
||||||
if (!file->is_open()) {
|
if (!file->is_open()) {
|
||||||
StringBuilder sb;
|
StringBuilder sb;
|
||||||
sb.append("Failed to open ");
|
sb.append("Failed to open ");
|
||||||
sb.append(file_name);
|
sb.append(filename);
|
||||||
sb.append(" for write. Error: ");
|
sb.append(" for write. Error: ");
|
||||||
sb.append(file->error_string());
|
sb.append(file->error_string());
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ void KeyboardMapperWidget::save_to_file(const StringView& file_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
m_file_name = file_name;
|
m_filename = filename;
|
||||||
update_window_title();
|
update_window_title();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ void KeyboardMapperWidget::set_current_map(const String current_map)
|
||||||
void KeyboardMapperWidget::update_window_title()
|
void KeyboardMapperWidget::update_window_title()
|
||||||
{
|
{
|
||||||
StringBuilder sb;
|
StringBuilder sb;
|
||||||
sb.append(m_file_name);
|
sb.append(m_filename);
|
||||||
if (m_modified)
|
if (m_modified)
|
||||||
sb.append(" (*)");
|
sb.append(" (*)");
|
||||||
sb.append(" - KeyboardMapper");
|
sb.append(" - KeyboardMapper");
|
||||||
|
|
|
@ -34,7 +34,7 @@ private:
|
||||||
Vector<KeyButton*> m_keys;
|
Vector<KeyButton*> m_keys;
|
||||||
RefPtr<GUI::Widget> m_map_group;
|
RefPtr<GUI::Widget> m_map_group;
|
||||||
|
|
||||||
String m_file_name;
|
String m_filename;
|
||||||
Keyboard::CharacterMapData m_character_map;
|
Keyboard::CharacterMapData m_character_map;
|
||||||
String m_current_map_name;
|
String m_current_map_name;
|
||||||
bool m_modified { false };
|
bool m_modified { false };
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
|
|
||||||
class CharacterMapFileListModel final : public GUI::Model {
|
class CharacterMapFileListModel final : public GUI::Model {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<CharacterMapFileListModel> create(Vector<String>& file_names)
|
static NonnullRefPtr<CharacterMapFileListModel> create(Vector<String>& filenames)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new CharacterMapFileListModel(file_names));
|
return adopt_ref(*new CharacterMapFileListModel(filenames));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~CharacterMapFileListModel() override { }
|
virtual ~CharacterMapFileListModel() override { }
|
||||||
|
|
||||||
virtual int row_count(const GUI::ModelIndex&) const override
|
virtual int row_count(const GUI::ModelIndex&) const override
|
||||||
{
|
{
|
||||||
return m_file_names.size();
|
return m_filenames.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int column_count(const GUI::ModelIndex&) const override
|
virtual int column_count(const GUI::ModelIndex&) const override
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
VERIFY(index.column() == 0);
|
VERIFY(index.column() == 0);
|
||||||
|
|
||||||
if (role == GUI::ModelRole::Display)
|
if (role == GUI::ModelRole::Display)
|
||||||
return m_file_names.at(index.row());
|
return m_filenames.at(index.row());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CharacterMapFileListModel(Vector<String>& file_names)
|
explicit CharacterMapFileListModel(Vector<String>& filenames)
|
||||||
: m_file_names(file_names)
|
: m_filenames(filenames)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<String>& m_file_names;
|
Vector<String>& m_filenames;
|
||||||
};
|
};
|
||||||
|
|
|
@ -329,7 +329,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
|
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
|
||||||
Core::File::ensure_parent_directories(config->file_name());
|
Core::File::ensure_parent_directories(config->filename());
|
||||||
|
|
||||||
pid_t shell_pid = 0;
|
pid_t shell_pid = 0;
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(config->file_name().characters(), "rwc") < 0) {
|
if (unveil(config->filename().characters(), "rwc") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,14 +675,14 @@ String HackStudioWidget::get_full_path_of_serenity_source(const String& file)
|
||||||
return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
|
return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& file_name)
|
RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& filename)
|
||||||
{
|
{
|
||||||
String file_path = file_name;
|
String file_path = filename;
|
||||||
|
|
||||||
// TODO: We can probably do a more specific condition here, something like
|
// TODO: We can probably do a more specific condition here, something like
|
||||||
// "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))"
|
// "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))"
|
||||||
if (file_name.starts_with("../")) {
|
if (filename.starts_with("../")) {
|
||||||
file_path = get_full_path_of_serenity_source(file_name);
|
file_path = get_full_path_of_serenity_source(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!open_file(file_path))
|
if (!open_file(file_path))
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
NonnullRefPtr<GUI::Action> create_set_autocomplete_mode_action();
|
NonnullRefPtr<GUI::Action> create_set_autocomplete_mode_action();
|
||||||
|
|
||||||
void add_new_editor(GUI::Widget& parent);
|
void add_new_editor(GUI::Widget& parent);
|
||||||
RefPtr<EditorWrapper> get_editor_of_file(const String& file_name);
|
RefPtr<EditorWrapper> get_editor_of_file(const String& filename);
|
||||||
String get_project_executable_path() const;
|
String get_project_executable_path() const;
|
||||||
|
|
||||||
void on_action_tab_change();
|
void on_action_tab_change();
|
||||||
|
|
|
@ -46,28 +46,28 @@ OwnPtr<Messages::LanguageServer::GreetResponse> ClientConnection::handle(const M
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
|
||||||
{
|
{
|
||||||
if (m_filedb.is_open(message.file_name())) {
|
if (m_filedb.is_open(message.filename())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_filedb.add(message.file_name(), message.file().take_fd());
|
m_filedb.add(message.filename(), message.file().take_fd());
|
||||||
m_autocomplete_engine->file_opened(message.file_name());
|
m_autocomplete_engine->file_opened(message.filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
|
||||||
{
|
{
|
||||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", message.file_name());
|
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", message.filename());
|
||||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", message.text());
|
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", message.text());
|
||||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{}]", message.start_line(), message.start_column());
|
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{}]", message.start_line(), message.start_column());
|
||||||
m_filedb.on_file_edit_insert_text(message.file_name(), message.text(), message.start_line(), message.start_column());
|
m_filedb.on_file_edit_insert_text(message.filename(), message.text(), message.start_line(), message.start_column());
|
||||||
m_autocomplete_engine->on_edit(message.file_name());
|
m_autocomplete_engine->on_edit(message.filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
|
||||||
{
|
{
|
||||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", message.file_name());
|
dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", message.filename());
|
||||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", message.start_line(), message.start_column(), message.end_line(), message.end_column());
|
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", message.start_line(), message.start_column(), message.end_line(), message.end_column());
|
||||||
m_filedb.on_file_edit_remove_text(message.file_name(), message.start_line(), message.start_column(), message.end_line(), message.end_column());
|
m_filedb.on_file_edit_remove_text(message.filename(), message.start_line(), message.start_column(), message.end_line(), message.end_column());
|
||||||
m_autocomplete_engine->on_edit(message.file_name());
|
m_autocomplete_engine->on_edit(message.filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
|
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
|
||||||
|
@ -87,17 +87,17 @@ void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSugges
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::SetFileContent& message)
|
void ClientConnection::handle(const Messages::LanguageServer::SetFileContent& message)
|
||||||
{
|
{
|
||||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", message.file_name());
|
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", message.filename());
|
||||||
auto document = m_filedb.get(message.file_name());
|
auto document = m_filedb.get(message.filename());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
m_filedb.add(message.file_name(), message.content());
|
m_filedb.add(message.filename(), message.content());
|
||||||
VERIFY(m_filedb.is_open(message.file_name()));
|
VERIFY(m_filedb.is_open(message.filename()));
|
||||||
} else {
|
} else {
|
||||||
const auto& content = message.content();
|
const auto& content = message.content();
|
||||||
document->set_text(content.view());
|
document->set_text(content.view());
|
||||||
}
|
}
|
||||||
VERIFY(m_filedb.is_open(message.file_name()));
|
VERIFY(m_filedb.is_open(message.filename()));
|
||||||
m_autocomplete_engine->on_edit(message.file_name());
|
m_autocomplete_engine->on_edit(message.filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FindDeclaration& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FindDeclaration& message)
|
||||||
|
|
|
@ -337,9 +337,9 @@ void ParserAutoComplete::file_opened([[maybe_unused]] const String& file)
|
||||||
set_document_data(file, create_document_data_for(file));
|
set_document_data(file, create_document_data_for(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<GUI::AutocompleteProvider::ProjectLocation> ParserAutoComplete::find_declaration_of(const String& file_name, const GUI::TextPosition& identifier_position)
|
Optional<GUI::AutocompleteProvider::ProjectLocation> ParserAutoComplete::find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position)
|
||||||
{
|
{
|
||||||
const auto* document_ptr = get_or_create_document_data(file_name);
|
const auto* document_ptr = get_or_create_document_data(filename);
|
||||||
if (!document_ptr)
|
if (!document_ptr)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
|
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
|
||||||
virtual void on_edit(const String& file) override;
|
virtual void on_edit(const String& file) override;
|
||||||
virtual void file_opened([[maybe_unused]] const String& file) override;
|
virtual void file_opened([[maybe_unused]] const String& file) override;
|
||||||
virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& file_name, const GUI::TextPosition& identifier_position) override;
|
virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DocumentData {
|
struct DocumentData {
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
namespace LanguageServers {
|
namespace LanguageServers {
|
||||||
|
|
||||||
RefPtr<const GUI::TextDocument> FileDB::get(const String& file_name) const
|
RefPtr<const GUI::TextDocument> FileDB::get(const String& filename) const
|
||||||
{
|
{
|
||||||
auto absolute_path = to_absolute_path(file_name);
|
auto absolute_path = to_absolute_path(filename);
|
||||||
auto document_optional = m_open_files.get(absolute_path);
|
auto document_optional = m_open_files.get(absolute_path);
|
||||||
if (!document_optional.has_value())
|
if (!document_optional.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -21,60 +21,60 @@ RefPtr<const GUI::TextDocument> FileDB::get(const String& file_name) const
|
||||||
return document_optional.value();
|
return document_optional.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<GUI::TextDocument> FileDB::get(const String& file_name)
|
RefPtr<GUI::TextDocument> FileDB::get(const String& filename)
|
||||||
{
|
{
|
||||||
auto document = reinterpret_cast<const FileDB*>(this)->get(file_name);
|
auto document = reinterpret_cast<const FileDB*>(this)->get(filename);
|
||||||
if (document.is_null())
|
if (document.is_null())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
|
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& file_name) const
|
RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& filename) const
|
||||||
{
|
{
|
||||||
auto absolute_path = to_absolute_path(file_name);
|
auto absolute_path = to_absolute_path(filename);
|
||||||
auto document = get(absolute_path);
|
auto document = get(absolute_path);
|
||||||
if (document)
|
if (document)
|
||||||
return document;
|
return document;
|
||||||
return create_from_filesystem(absolute_path);
|
return create_from_filesystem(absolute_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& file_name)
|
RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& filename)
|
||||||
{
|
{
|
||||||
auto document = reinterpret_cast<const FileDB*>(this)->get_or_create_from_filesystem(file_name);
|
auto document = reinterpret_cast<const FileDB*>(this)->get_or_create_from_filesystem(filename);
|
||||||
if (document.is_null())
|
if (document.is_null())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
|
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileDB::is_open(const String& file_name) const
|
bool FileDB::is_open(const String& filename) const
|
||||||
{
|
{
|
||||||
return m_open_files.contains(to_absolute_path(file_name));
|
return m_open_files.contains(to_absolute_path(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileDB::add(const String& file_name, int fd)
|
bool FileDB::add(const String& filename, int fd)
|
||||||
{
|
{
|
||||||
auto document = create_from_fd(fd);
|
auto document = create_from_fd(fd);
|
||||||
if (!document)
|
if (!document)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_open_files.set(to_absolute_path(file_name), document.release_nonnull());
|
m_open_files.set(to_absolute_path(filename), document.release_nonnull());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String FileDB::to_absolute_path(const String& file_name) const
|
String FileDB::to_absolute_path(const String& filename) const
|
||||||
{
|
{
|
||||||
if (LexicalPath { file_name }.is_absolute()) {
|
if (LexicalPath { filename }.is_absolute()) {
|
||||||
return file_name;
|
return filename;
|
||||||
}
|
}
|
||||||
VERIFY(!m_project_root.is_null());
|
VERIFY(!m_project_root.is_null());
|
||||||
return LexicalPath { String::formatted("{}/{}", m_project_root, file_name) }.string();
|
return LexicalPath { String::formatted("{}/{}", m_project_root, filename) }.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(const String& file_name) const
|
RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(const String& filename) const
|
||||||
{
|
{
|
||||||
auto file = Core::File::open(to_absolute_path(file_name), Core::IODevice::ReadOnly);
|
auto file = Core::File::open(to_absolute_path(filename), Core::IODevice::ReadOnly);
|
||||||
if (file.is_error()) {
|
if (file.is_error()) {
|
||||||
dbgln("failed to create document for {} from filesystem", file_name);
|
dbgln("failed to create document for {} from filesystem", filename);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return create_from_file(*file.value());
|
return create_from_file(*file.value());
|
||||||
|
@ -117,10 +117,10 @@ RefPtr<GUI::TextDocument> FileDB::create_from_file(Core::File& file) const
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDB::on_file_edit_insert_text(const String& file_name, const String& inserted_text, size_t start_line, size_t start_column)
|
void FileDB::on_file_edit_insert_text(const String& filename, const String& inserted_text, size_t start_line, size_t start_column)
|
||||||
{
|
{
|
||||||
VERIFY(is_open(file_name));
|
VERIFY(is_open(filename));
|
||||||
auto document = get(file_name);
|
auto document = get(filename);
|
||||||
VERIFY(document);
|
VERIFY(document);
|
||||||
GUI::TextPosition start_position { start_line, start_column };
|
GUI::TextPosition start_position { start_line, start_column };
|
||||||
document->insert_at(start_position, inserted_text, &s_default_document_client);
|
document->insert_at(start_position, inserted_text, &s_default_document_client);
|
||||||
|
@ -128,12 +128,12 @@ void FileDB::on_file_edit_insert_text(const String& file_name, const String& ins
|
||||||
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
|
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDB::on_file_edit_remove_text(const String& file_name, size_t start_line, size_t start_column, size_t end_line, size_t end_column)
|
void FileDB::on_file_edit_remove_text(const String& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column)
|
||||||
{
|
{
|
||||||
// TODO: If file is not open - need to get its contents
|
// TODO: If file is not open - need to get its contents
|
||||||
// Otherwise- somehow verify that respawned language server is synced with all file contents
|
// Otherwise- somehow verify that respawned language server is synced with all file contents
|
||||||
VERIFY(is_open(file_name));
|
VERIFY(is_open(filename));
|
||||||
auto document = get(file_name);
|
auto document = get(filename);
|
||||||
VERIFY(document);
|
VERIFY(document);
|
||||||
GUI::TextPosition start_position { start_line, start_column };
|
GUI::TextPosition start_position { start_line, start_column };
|
||||||
GUI::TextRange range {
|
GUI::TextRange range {
|
||||||
|
@ -153,7 +153,7 @@ RefPtr<GUI::TextDocument> FileDB::create_with_content(const String& content)
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileDB::add(const String& file_name, const String& content)
|
bool FileDB::add(const String& filename, const String& content)
|
||||||
{
|
{
|
||||||
auto document = create_with_content(content);
|
auto document = create_with_content(content);
|
||||||
if (!document) {
|
if (!document) {
|
||||||
|
@ -161,7 +161,7 @@ bool FileDB::add(const String& file_name, const String& content)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_open_files.set(to_absolute_path(file_name), document.release_nonnull());
|
m_open_files.set(to_absolute_path(filename), document.release_nonnull());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,22 +15,22 @@ namespace LanguageServers {
|
||||||
|
|
||||||
class FileDB final {
|
class FileDB final {
|
||||||
public:
|
public:
|
||||||
RefPtr<const GUI::TextDocument> get(const String& file_name) const;
|
RefPtr<const GUI::TextDocument> get(const String& filename) const;
|
||||||
RefPtr<GUI::TextDocument> get(const String& file_name);
|
RefPtr<GUI::TextDocument> get(const String& filename);
|
||||||
RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(const String& file_name) const;
|
RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(const String& filename) const;
|
||||||
RefPtr<GUI::TextDocument> get_or_create_from_filesystem(const String& file_name);
|
RefPtr<GUI::TextDocument> get_or_create_from_filesystem(const String& filename);
|
||||||
bool add(const String& file_name, int fd);
|
bool add(const String& filename, int fd);
|
||||||
bool add(const String& file_name, const String& content);
|
bool add(const String& filename, const String& content);
|
||||||
|
|
||||||
void set_project_root(const String& root_path) { m_project_root = root_path; }
|
void set_project_root(const String& root_path) { m_project_root = root_path; }
|
||||||
|
|
||||||
void on_file_edit_insert_text(const String& file_name, const String& inserted_text, size_t start_line, size_t start_column);
|
void on_file_edit_insert_text(const String& filename, const String& inserted_text, size_t start_line, size_t start_column);
|
||||||
void on_file_edit_remove_text(const String& file_name, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
|
void on_file_edit_remove_text(const String& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
|
||||||
String to_absolute_path(const String& file_name) const;
|
String to_absolute_path(const String& filename) const;
|
||||||
bool is_open(const String& file_name) const;
|
bool is_open(const String& filename) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<GUI::TextDocument> create_from_filesystem(const String& file_name) const;
|
RefPtr<GUI::TextDocument> create_from_filesystem(const String& filename) const;
|
||||||
RefPtr<GUI::TextDocument> create_from_fd(int fd) const;
|
RefPtr<GUI::TextDocument> create_from_fd(int fd) const;
|
||||||
RefPtr<GUI::TextDocument> create_from_file(Core::File&) const;
|
RefPtr<GUI::TextDocument> create_from_file(Core::File&) const;
|
||||||
static RefPtr<GUI::TextDocument> create_with_content(const String&);
|
static RefPtr<GUI::TextDocument> create_with_content(const String&);
|
||||||
|
|
|
@ -2,10 +2,10 @@ endpoint LanguageServer
|
||||||
{
|
{
|
||||||
Greet(String project_root) => ()
|
Greet(String project_root) => ()
|
||||||
|
|
||||||
FileOpened(String file_name, IPC::File file) =|
|
FileOpened(String filename, IPC::File file) =|
|
||||||
FileEditInsertText(String file_name, String text, i32 start_line, i32 start_column) =|
|
FileEditInsertText(String filename, String text, i32 start_line, i32 start_column) =|
|
||||||
FileEditRemoveText(String file_name, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
|
FileEditRemoveText(String filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
|
||||||
SetFileContent(String file_name, String content) =|
|
SetFileContent(String filename, String content) =|
|
||||||
|
|
||||||
AutoCompleteSuggestions(GUI::AutocompleteProvider::ProjectLocation location) =|
|
AutoCompleteSuggestions(GUI::AutocompleteProvider::ProjectLocation location) =|
|
||||||
SetAutoCompleteMode(String mode) =|
|
SetAutoCompleteMode(String mode) =|
|
||||||
|
|
|
@ -164,10 +164,10 @@ void AutoComplete::file_opened([[maybe_unused]] const String& file)
|
||||||
set_document_data(file, create_document_data_for(file));
|
set_document_data(file, create_document_data_for(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<GUI::AutocompleteProvider::ProjectLocation> AutoComplete::find_declaration_of(const String& file_name, const GUI::TextPosition& identifier_position)
|
Optional<GUI::AutocompleteProvider::ProjectLocation> AutoComplete::find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position)
|
||||||
{
|
{
|
||||||
dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", file_name, identifier_position.line(), identifier_position.column());
|
dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", filename, identifier_position.line(), identifier_position.column());
|
||||||
const auto& document = get_or_create_document_data(file_name);
|
const auto& document = get_or_create_document_data(filename);
|
||||||
auto position = resolve(document, identifier_position);
|
auto position = resolve(document, identifier_position);
|
||||||
auto result = document.node->hit_test_position(position);
|
auto result = document.node->hit_test_position(position);
|
||||||
if (!result.matching_node) {
|
if (!result.matching_node) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& position) override;
|
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& position) override;
|
||||||
virtual void on_edit(const String& file) override;
|
virtual void on_edit(const String& file) override;
|
||||||
virtual void file_opened([[maybe_unused]] const String& file) override;
|
virtual void file_opened([[maybe_unused]] const String& file) override;
|
||||||
virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& file_name, const GUI::TextPosition& identifier_position) override;
|
virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DocumentData {
|
struct DocumentData {
|
||||||
|
|
|
@ -132,14 +132,14 @@ GUI::TextEditor& current_editor()
|
||||||
return s_hack_studio_widget->current_editor();
|
return s_hack_studio_widget->current_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_file(const String& file_name)
|
void open_file(const String& filename)
|
||||||
{
|
{
|
||||||
s_hack_studio_widget->open_file(file_name);
|
s_hack_studio_widget->open_file(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_file(const String& file_name, size_t line, size_t column)
|
void open_file(const String& filename, size_t line, size_t column)
|
||||||
{
|
{
|
||||||
s_hack_studio_widget->open_file(file_name);
|
s_hack_studio_widget->open_file(filename);
|
||||||
s_hack_studio_widget->current_editor_wrapper().editor().set_cursor({ line, column });
|
s_hack_studio_widget->current_editor_wrapper().editor().set_cursor({ line, column });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
if (unveil(config->filename().characters(), "crw") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
if (unveil(config->filename().characters(), "crw") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
if (unveil(config->filename().characters(), "crw") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(config->file_name().characters(), "rwc") < 0) {
|
if (unveil(config->filename().characters(), "rwc") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
if (unveil(config->filename().characters(), "crw") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ constexpr const char* posix1_tar_version = ""; // POSIX.1-1988 format version
|
||||||
|
|
||||||
class [[gnu::packed]] TarFileHeader {
|
class [[gnu::packed]] TarFileHeader {
|
||||||
public:
|
public:
|
||||||
const StringView file_name() const { return m_file_name; }
|
const StringView filename() const { return m_filename; }
|
||||||
mode_t mode() const { return get_tar_field(m_mode); }
|
mode_t mode() const { return get_tar_field(m_mode); }
|
||||||
uid_t uid() const { return get_tar_field(m_uid); }
|
uid_t uid() const { return get_tar_field(m_uid); }
|
||||||
gid_t gid() const { return get_tar_field(m_gid); }
|
gid_t gid() const { return get_tar_field(m_gid); }
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
// FIXME: support ustar filename prefix
|
// FIXME: support ustar filename prefix
|
||||||
const StringView prefix() const { return m_prefix; }
|
const StringView prefix() const { return m_prefix; }
|
||||||
|
|
||||||
void set_file_name(const String& file_name) { VERIFY(file_name.copy_characters_to_buffer(m_file_name, sizeof(m_file_name))); }
|
void set_filename(const String& filename) { VERIFY(filename.copy_characters_to_buffer(m_filename, sizeof(m_filename))); }
|
||||||
void set_mode(mode_t mode) { VERIFY(String::formatted("{:o}", mode).copy_characters_to_buffer(m_mode, sizeof(m_mode))); }
|
void set_mode(mode_t mode) { VERIFY(String::formatted("{:o}", mode).copy_characters_to_buffer(m_mode, sizeof(m_mode))); }
|
||||||
void set_uid(uid_t uid) { VERIFY(String::formatted("{:o}", uid).copy_characters_to_buffer(m_uid, sizeof(m_uid))); }
|
void set_uid(uid_t uid) { VERIFY(String::formatted("{:o}", uid).copy_characters_to_buffer(m_uid, sizeof(m_uid))); }
|
||||||
void set_gid(gid_t gid) { VERIFY(String::formatted("{:o}", gid).copy_characters_to_buffer(m_gid, sizeof(m_gid))); }
|
void set_gid(gid_t gid) { VERIFY(String::formatted("{:o}", gid).copy_characters_to_buffer(m_gid, sizeof(m_gid))); }
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
void calculate_checksum();
|
void calculate_checksum();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char m_file_name[100];
|
char m_filename[100];
|
||||||
char m_mode[8];
|
char m_mode[8];
|
||||||
char m_uid[8];
|
char m_uid[8];
|
||||||
char m_gid[8];
|
char m_gid[8];
|
||||||
|
|
|
@ -132,7 +132,7 @@ void TarOutputStream::add_directory(const String& path, mode_t mode)
|
||||||
TarFileHeader header;
|
TarFileHeader header;
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
header.set_size(0);
|
header.set_size(0);
|
||||||
header.set_file_name(String::formatted("{}/", path)); // Old tar implementations assume directory names end with a /
|
header.set_filename(String::formatted("{}/", path)); // Old tar implementations assume directory names end with a /
|
||||||
header.set_type_flag(TarFileType::Directory);
|
header.set_type_flag(TarFileType::Directory);
|
||||||
header.set_mode(mode);
|
header.set_mode(mode);
|
||||||
header.set_magic(gnu_magic);
|
header.set_magic(gnu_magic);
|
||||||
|
@ -149,7 +149,7 @@ void TarOutputStream::add_file(const String& path, mode_t mode, const ReadonlyBy
|
||||||
TarFileHeader header;
|
TarFileHeader header;
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
header.set_size(bytes.size());
|
header.set_size(bytes.size());
|
||||||
header.set_file_name(path);
|
header.set_filename(path);
|
||||||
header.set_type_flag(TarFileType::NormalFile);
|
header.set_type_flag(TarFileType::NormalFile);
|
||||||
header.set_mode(mode);
|
header.set_mode(mode);
|
||||||
header.set_magic(gnu_magic);
|
header.set_magic(gnu_magic);
|
||||||
|
|
|
@ -41,8 +41,8 @@ NonnullRefPtr<ConfigFile> ConfigFile::open(const String& path)
|
||||||
return adopt_ref(*new ConfigFile(path));
|
return adopt_ref(*new ConfigFile(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigFile::ConfigFile(const String& file_name)
|
ConfigFile::ConfigFile(const String& filename)
|
||||||
: m_file_name(file_name)
|
: m_filename(filename)
|
||||||
{
|
{
|
||||||
reparse();
|
reparse();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ void ConfigFile::reparse()
|
||||||
{
|
{
|
||||||
m_groups.clear();
|
m_groups.clear();
|
||||||
|
|
||||||
auto file = File::construct(m_file_name);
|
auto file = File::construct(m_filename);
|
||||||
if (!file->open(IODevice::OpenMode::ReadOnly))
|
if (!file->open(IODevice::OpenMode::ReadOnly))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ bool ConfigFile::sync()
|
||||||
if (!m_dirty)
|
if (!m_dirty)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
FILE* fp = fopen(m_file_name.characters(), "wb");
|
FILE* fp = fopen(m_filename.characters(), "wb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -47,14 +47,14 @@ public:
|
||||||
void remove_group(const String& group);
|
void remove_group(const String& group);
|
||||||
void remove_entry(const String& group, const String& key);
|
void remove_entry(const String& group, const String& key);
|
||||||
|
|
||||||
String file_name() const { return m_file_name; }
|
String filename() const { return m_filename; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ConfigFile(const String& file_name);
|
explicit ConfigFile(const String& filename);
|
||||||
|
|
||||||
void reparse();
|
void reparse();
|
||||||
|
|
||||||
String m_file_name;
|
String m_filename;
|
||||||
HashMap<String, HashMap<String, String>> m_groups;
|
HashMap<String, HashMap<String, String>> m_groups;
|
||||||
bool m_dirty { false };
|
bool m_dirty { false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -372,9 +372,9 @@ Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_brea
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::insert_breakpoint(const String& file_name, size_t line_number)
|
Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::insert_breakpoint(const String& filename, size_t line_number)
|
||||||
{
|
{
|
||||||
auto address_and_source_position = get_address_from_source_position(file_name, line_number);
|
auto address_and_source_position = get_address_from_source_position(filename, line_number);
|
||||||
if (!address_and_source_position.has_value())
|
if (!address_and_source_position.has_value())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,12 @@ public:
|
||||||
|
|
||||||
struct InsertBreakpointAtSourcePositionResult {
|
struct InsertBreakpointAtSourcePositionResult {
|
||||||
String library_name;
|
String library_name;
|
||||||
String file_name;
|
String filename;
|
||||||
size_t line_number { 0 };
|
size_t line_number { 0 };
|
||||||
FlatPtr address { 0 };
|
FlatPtr address { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(const String& file_name, size_t line_number);
|
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(const String& filename, size_t line_number);
|
||||||
|
|
||||||
bool insert_breakpoint(void* address);
|
bool insert_breakpoint(void* address);
|
||||||
bool disable_breakpoint(void* address);
|
bool disable_breakpoint(void* address);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
~AppFile();
|
~AppFile();
|
||||||
|
|
||||||
bool is_valid() const { return m_valid; }
|
bool is_valid() const { return m_valid; }
|
||||||
String file_name() const { return m_config->file_name(); }
|
String filename() const { return m_config->filename(); }
|
||||||
|
|
||||||
String name() const;
|
String name() const;
|
||||||
String executable() const;
|
String executable() const;
|
||||||
|
|
|
@ -41,9 +41,9 @@ char* dlerror()
|
||||||
return const_cast<char*>(s_dlerror_text);
|
return const_cast<char*>(s_dlerror_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* dlopen(const char* file_name, int flags)
|
void* dlopen(const char* filename, int flags)
|
||||||
{
|
{
|
||||||
auto result = __dlopen(file_name, flags);
|
auto result = __dlopen(filename, flags);
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
store_error(result.error().text);
|
store_error(result.error().text);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -42,7 +42,7 @@ typedef struct
|
||||||
#define AT_BASE_PLATFORM 24 /* a_ptr points to a string identifying base platform name, which might be different from platform (e.g x86_64 when in i386 compat) */
|
#define AT_BASE_PLATFORM 24 /* a_ptr points to a string identifying base platform name, which might be different from platform (e.g x86_64 when in i386 compat) */
|
||||||
#define AT_RANDOM 25 /* a_ptr points to 16 securely generated random bytes */
|
#define AT_RANDOM 25 /* a_ptr points to 16 securely generated random bytes */
|
||||||
#define AT_HWCAP2 26 /* a_val holds extended hw feature mask. Currently 0 */
|
#define AT_HWCAP2 26 /* a_val holds extended hw feature mask. Currently 0 */
|
||||||
#define AT_EXECFN 31 /* a_ptr points to file name of executed program */
|
#define AT_EXECFN 31 /* a_ptr points to filename of executed program */
|
||||||
#define AT_EXE_BASE 32 /* a_ptr holds base address where main program was loaded into memory */
|
#define AT_EXE_BASE 32 /* a_ptr holds base address where main program was loaded into memory */
|
||||||
#define AT_EXE_SIZE 33 /* a_val holds the size of the main program in memory */
|
#define AT_EXE_SIZE 33 /* a_val holds the size of the main program in memory */
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ bool Desktop::set_wallpaper(const StringView& path, bool save_config)
|
||||||
|
|
||||||
if (ret_val && save_config) {
|
if (ret_val && save_config) {
|
||||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager");
|
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager");
|
||||||
dbgln("Saving wallpaper path '{}' to config file at {}", path, config->file_name());
|
dbgln("Saving wallpaper path '{}' to config file at {}", path, config->filename());
|
||||||
config->write_entry("Background", "Wallpaper", path);
|
config->write_entry("Background", "Wallpaper", path);
|
||||||
config->sync();
|
config->sync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ Optional<String> FilePicker::get_save_filepath(Window* parent_window, const Stri
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& file_name, const StringView& path)
|
FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filename, const StringView& path)
|
||||||
: Dialog(parent_window)
|
: Dialog(parent_window)
|
||||||
, m_model(FileSystemModel::create())
|
, m_model(FileSystemModel::create())
|
||||||
, m_mode(mode)
|
, m_mode(mode)
|
||||||
|
@ -148,7 +148,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& file_
|
||||||
m_filename_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("filename_textbox");
|
m_filename_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("filename_textbox");
|
||||||
m_filename_textbox->set_focus(true);
|
m_filename_textbox->set_focus(true);
|
||||||
if (m_mode == Mode::Save) {
|
if (m_mode == Mode::Save) {
|
||||||
m_filename_textbox->set_text(file_name);
|
m_filename_textbox->set_text(filename);
|
||||||
m_filename_textbox->select_all();
|
m_filename_textbox->select_all();
|
||||||
}
|
}
|
||||||
m_filename_textbox->on_return_pressed = [&] {
|
m_filename_textbox->on_return_pressed = [&] {
|
||||||
|
|
|
@ -43,7 +43,7 @@ private:
|
||||||
// ^GUI::ModelClient
|
// ^GUI::ModelClient
|
||||||
virtual void model_did_update(unsigned) override;
|
virtual void model_did_update(unsigned) override;
|
||||||
|
|
||||||
FilePicker(Window* parent_window, Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = Core::StandardPaths::home_directory());
|
FilePicker(Window* parent_window, Mode type = Mode::Open, const StringView& filename = "Untitled", const StringView& path = Core::StandardPaths::home_directory());
|
||||||
|
|
||||||
static String ok_button_name(Mode mode)
|
static String ok_button_name(Mode mode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
text: "File name:"
|
text: "Filename:"
|
||||||
text_alignment: "CenterRight"
|
text_alignment: "CenterRight"
|
||||||
fixed_height: 24
|
fixed_height: 24
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class CharacterMap {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterMap(const String& map_name, const CharacterMapData& map_data);
|
CharacterMap(const String& map_name, const CharacterMapData& map_data);
|
||||||
static Optional<CharacterMap> load_from_file(const String& file_name);
|
static Optional<CharacterMap> load_from_file(const String& filename);
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
int set_system_map();
|
int set_system_map();
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
|
|
||||||
namespace Keyboard {
|
namespace Keyboard {
|
||||||
|
|
||||||
Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& file_name)
|
Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& filename)
|
||||||
{
|
{
|
||||||
auto path = file_name;
|
auto path = filename;
|
||||||
if (!path.ends_with(".json")) {
|
if (!path.ends_with(".json")) {
|
||||||
StringBuilder full_path;
|
StringBuilder full_path;
|
||||||
full_path.append("/res/keymaps/");
|
full_path.append("/res/keymaps/");
|
||||||
full_path.append(file_name);
|
full_path.append(filename);
|
||||||
full_path.append(".json");
|
full_path.append(".json");
|
||||||
path = full_path.to_string();
|
path = full_path.to_string();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& file_n
|
||||||
auto file = Core::File::construct(path);
|
auto file = Core::File::construct(path);
|
||||||
file->open(Core::IODevice::ReadOnly);
|
file->open(Core::IODevice::ReadOnly);
|
||||||
if (!file->is_open()) {
|
if (!file->is_open()) {
|
||||||
dbgln("Failed to open {}: {}", file_name, file->error_string());
|
dbgln("Failed to open {}: {}", filename, file->error_string());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Keyboard {
|
||||||
class CharacterMapFile {
|
class CharacterMapFile {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Optional<CharacterMapData> load_from_file(const String& file_name);
|
static Optional<CharacterMapData> load_from_file(const String& filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Vector<u32> read_map(const JsonObject& json, const String& name);
|
static Vector<u32> read_map(const JsonObject& json, const String& name);
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
namespace PCIDB {
|
namespace PCIDB {
|
||||||
|
|
||||||
RefPtr<Database> Database::open(const String& file_name)
|
RefPtr<Database> Database::open(const String& filename)
|
||||||
{
|
{
|
||||||
auto file_or_error = MappedFile::map(file_name);
|
auto file_or_error = MappedFile::map(filename);
|
||||||
if (file_or_error.is_error())
|
if (file_or_error.is_error())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto res = adopt_ref(*new Database(file_or_error.release_value()));
|
auto res = adopt_ref(*new Database(file_or_error.release_value()));
|
||||||
|
|
|
@ -53,7 +53,7 @@ struct Class {
|
||||||
|
|
||||||
class Database : public RefCounted<Database> {
|
class Database : public RefCounted<Database> {
|
||||||
public:
|
public:
|
||||||
static RefPtr<Database> open(const String& file_name);
|
static RefPtr<Database> open(const String& filename);
|
||||||
static RefPtr<Database> open() { return open("/res/pci.ids"); };
|
static RefPtr<Database> open() { return open("/res/pci.ids"); };
|
||||||
|
|
||||||
const StringView get_vendor(u16 vendor_id) const;
|
const StringView get_vendor(u16 vendor_id) const;
|
||||||
|
|
|
@ -93,7 +93,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co
|
||||||
update();
|
update();
|
||||||
};
|
};
|
||||||
|
|
||||||
dbgln("Load config file from {}", m_config->file_name());
|
dbgln("Load config file from {}", m_config->filename());
|
||||||
m_cursor_blink_timer->set_interval(m_config->read_num_entry("Text",
|
m_cursor_blink_timer->set_interval(m_config->read_num_entry("Text",
|
||||||
"CursorBlinkInterval",
|
"CursorBlinkInterval",
|
||||||
500));
|
500));
|
||||||
|
|
|
@ -37,7 +37,7 @@ LookupServer::LookupServer()
|
||||||
s_the = this;
|
s_the = this;
|
||||||
|
|
||||||
auto config = Core::ConfigFile::get_for_system("LookupServer");
|
auto config = Core::ConfigFile::get_for_system("LookupServer");
|
||||||
dbgln("Using network config file at {}", config->file_name());
|
dbgln("Using network config file at {}", config->filename());
|
||||||
m_nameservers = config->read_entry("DNS", "Nameservers", "1.1.1.1,1.0.0.1").split(',');
|
m_nameservers = config->read_entry("DNS", "Nameservers", "1.1.1.1,1.0.0.1").split(',');
|
||||||
|
|
||||||
load_etc_hosts();
|
load_etc_hosts();
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace WindowServer {
|
namespace WindowServer {
|
||||||
|
|
||||||
CursorParams CursorParams::parse_from_file_name(const StringView& cursor_path, const Gfx::IntPoint& default_hotspot)
|
CursorParams CursorParams::parse_from_filename(const StringView& cursor_path, const Gfx::IntPoint& default_hotspot)
|
||||||
{
|
{
|
||||||
LexicalPath path(cursor_path);
|
LexicalPath path(cursor_path);
|
||||||
if (!path.is_valid()) {
|
if (!path.is_valid()) {
|
||||||
|
@ -123,7 +123,7 @@ NonnullRefPtr<Cursor> Cursor::create(NonnullRefPtr<Gfx::Bitmap>&& bitmap)
|
||||||
NonnullRefPtr<Cursor> Cursor::create(NonnullRefPtr<Gfx::Bitmap>&& bitmap, const StringView& filename)
|
NonnullRefPtr<Cursor> Cursor::create(NonnullRefPtr<Gfx::Bitmap>&& bitmap, const StringView& filename)
|
||||||
{
|
{
|
||||||
auto default_hotspot = bitmap->rect().center();
|
auto default_hotspot = bitmap->rect().center();
|
||||||
return adopt_ref(*new Cursor(move(bitmap), CursorParams::parse_from_file_name(filename, default_hotspot)));
|
return adopt_ref(*new Cursor(move(bitmap), CursorParams::parse_from_filename(filename, default_hotspot)));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Cursor> Cursor::create(Gfx::StandardCursor standard_cursor)
|
RefPtr<Cursor> Cursor::create(Gfx::StandardCursor standard_cursor)
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace WindowServer {
|
||||||
|
|
||||||
class CursorParams {
|
class CursorParams {
|
||||||
public:
|
public:
|
||||||
static CursorParams parse_from_file_name(const StringView&, const Gfx::IntPoint&);
|
static CursorParams parse_from_filename(const StringView&, const Gfx::IntPoint&);
|
||||||
CursorParams(const Gfx::IntPoint& hotspot)
|
CursorParams(const Gfx::IntPoint& hotspot)
|
||||||
: m_hotspot(hotspot)
|
: m_hotspot(hotspot)
|
||||||
{
|
{
|
||||||
|
|
|
@ -116,13 +116,13 @@ bool WindowManager::set_resolution(int width, int height, int scale)
|
||||||
}
|
}
|
||||||
if (m_config) {
|
if (m_config) {
|
||||||
if (success) {
|
if (success) {
|
||||||
dbgln("Saving resolution: {} @ {}x to config file at {}", Gfx::IntSize(width, height), scale, m_config->file_name());
|
dbgln("Saving resolution: {} @ {}x to config file at {}", Gfx::IntSize(width, height), scale, m_config->filename());
|
||||||
m_config->write_num_entry("Screen", "Width", width);
|
m_config->write_num_entry("Screen", "Width", width);
|
||||||
m_config->write_num_entry("Screen", "Height", height);
|
m_config->write_num_entry("Screen", "Height", height);
|
||||||
m_config->write_num_entry("Screen", "ScaleFactor", scale);
|
m_config->write_num_entry("Screen", "ScaleFactor", scale);
|
||||||
m_config->sync();
|
m_config->sync();
|
||||||
} else {
|
} else {
|
||||||
dbgln("Saving fallback resolution: {} @1x to config file at {}", resolution(), m_config->file_name());
|
dbgln("Saving fallback resolution: {} @1x to config file at {}", resolution(), m_config->filename());
|
||||||
m_config->write_num_entry("Screen", "Width", resolution().width());
|
m_config->write_num_entry("Screen", "Width", resolution().width());
|
||||||
m_config->write_num_entry("Screen", "Height", resolution().height());
|
m_config->write_num_entry("Screen", "Height", resolution().height());
|
||||||
m_config->write_num_entry("Screen", "ScaleFactor", 1);
|
m_config->write_num_entry("Screen", "ScaleFactor", 1);
|
||||||
|
@ -140,7 +140,7 @@ Gfx::IntSize WindowManager::resolution() const
|
||||||
void WindowManager::set_acceleration_factor(double factor)
|
void WindowManager::set_acceleration_factor(double factor)
|
||||||
{
|
{
|
||||||
Screen::the().set_acceleration_factor(factor);
|
Screen::the().set_acceleration_factor(factor);
|
||||||
dbgln("Saving acceleration factor {} to config file at {}", factor, m_config->file_name());
|
dbgln("Saving acceleration factor {} to config file at {}", factor, m_config->filename());
|
||||||
m_config->write_entry("Mouse", "AccelerationFactor", String::formatted("{}", factor));
|
m_config->write_entry("Mouse", "AccelerationFactor", String::formatted("{}", factor));
|
||||||
m_config->sync();
|
m_config->sync();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ void WindowManager::set_acceleration_factor(double factor)
|
||||||
void WindowManager::set_scroll_step_size(unsigned step_size)
|
void WindowManager::set_scroll_step_size(unsigned step_size)
|
||||||
{
|
{
|
||||||
Screen::the().set_scroll_step_size(step_size);
|
Screen::the().set_scroll_step_size(step_size);
|
||||||
dbgln("Saving scroll step size {} to config file at {}", step_size, m_config->file_name());
|
dbgln("Saving scroll step size {} to config file at {}", step_size, m_config->filename());
|
||||||
m_config->write_entry("Mouse", "ScrollStepSize", String::number(step_size));
|
m_config->write_entry("Mouse", "ScrollStepSize", String::number(step_size));
|
||||||
m_config->sync();
|
m_config->sync();
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ void WindowManager::set_double_click_speed(int speed)
|
||||||
{
|
{
|
||||||
VERIFY(speed >= double_click_speed_min && speed <= double_click_speed_max);
|
VERIFY(speed >= double_click_speed_min && speed <= double_click_speed_max);
|
||||||
m_double_click_speed = speed;
|
m_double_click_speed = speed;
|
||||||
dbgln("Saving double-click speed {} to config file at {}", speed, m_config->file_name());
|
dbgln("Saving double-click speed {} to config file at {}", speed, m_config->filename());
|
||||||
m_config->write_entry("Input", "DoubleClickSpeed", String::number(speed));
|
m_config->write_entry("Input", "DoubleClickSpeed", String::number(speed));
|
||||||
m_config->sync();
|
m_config->sync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ int main(int argc, char** argv)
|
||||||
args_parser.set_general_help("Print the beginning ('head') of a file.");
|
args_parser.set_general_help("Print the beginning ('head') of a file.");
|
||||||
args_parser.add_option(line_count, "Number of lines to print (default 10)", "lines", 'n', "number");
|
args_parser.add_option(line_count, "Number of lines to print (default 10)", "lines", 'n', "number");
|
||||||
args_parser.add_option(char_count, "Number of characters to print", "characters", 'c', "number");
|
args_parser.add_option(char_count, "Number of characters to print", "characters", 'c', "number");
|
||||||
args_parser.add_option(never_print_filenames, "Never print file names", "quiet", 'q');
|
args_parser.add_option(never_print_filenames, "Never print filenames", "quiet", 'q');
|
||||||
args_parser.add_option(always_print_filenames, "Always print file names", "verbose", 'v');
|
args_parser.add_option(always_print_filenames, "Always print filenames", "verbose", 'v');
|
||||||
args_parser.add_positional_argument(files, "File to process", "file", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(files, "File to process", "file", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -574,8 +574,8 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::repl_help)
|
||||||
outln("REPL commands:");
|
outln("REPL commands:");
|
||||||
outln(" exit(code): exit the REPL with specified code. Defaults to 0.");
|
outln(" exit(code): exit the REPL with specified code. Defaults to 0.");
|
||||||
outln(" help(): display this menu");
|
outln(" help(): display this menu");
|
||||||
outln(" load(files): accepts file names as params to load into running session. For example load(\"js/1.js\", \"js/2.js\", \"js/3.js\")");
|
outln(" load(files): accepts filenames as params to load into running session. For example load(\"js/1.js\", \"js/2.js\", \"js/3.js\")");
|
||||||
outln(" save(file): accepts a file name, writes REPL input history to a file. For example: save(\"foo.txt\")");
|
outln(" save(file): accepts a filename, writes REPL input history to a file. For example: save(\"foo.txt\")");
|
||||||
return JS::js_undefined();
|
return JS::js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,10 +585,10 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::load_file)
|
||||||
return JS::Value(false);
|
return JS::Value(false);
|
||||||
|
|
||||||
for (auto& file : vm.call_frame().arguments) {
|
for (auto& file : vm.call_frame().arguments) {
|
||||||
String file_name = file.as_string().string();
|
String filename = file.as_string().string();
|
||||||
auto js_file = Core::File::construct(file_name);
|
auto js_file = Core::File::construct(filename);
|
||||||
if (!js_file->open(Core::IODevice::ReadOnly)) {
|
if (!js_file->open(Core::IODevice::ReadOnly)) {
|
||||||
warnln("Failed to open {}: {}", file_name, js_file->error_string());
|
warnln("Failed to open {}: {}", filename, js_file->error_string());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto file_contents = js_file->read_all();
|
auto file_contents = js_file->read_all();
|
||||||
|
|
|
@ -124,7 +124,7 @@ int main(int argc, char* argv[])
|
||||||
int arg_uid_int = -1;
|
int arg_uid_int = -1;
|
||||||
int arg_pgid { -1 };
|
int arg_pgid { -1 };
|
||||||
pid_t arg_pid { -1 };
|
pid_t arg_pid { -1 };
|
||||||
const char* arg_file_name { nullptr };
|
const char* arg_filename { nullptr };
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
arg_all_processes = true;
|
arg_all_processes = true;
|
||||||
|
@ -135,7 +135,7 @@ int main(int argc, char* argv[])
|
||||||
parser.add_option(arg_fd, "Select by file descriptor", nullptr, 'd', "fd");
|
parser.add_option(arg_fd, "Select by file descriptor", nullptr, 'd', "fd");
|
||||||
parser.add_option(arg_uid, "Select by login/UID", nullptr, 'u', "login/UID");
|
parser.add_option(arg_uid, "Select by login/UID", nullptr, 'u', "login/UID");
|
||||||
parser.add_option(arg_pgid, "Select by process group ID", nullptr, 'g', "PGID");
|
parser.add_option(arg_pgid, "Select by process group ID", nullptr, 'g', "PGID");
|
||||||
parser.add_positional_argument(arg_file_name, "File name", "file name", Core::ArgsParser::Required::No);
|
parser.add_positional_argument(arg_filename, "Filename", "filename", Core::ArgsParser::Required::No);
|
||||||
parser.parse(argc, argv);
|
parser.parse(argc, argv);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,7 @@ int main(int argc, char* argv[])
|
||||||
|| (arg_uid_int != -1 && (int)process.value.uid == arg_uid_int)
|
|| (arg_uid_int != -1 && (int)process.value.uid == arg_uid_int)
|
||||||
|| (arg_uid != nullptr && process.value.username == arg_uid)
|
|| (arg_uid != nullptr && process.value.username == arg_uid)
|
||||||
|| (arg_pgid != -1 && (int)process.value.pgid == arg_pgid)
|
|| (arg_pgid != -1 && (int)process.value.pgid == arg_pgid)
|
||||||
|| (arg_file_name != nullptr && file.name == arg_file_name))
|
|| (arg_filename != nullptr && file.name == arg_filename))
|
||||||
display_entry(file, process.value);
|
display_entry(file, process.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ int main(int argc, char* argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* file_name = nullptr;
|
const char* filename = nullptr;
|
||||||
bool html = false;
|
bool html = false;
|
||||||
int view_width = 0;
|
int view_width = 0;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ int main(int argc, char* argv[])
|
||||||
args_parser.set_general_help("Render Markdown to some other format.");
|
args_parser.set_general_help("Render Markdown to some other format.");
|
||||||
args_parser.add_option(html, "Render to HTML rather than for the terminal", "html", 'H');
|
args_parser.add_option(html, "Render to HTML rather than for the terminal", "html", 'H');
|
||||||
args_parser.add_option(view_width, "Viewport width for the terminal (defaults to current terminal width)", "view-width", 0, "width");
|
args_parser.add_option(view_width, "Viewport width for the terminal (defaults to current terminal width)", "view-width", 0, "width");
|
||||||
args_parser.add_positional_argument(file_name, "Path to Markdown file", "path", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(filename, "Path to Markdown file", "path", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
if (!html && view_width == 0) {
|
if (!html && view_width == 0) {
|
||||||
|
@ -47,10 +47,10 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
auto file = Core::File::construct();
|
auto file = Core::File::construct();
|
||||||
bool success;
|
bool success;
|
||||||
if (file_name == nullptr) {
|
if (filename == nullptr) {
|
||||||
success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::No);
|
success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::No);
|
||||||
} else {
|
} else {
|
||||||
file->set_filename(file_name);
|
file->set_filename(filename);
|
||||||
success = file->open(Core::IODevice::OpenMode::ReadOnly);
|
success = file->open(Core::IODevice::OpenMode::ReadOnly);
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
|
|
@ -42,17 +42,17 @@ int main(int argc, char** argv)
|
||||||
unsigned long name_max = flag_most_posix ? _POSIX_NAME_MAX : pathconf(str_path.characters(), _PC_NAME_MAX);
|
unsigned long name_max = flag_most_posix ? _POSIX_NAME_MAX : pathconf(str_path.characters(), _PC_NAME_MAX);
|
||||||
|
|
||||||
if (str_path.length() > path_max) {
|
if (str_path.length() > path_max) {
|
||||||
warnln("{}: limit {} exceeded by length {} of file name '{}'", argv[0], path_max, str_path.length(), str_path);
|
warnln("{}: limit {} exceeded by length {} of filename '{}'", argv[0], path_max, str_path.length(), str_path);
|
||||||
fail = true;
|
fail = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag_most_posix) {
|
if (flag_most_posix) {
|
||||||
// POSIX portable file name character set (a-z A-Z 0-9 . _ -)
|
// POSIX portable filename character set (a-z A-Z 0-9 . _ -)
|
||||||
for (long unsigned i = 0; i < str_path.length(); ++i) {
|
for (long unsigned i = 0; i < str_path.length(); ++i) {
|
||||||
auto c = path[i];
|
auto c = path[i];
|
||||||
if (!(c >= 'a' && c <= 'z') && !(c >= 'A' && c <= 'Z') && !(c >= '0' && c <= '9') && c != '/' && c != '.' && c != '-' && c != '_') {
|
if (!(c >= 'a' && c <= 'z') && !(c >= 'A' && c <= 'Z') && !(c >= '0' && c <= '9') && c != '/' && c != '.' && c != '-' && c != '_') {
|
||||||
warnln("{}: non-portable character '{}' in file name '{}'", argv[0], path[i], str_path);
|
warnln("{}: non-portable character '{}' in filename '{}'", argv[0], path[i], str_path);
|
||||||
fail = true;
|
fail = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
if (flag_empty_name_and_leading_dash) {
|
if (flag_empty_name_and_leading_dash) {
|
||||||
if (str_path.is_empty()) {
|
if (str_path.is_empty()) {
|
||||||
warnln("{}: empty file name", argv[0]);
|
warnln("{}: empty filename", argv[0]);
|
||||||
fail = true;
|
fail = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -79,13 +79,13 @@ int main(int argc, char** argv)
|
||||||
for (auto& component : str_path.split('/')) {
|
for (auto& component : str_path.split('/')) {
|
||||||
if (flag_empty_name_and_leading_dash) {
|
if (flag_empty_name_and_leading_dash) {
|
||||||
if (component.starts_with('-')) {
|
if (component.starts_with('-')) {
|
||||||
warnln("{}: leading '-' in a component of file name '{}'", argv[0], str_path);
|
warnln("{}: leading '-' in a component of filename '{}'", argv[0], str_path);
|
||||||
fail = true;
|
fail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (component.length() > name_max) {
|
if (component.length() > name_max) {
|
||||||
warnln("{}: limit {} exceeded by length {} of file name component '{}'", argv[0], name_max, component.length(), component.characters());
|
warnln("{}: limit {} exceeded by length {} of filename component '{}'", argv[0], name_max, component.length(), component.characters());
|
||||||
fail = true;
|
fail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
for (; !tar_stream.finished(); tar_stream.advance()) {
|
for (; !tar_stream.finished(); tar_stream.advance()) {
|
||||||
if (list || verbose)
|
if (list || verbose)
|
||||||
outln("{}", tar_stream.header().file_name());
|
outln("{}", tar_stream.header().filename());
|
||||||
|
|
||||||
if (extract) {
|
if (extract) {
|
||||||
Archive::TarFileStream file_stream = tar_stream.file_contents();
|
Archive::TarFileStream file_stream = tar_stream.file_contents();
|
||||||
|
@ -77,7 +77,7 @@ int main(int argc, char** argv)
|
||||||
switch (header.type_flag()) {
|
switch (header.type_flag()) {
|
||||||
case Archive::TarFileType::NormalFile:
|
case Archive::TarFileType::NormalFile:
|
||||||
case Archive::TarFileType::AlternateNormalFile: {
|
case Archive::TarFileType::AlternateNormalFile: {
|
||||||
int fd = open(String(header.file_name()).characters(), O_CREAT | O_WRONLY, header.mode());
|
int fd = open(String(header.filename()).characters(), O_CREAT | O_WRONLY, header.mode());
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror("open");
|
perror("open");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -95,7 +95,7 @@ int main(int argc, char** argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Archive::TarFileType::Directory: {
|
case Archive::TarFileType::Directory: {
|
||||||
if (mkdir(String(header.file_name()).characters(), header.mode())) {
|
if (mkdir(String(header.filename()).characters(), header.mode())) {
|
||||||
perror("mkdir");
|
perror("mkdir");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ static int run(Function<void(const char*, size_t)> fn)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (filename == nullptr) {
|
if (filename == nullptr) {
|
||||||
puts("must specify a file name");
|
puts("must specify a filename");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!Core::File::exists(filename)) {
|
if (!Core::File::exists(filename)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue