Kenneth Myhra
951d8a06d8
LibCore: Add syscall wrapper for gethostname()
2021-11-27 11:14:16 +01:00
Andreas Kling
f1cc3d0fc4
Userland: Use Core::ArgsParser's Vector<StringView> API everywhere
...
...and remove the Vector<String> variant since there are no remaining
users of this API.
2021-11-26 23:27:57 +01:00
Andreas Kling
395ba619d8
LibCore: Add Vector<StringView> variant of add_positional_argument()
2021-11-26 23:27:57 +01:00
Andreas Kling
748c8b4879
LibCore: Add syscall wrapper for ptsname()
2021-11-24 23:24:53 +01:00
Andreas Kling
a152b1f215
LibCore: Add syscall wrapper for dup2()
2021-11-24 23:07:31 +01:00
Andreas Kling
71bc9bee0a
LibCore: Add syscall wrapper for pipe2()
2021-11-24 23:07:31 +01:00
Andreas Kling
b81ce827b6
LibCore: Add Core::Object::try_add<T>(...)
...
This is a fallible version of add<T>(...) that returns ErrorOr<T>.
It can be used together with TRY() to handle allocation failures when
instantiating new Core::Objects.
2021-11-24 13:52:01 +01:00
Andreas Kling
8b7b726680
LibCore: Add kill() syscall wrapper
2021-11-24 00:25:22 +01:00
Timothy Flynn
7f780e43a6
LibCore: Allow moving, but not copying, DirIterator
...
An explicit move constructor is required to null-out the moved-from
directory descriptor. Otherwise, we would call closedir() twice when
using ErrorOr<DirIterator>::release_value().
2021-11-23 22:58:05 +01:00
Andreas Kling
5a3f5582ba
LibCore: Add try_create(...) helper to all Core::Object derived classes
...
This is like construct(...) but returns ErrorOr<NonnullRefPtr<T>>.
2021-11-23 15:44:59 +01:00
Andreas Kling
16356ca478
LibCore: Add syscall wrappers for read() and write()
2021-11-23 15:44:59 +01:00
Andreas Kling
3db9979e40
LibCore: Add syscall wrapper for stat()
2021-11-23 12:23:54 +01:00
Andreas Kling
4a213869f2
LibCore: Add syscall wrapper for ftruncate()
2021-11-23 12:23:54 +01:00
Andreas Kling
4bf08e4d52
LibCore: Add syscall wrapper for close()
2021-11-23 12:23:54 +01:00
Andreas Kling
0ed5f84bd9
LibCore: Use open() wrapper in Core::MappedFile :^)
2021-11-23 12:23:54 +01:00
Andreas Kling
50416c286d
LibCore: Add syscall wrapper for open()
2021-11-23 11:59:50 +01:00
Andreas Kling
094fa900a3
LibCore: Use mmap() and munmap() wrappers in Core::MappedFile
2021-11-23 11:51:46 +01:00
Andreas Kling
45842a5208
LibCore: Add syscall wrapper for munmap()
2021-11-23 11:51:11 +01:00
Andreas Kling
53e9b9758e
LibCore: Add syscall wrapper for mmap()
...
For convenience on SerenityOS, this also takes a custom alignment
request, and a memory region name. These are non-POSIX extensions.
2021-11-23 11:48:40 +01:00
Andreas Kling
a62d16fbe9
LibCore: Use syscall wrappers in MappedFile::map_from_fd_and_close()
2021-11-23 11:36:00 +01:00
Andreas Kling
58fb3ebf66
LibCore+AK: Move MappedFile from AK to LibCore
...
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Andreas Kling
c1a3968c66
LibCore: Make LocalSocket takeover mechanism return ErrorOr<T>
2021-11-23 11:33:36 +01:00
Andreas Kling
c37a02341b
LibCore: Add Core::System wrappers for fstat() and fcntl()
2021-11-23 11:33:36 +01:00
Andreas Kling
21a5fb0fa2
LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
...
With this change, System::foo() becomes Core::System::foo().
Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00
Mustafa Quraish
7720644ae2
LibCore: Let ArgsParser::parse() accept Main::Arguments
...
Instead of manually passing in `arguments.argc` and `arguments.argv`,
we can now just pass in the arguments directly.
2021-11-22 21:13:42 -08:00
qiu-x
c0a7e0ad23
LibCore: Fix LocalSocket.cpp
build on FreeBSD
...
This fixes the build on FreeBSD by chagning LOCAL_PEERPID to
LOCAL_PEERCRED inside a ifdef
2021-11-20 21:11:30 +00:00
Andreas Kling
216e21a1fa
AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
...
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling
587f9af960
AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
...
Also add slightly richer parse errors now that we can include a string
literal with returned errors.
This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Benjamin S Osenbach
d82e41440c
LibCore: Don't include crypt.h in Account.cpp on FreeBSD
...
Fixes #10803 .
2021-11-16 19:06:13 +00:00
Andreas Kling
80d4e830a0
Everywhere: Pass AK::ReadonlyBytes by value
2021-11-11 01:27:46 +01:00
Andreas Kling
8b1108e485
Everywhere: Pass AK::StringView by value
2021-11-11 01:27:46 +01:00
Tim Schumacher
80cb44afae
Everywhere: Move shared library checks into a common function
...
While we're at it, unify the various different conditions that are
scattered accross the codebase.
2021-11-10 14:42:49 +01:00
Andreas Kling
0b0c4e82b9
LibCore: Replace Result<T, E> use with ErrorOr<T> in Core::FileWatcher
2021-11-08 00:35:27 +01:00
Andreas Kling
4eeab4cfc8
LibCore: Replace Result<T, E> use with ErrorOr<T> in Core::Account
2021-11-08 00:35:27 +01:00
Andreas Kling
e76b21a66f
LibCore: Use ErrorOr<T> for Core::get_password()
2021-11-08 00:35:27 +01:00
Andreas Kling
a7f1f1c34b
LibCore: Use ErrorOr<T> for Core::File::open()
2021-11-08 00:35:27 +01:00
Andreas Kling
fac2550143
LibCore: Use ErrorOr<T> for Core::File::size()
2021-11-08 00:35:27 +01:00
Andreas Kling
4a2b718ba2
LibCore: Use ErrorOr<T> for Core::File::copy_file()
2021-11-08 00:35:27 +01:00
Andreas Kling
c7e62d448c
LibCore: Use ErrorOr<T> for Core::File::remove()
...
This function returns a subclass of Error, which is now possible.
2021-11-08 00:35:27 +01:00
Andreas Kling
b2170c11a4
LibCore: Use ErrorOr<T> for Core::File::link_file()
2021-11-08 00:35:27 +01:00
Andreas Kling
e5dde37e24
AK: Bring AK::Error into the global namespace
2021-11-08 00:35:27 +01:00
Andreas Kling
e2eabb4132
LibCore: Use ErrorOr<T> in Core::AnonymousBuffer
2021-11-08 00:35:27 +01:00
Ben Wiederhake
f9167c9265
Base+LibCore: Store booleans in human-readable format
...
Fixes #10640 .
2021-11-04 23:44:02 +01:00
Tor-björn Claesson
53c8faaafc
LibCore: Trim trailing whitespaces from ConfigFile values
...
Previously, trailing whitespaces were not removed from values in
config files. This could cause errors with poorly formatted files.
This commit fixes this by trimming whitespaces from values in
ConfigFile::reparse().
2021-11-04 18:53:17 +01:00
Ben Wiederhake
b3e9a4e603
Libraries: Fix visibility of Object-derivative constructors
...
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
2e6bb987a3
AK+WindowServer: Remove did_construct() framework used only once
...
There is also make_ref_counted(), which does not call did_construct(),
so the method was not guaranteed to be run. Since there is only a single
user, and `WindowServer::Window` is a final class anyway (so there is no
need to separate the constructor and post-constructor phases), let's get
rid of this concept.
(The following commits reduce the opportunities to call
make_ref_counted, but still.)
2021-11-02 22:56:53 +01:00
thislooksfun
9cf9e604c3
LibCore: Add REGISTER_ABSTRACT_CORE_OBJECT
...
This behaves identically to REGISTER_CORE_OBJECT, but the resulting
ObjectClassRegistration's construct() method will always return null.
2021-11-02 17:53:22 +01:00
thislooksfun
c3b0b9057e
LibCore+LibGUI: Make ObjectClassRegistration::construct() nullable
...
This lays the groundwork for allowing the registration of abstract
core objects, which will be needed for improved GML autocomplete.
2021-11-02 17:53:22 +01:00
Ben Wiederhake
ea9f2f80a1
LibCore: Make ArgsParser '--help' description more general
...
Now that the output may end up in Markdown files (and thus the website),
the help message should no longer be self-referential.
2021-11-01 21:12:58 +01:00
Ben Wiederhake
0372f051e9
LibCore: Enable emitting markdown from ArgsParser
...
ArgsParser will now automatically look for an environment variable
'ARGSPARSER_EMIT_MARKDOWN', and if it is set to exactly the string "1"
(i.e. mere presence or values like "ON" or "yes" are not enough), then
ArgsParser will emit a Markdown-formatted help message, instead of the
regular help message designed for consumption through a terminal.
2021-11-01 21:12:58 +01:00