summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
AgeCommit message (Collapse)Author
2022-03-29LibCore: Add syscall wrapper for access()Kenneth Myhra
2022-03-28LibCore: Set the correct invariant length for consecutive short optionsAli Mohammad Pur
When completing `ls -l` to add another short option, the invariant length should be zero as we are not replacing anything with our suggestion. Also skip the initial dash if there already is one. Fixes #13301.
2022-03-27Everywhere: Rename CommandResult stdout, stderr members to output, errorBrian Gianforcaro
The names stdout / stderr are bound to conflict with existing declarations when compiling against other LibC's. The build on OpenBSD is broken for this reason at the moment. Lets rename the members to more generic names to resolve the situation.
2022-03-27LibCore: Add Vector<size_t> variant of add_option()Kenneth Myhra
This adds a Vector<size_t> variant of add_option(). The signature includes a separator parameter which defaults to ','.
2022-03-26LibCore: Allow marking options as 'hidden' in ArgsParserAli Mohammad Pur
This removes them from the main invocation example in --help, as well as hides them from autocomplete results (we were previously special-casing "help" and "version").
2022-03-26Shell+LibCore: Provide argument help strings as display triviaAli Mohammad Pur
2022-03-26LibCore: Make ArgsParser perform some completion if passed --completeAli Mohammad Pur
This makes it possible to autocomplete flags and options via the Shell.
2022-03-25LibCore: Fix enum copy mistakes in REGISTER_TEXT_ALIGNMENT_PROPERTYkleines Filmröllchen
2022-03-25LibCore: Make EventLoop connect to InspectorServer if requestedkleines Filmröllchen
I regressed this at some point by inverting the condition here.
2022-03-24Userland+Tests: Convert File::read_link() from String to ErrorOr<String>Kenneth Myhra
This converts the return value of File::read_link() from String to ErrorOr<String>. The rest of the change is to support the potential of an Error being returned and subsequent release of the value when no Error is returned. Unfortunately at this stage none of the places affected can utililize our TRY() macro.
2022-03-22LibCore: Add Core::System::drop_privileges()Brian Gianforcaro
In a few places we intentionally drop privileges to reduce the potential security surface area of networked program, with the pattern of: ``` if (setgid(getgid()) || setuid(getuid()) { return 1; } ``` We can make this a bit nicer to use by creating a wrapper.
2022-03-19LibCore: Add text/css mime typeMaciej
Firefox throws out css files with MIME type not being "text/css", so let's add it to make attached CSS working on WebServer. :^)
2022-03-19LibCore: Add some extensions that are text/plainMaciej
C++ source/header files, GML, IPC, CMake and various Serenity config files.
2022-03-19LibCore: Make application/octet-stream the default guessed MIME typeMaciej
This MIME type can be associated with every file, text/plain only with plaintext files. This makes browsers (e.g Firefox) properly displaying download progress when downloading files in WebServer :^)
2022-03-19LibCore: Add File::ensure_directories()Tim Schumacher
2022-03-19LibCore: Change class_name to use StringView instead of char const*Lenny Maiorani
This helps make the overall codebase consistent. `class_name()` in `Kernel` is always `StringView`, but not elsewhere. Additionally, this results in the `strlen` (which needs to be done when printing or other operations) always being computed at compile-time.
2022-03-18Everywhere: Deduplicate day/month name constantsLenny Maiorani
Day and month name constants are defined in numerous places. This pulls them together into a single place and eliminates the duplication. It also ensures they are `constexpr`.
2022-03-13LibCore: Use timing_safe_compare to compare password hash valuesBrian Gianforcaro
This is not strictly required, as we are comparing hashes, not the password it self. However given this is generic code that could be used anywhere in the system, it seems prudent to be cautious and make sure we don't inadvertently leak any information about the hash via timing attacks in future usages of `LibCore::Account`. Reported-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2022-03-13LibCore: Use altzone for the current time zone offset during DSTTimothy Flynn
Also use the daylight global to determine the current time zone name, i.e. tzname[0] is standard time, tzname[1] is daylight savings time. Note that altzone isn't required to be defined on all systems, so we have to #ifdef to check if it exists in order for Lagom to build.
2022-03-10LibCore: Verify that EventLoop is initialized in its static APIjavabird25
2022-03-10Libraries: Use default constructors/destructors in LibCoreLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-08LibCore: Do not skip dotfiles when copying directories recursivelyDaniel Bertalan
2022-03-08LibCore: Add support for application/zip mime-typekimlintu
The local file header signature of a ZIP entry is normally 0x04034B50 and stored in little-endian byte order. Therefore, if the archive starts with an entry we can identify a ZIP file by checking if the first two bytes are 0x504B (PK). Also checks for the .zip file extension, which is is also used by file if no byte signature was detected.
2022-03-08LibGfx: Add support for TextAlignment::TopCenter / BottomCenterVrins
Now supports TextAlignment::TopCenter and TextAlignment::BottomCenter for the Painter::draw_text. Also patched this in Spreadsheet/CellTypeDialog.cpp
2022-03-02LibCore: Add wrapper for posix_openpt(), grantpt() and unlockpt()Lucas CHOLLET
2022-03-02LibCore+LibC: Add wrapper for setenvLucas CHOLLET
I also added a common interface with StringView compatible parameters: int serenity_setenv(const char*, ssize_t, const char*, ssize_t, int) This function is called by both C and C++ API for setenv().
2022-03-02LibCore: Add tcsetpgrp(int, pid_t) wrapperLucas CHOLLET
2022-03-02LibCore: Add killpg() wrapperLucas CHOLLET
2022-02-28LibCore: Add rmdir system call wrapperLenny Maiorani
2022-02-18Core: Remove non-existent classes from `Forward.h`James Puleo
2022-02-17ArgsParser: Add support for Optional<size_t>brapru
2022-02-17LibCore: Make FreeBSD build SerenityOSIsak Holmstrom
2022-02-17LibCore: Add FreeBSD as OpenBSD/Apple in System.cpp & System.hIsak Holmstrom
2022-02-16LibCore: Migrate ConfigFile to Core::Stream API :^)Sam Atkins
As part of this, moved the call to `reparse()` out of the constructor and into the factory methods, to allow the error to propagate.
2022-02-16LibCore+Everywhere: Return ErrorOr from ConfigFile::sync()Sam Atkins
Currently this method always succeeds, but that won't be true once we switch to the Core::Stream API. :^) Some of these places would ideally show an error message to the user, since failure to save a file is significant, but let's not get distracted right now.
2022-02-16LibCore: Create ConfigFiles with an already-open FileSam Atkins
This moves the fallible action of opening the file, from the constructor, into the factory methods which can propagate any errors. The wrinkle here is that failure to open a ConfigFile in read-only mode is allowed (and expected, since the file may not exist), and treated as if an empty file was successfully opened.
2022-02-16LibCore+Everywhere: Return ErrorOr from ConfigFile factory methodsSam Atkins
I've attempted to handle the errors gracefully where it was clear how to do so, and simple, but a lot of this was just adding `release_value_but_fixme_should_propagate_errors()` in places.
2022-02-16LibCore+Tests: Add SeekableStream::truncate()Sam Atkins
2022-02-16LibCore: Make ConfigFile parsing work for non-null-terminated stringsSam Atkins
This is necessary for converting it to Core::Stream.
2022-02-15LibCore: Exit get_next_timer_expiration() sooner if possibleAndreas Kling
If we find a timer that needs to be fired immediately, we can stop looking through the remaining timers. This significantly reduces time spent in get_next_timer_expiration() on ACID3. Of course, with a better data structure, we could reduce time spent further. I've left a FIXME about that.
2022-02-14LibCore: Remove Core::Socket :^)sin-ack
This class is one of the last users of Core::IODevice and is no longer used itself.
2022-02-14LibCore: Implement System::fchownsin-ack
2022-02-14LibCore+Tests: Remove Core::UDPSocket :^)sin-ack
2022-02-14LibCore: Add a timeout option to UDPSocket::connectsin-ack
This allows us to set a timeout during connection and during receive and send operations. I didn't add this to the other connect calls as it's not used anywhere else for the time being.
2022-02-13LibCore: Allow event loops on other threads to wake upkleines Filmröllchen
Because the wake pipe is thread-local, it was previously not possible to wake an event loop across a thread. Therefore, this commit rearchitects event loop waking by making the wake function a member of the event loop itself and having it keep a pointer to its thread's wake pipe. The global wake() function calls wake on the current thread's event loop. This also fixes a bug in BackgroundAction: it should wake the event loop it was created on, instead of the current thread's event loop.
2022-02-13LibCore: Fix event loop stacks on non-main threadskleines Filmröllchen
Previously, event loop stacks on non-main threads would always crash because the condition for "am I the lowest-stacked loop" was still "am I the main loop", which of course is no longer sensible. A simple switch to `is_instantiated` fixes this.
2022-02-13AK+Kernel: Rename try_make_weak_ptr to make_weak_ptr_if_nonnullIdan Horowitz
This matches the likes of the adopt_{own, ref}_if_nonnull family and also frees up the name to allow us to eventually add OOM-fallible versions of these functions.
2022-02-13LibCore: Add Darwin anon_create supportFiliph Sandström
2022-02-13LibCore: Add syscall wrapper for profiling_free_buffer()rvictorr
2022-02-13LibCore: Add syscall wrapper for profiling_disable()rvictorr