## Summary Standardize naming conventions across the entire wizapp-stdlib codebase by replacing inconsistent prefixes and snake_case with a unified `wp` prefix + CamelCase scheme. ## Changes ### Naming convention applied | Pattern | Before | After | |---|---|---| | Public functions | `wapp_module_function` | `wpModuleFunction` | | Public types | `GenericXxx`, bare `Xxx` | `WpXxx` | | Constants / enum values | `WAPP_XXX`, `SHELL_XXX` | `WP_XXX`, `WP_SHELL_XXX` | | Internal functions | `_module_function` | `_moduleFunction` | | Storage-class macros | `wapp_extern`, `wapp_intern` | `wp_extern`, `wp_intern` | ### Modules affected All 20 modules were renamed: `arena`, `array`, `dbl_list`, `queue`, `str8`, `mem_allocator`, `mem_utils`, `mem_os`, `file`, `cpath`, `log`, `shell_commander`, `shell_termcolour`, `shell_utils`, `prng/xorshift`, `uuid`, `tester`, `aliases`, `assert`, `misc_utils`, `platform` — plus their test files. ### Backward compatibility Added `src/oldnames.h` with `#define OLD_NAME NEW_NAME` for every renamed symbol, organized by module under Constants → Types → Functions sections. Existing code that includes this file will compile without changes. Reviewed-on: #12 Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include "file_posix.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#include "../file.h"
|
||||
#include "../../cpath/cpath.h"
|
||||
@@ -11,62 +11,62 @@
|
||||
#include "../../../base/array/array.h"
|
||||
#include "../../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_APPLE
|
||||
#ifdef WP_PLATFORM_APPLE
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define lseek64 lseek
|
||||
#endif // !WAPP_PLATFORM_APPLE
|
||||
#endif // !WP_PLATFORM_APPLE
|
||||
|
||||
#define __USE_LARGEFILE64
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
wapp_intern i32 file_flags[FILE_ACCESS_MODE_COUNT] = {
|
||||
[WAPP_ACCESS_READ] = O_RDONLY,
|
||||
[WAPP_ACCESS_WRITE] = O_WRONLY | O_CREAT,
|
||||
[WAPP_ACCESS_APPEND] = O_WRONLY | O_APPEND | O_CREAT,
|
||||
[WAPP_ACCESS_READ_EX] = O_RDWR,
|
||||
[WAPP_ACCESS_WRITE_EX] = O_RDWR | O_CREAT,
|
||||
[WAPP_ACCESS_APPEND_EX] = O_RDWR | O_APPEND | O_CREAT,
|
||||
[WAPP_ACCESS_WRITE_FAIL_ON_EXIST] = O_WRONLY | O_CREAT | O_EXCL,
|
||||
[WAPP_ACCESS_WRITE_FAIL_ON_EXIST_EX] = O_RDWR | O_CREAT | O_EXCL,
|
||||
wp_intern i32 file_flags[COUNT_FILE_ACCESS_MODE] = {
|
||||
[WP_ACCESS_READ] = O_RDONLY,
|
||||
[WP_ACCESS_WRITE] = O_WRONLY | O_CREAT,
|
||||
[WP_ACCESS_APPEND] = O_WRONLY | O_APPEND | O_CREAT,
|
||||
[WP_ACCESS_READ_EX] = O_RDWR,
|
||||
[WP_ACCESS_WRITE_EX] = O_RDWR | O_CREAT,
|
||||
[WP_ACCESS_APPEND_EX] = O_RDWR | O_APPEND | O_CREAT,
|
||||
[WP_ACCESS_WRITE_FAIL_ON_EXIST] = O_WRONLY | O_CREAT | O_EXCL,
|
||||
[WP_ACCESS_WRITE_FAIL_ON_EXIST_EX] = O_RDWR | O_CREAT | O_EXCL,
|
||||
};
|
||||
|
||||
wapp_intern mode_t file_modes[FILE_ACCESS_MODE_COUNT] = {
|
||||
[WAPP_ACCESS_READ] = 0,
|
||||
[WAPP_ACCESS_WRITE] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WAPP_ACCESS_APPEND] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WAPP_ACCESS_READ_EX] = 0,
|
||||
[WAPP_ACCESS_WRITE_EX] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WAPP_ACCESS_APPEND_EX] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WAPP_ACCESS_WRITE_FAIL_ON_EXIST] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WAPP_ACCESS_WRITE_FAIL_ON_EXIST_EX] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
wp_intern mode_t file_modes[COUNT_FILE_ACCESS_MODE] = {
|
||||
[WP_ACCESS_READ] = 0,
|
||||
[WP_ACCESS_WRITE] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WP_ACCESS_APPEND] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WP_ACCESS_READ_EX] = 0,
|
||||
[WP_ACCESS_WRITE_EX] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WP_ACCESS_APPEND_EX] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WP_ACCESS_WRITE_FAIL_ON_EXIST] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
[WP_ACCESS_WRITE_FAIL_ON_EXIST_EX] = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||
};
|
||||
|
||||
wapp_intern i32 file_seek_origins[FILE_SEEK_ORIGIN_COUNT] = {
|
||||
[WAPP_SEEK_START] = SEEK_SET,
|
||||
[WAPP_SEEK_CURRENT] = SEEK_CUR,
|
||||
[WAPP_SEEK_END] = SEEK_END,
|
||||
wp_intern i32 file_seek_origins[COUNT_FILE_SEEK_ORIGIN] = {
|
||||
[WP_SEEK_START] = SEEK_SET,
|
||||
[WP_SEEK_CURRENT] = SEEK_CUR,
|
||||
[WP_SEEK_END] = SEEK_END,
|
||||
};
|
||||
|
||||
WFile *wapp_file_stdin(void) {
|
||||
wapp_persist WFile _stdin = { .fd = STDIN_FILENO };
|
||||
WpFile *wpFileStdin(void) {
|
||||
wp_persist WpFile _stdin = { .fd = STDIN_FILENO };
|
||||
return &_stdin;
|
||||
}
|
||||
|
||||
WFile *wapp_file_stdout(void) {
|
||||
wapp_persist WFile _stdout = { .fd = STDOUT_FILENO };
|
||||
WpFile *wpFileStdout(void) {
|
||||
wp_persist WpFile _stdout = { .fd = STDOUT_FILENO };
|
||||
return &_stdout;
|
||||
}
|
||||
|
||||
WFile *wapp_file_stderr(void) {
|
||||
wapp_persist WFile _stderr = { .fd = STDERR_FILENO };
|
||||
WpFile *wpFileStderr(void) {
|
||||
wp_persist WpFile _stderr = { .fd = STDERR_FILENO };
|
||||
return &_stderr;
|
||||
}
|
||||
|
||||
WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode) {
|
||||
wapp_persist c8 tmp[WAPP_PATH_MAX] = {0};
|
||||
memset(tmp, 0, WAPP_PATH_MAX);
|
||||
WpFile *_fileOpen(const WpAllocator *allocator, WpStr8RO *filepath, WpFileAccessMode mode) {
|
||||
wp_persist c8 tmp[WP_PATH_MAX] = {0};
|
||||
memset(tmp, 0, WP_PATH_MAX);
|
||||
memcpy(tmp, filepath->buf, filepath->size);
|
||||
|
||||
i32 fd = open((const char *)tmp, file_flags[mode], file_modes[mode]);
|
||||
@@ -74,7 +74,7 @@ WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode m
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WFile *output = wapp_mem_allocator_alloc(allocator, sizeof(WFile));
|
||||
WpFile *output = wpMemAllocatorAlloc(allocator, sizeof(WpFile));
|
||||
if (output) {
|
||||
output->fd = fd;
|
||||
}
|
||||
@@ -82,11 +82,11 @@ WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode m
|
||||
return output;
|
||||
}
|
||||
|
||||
i64 _file_seek(WFile *file, i64 offset, FileSeekOrigin origin) {
|
||||
i64 _fileSeek(WpFile *file, i64 offset, WpFileSeekOrigin origin) {
|
||||
return lseek64(file->fd, offset, file_seek_origins[origin]);
|
||||
}
|
||||
|
||||
u64 _file_read(void *dst_buf, u64 byte_count, WFile *file, u64 file_length) {
|
||||
u64 _fileRead(void *dst_buf, u64 byte_count, WpFile *file, u64 file_length) {
|
||||
u64 copy_byte_count = file_length <= byte_count ? file_length : byte_count;
|
||||
|
||||
i64 count = read(file->fd, dst_buf, copy_byte_count);
|
||||
@@ -95,40 +95,40 @@ u64 _file_read(void *dst_buf, u64 byte_count, WFile *file, u64 file_length) {
|
||||
return count;
|
||||
}
|
||||
|
||||
i64 _file_write(const void *src_buf, WFile *file, u64 byte_count) {
|
||||
i64 _fileWrite(const void *src_buf, WpFile *file, u64 byte_count) {
|
||||
return write(file->fd, src_buf, byte_count);
|
||||
}
|
||||
|
||||
i32 _file_flush(WFile *file) {
|
||||
i32 _fileFlush(WpFile *file) {
|
||||
return fsync(file->fd);
|
||||
}
|
||||
|
||||
i32 _file_close(WFile *file) {
|
||||
i32 _fileClose(WpFile *file) {
|
||||
return close(file->fd);
|
||||
}
|
||||
|
||||
i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
|
||||
wapp_persist c8 old_tmp[WAPP_PATH_MAX] = {0};
|
||||
wapp_persist c8 new_tmp[WAPP_PATH_MAX] = {0};
|
||||
memset(old_tmp, 0, WAPP_PATH_MAX);
|
||||
i32 _fileRename(WpStr8RO *old_filepath, WpStr8RO *new_filepath) {
|
||||
wp_persist c8 old_tmp[WP_PATH_MAX] = {0};
|
||||
wp_persist c8 new_tmp[WP_PATH_MAX] = {0};
|
||||
memset(old_tmp, 0, WP_PATH_MAX);
|
||||
memcpy(old_tmp, old_filepath->buf, old_filepath->size);
|
||||
memset(new_tmp, 0, WAPP_PATH_MAX);
|
||||
memset(new_tmp, 0, WP_PATH_MAX);
|
||||
memcpy(new_tmp, new_filepath->buf, new_filepath->size);
|
||||
|
||||
i32 link_result = link((const char *)old_tmp, (const char *)new_tmp);
|
||||
if (link_result == 0) {
|
||||
_file_remove(old_filepath);
|
||||
_fileRemove(old_filepath);
|
||||
}
|
||||
|
||||
return link_result;
|
||||
}
|
||||
|
||||
i32 _file_remove(Str8RO *filepath) {
|
||||
wapp_persist c8 tmp[WAPP_PATH_MAX] = {0};
|
||||
memset(tmp, 0, WAPP_PATH_MAX);
|
||||
i32 _fileRemove(WpStr8RO *filepath) {
|
||||
wp_persist c8 tmp[WP_PATH_MAX] = {0};
|
||||
memset(tmp, 0, WP_PATH_MAX);
|
||||
memcpy(tmp, filepath->buf, filepath->size);
|
||||
|
||||
return unlink((const char *)tmp);
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
Reference in New Issue
Block a user