Merge branch 'main' into feature/new-object-system

This commit is contained in:
2025-10-15 11:13:00 +01:00
227 changed files with 8252 additions and 2129 deletions

View File

@@ -274,6 +274,23 @@ static enum b_status stream_seek(
return b_file_cursor(file, &stream->s_cursor);
}
static enum b_status stream_tell(const struct b_stream *stream, size_t *pos)
{
const struct b_file *file = stream->s_ptr;
off_t v = lseek(file->fd, 0, SEEK_CUR);
if (v == (off_t)-1) {
return b_status_from_errno(errno, B_ERR_IO_FAILURE);
}
*pos = v;
return B_SUCCESS;
}
const struct b_path *b_file_path(const struct b_file *file)
{
return file->path;
}
enum b_status b_file_open_stream(struct b_file *file, struct b_stream **out)
{
struct b_stream *stream = malloc(sizeof *stream);
@@ -301,6 +318,7 @@ enum b_status b_file_open_stream(struct b_file *file, struct b_stream **out)
stream->s_read = stream_read;
stream->s_write = stream_write;
stream->s_seek = stream_seek;
stream->s_tell = stream_tell;
*out = stream;
@@ -382,11 +400,11 @@ enum b_status b_file_seek(
}
int err = lseek(file->fd, offset, whence);
if (err == 0) {
return B_SUCCESS;
if (err == (off_t)-1) {
return b_status_from_errno(errno, B_ERR_IO_FAILURE);
}
return b_status_from_errno(errno, B_ERR_IO_FAILURE);
return B_SUCCESS;
}
enum b_status b_file_swap_shadow(struct b_file *main_file, struct b_file *shadow_file)