wip: add mkdir, cd, simplify find_filename_in_directory usage, fix old issues

This commit is contained in:
2025-05-16 12:22:31 +03:00
parent a90f09ff6e
commit ff684fad45
5 changed files with 426 additions and 60 deletions

View File

@@ -61,6 +61,8 @@ int fs_seek(void *d);
int fs_read(void *d);
int fs_write(void *d);
int fs_close(void *d);
int fs_mkdir(void *d);
int fs_cd(void *d);
int fs_truncate(void *d);
int fs_allow_write(void *d);
int fs_prohibit_write(void *d);

View File

@@ -9,68 +9,58 @@
#include "color.h"
#if DEBUG == 1
#define pr(...) { printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__); }
#define pr(...) do { printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__); } while (0)
#else
#define pr(...) {}
#define pr(...)
#endif
#if ENABLE_STDOUT == 1
#define pr_stdout(...) { printf(__VA_ARGS__); }
#define write_stdout(data, size) { write(1, (data), (size)); }
#define pr_stdout(...) do { printf(__VA_ARGS__); } while (0)
#define write_stdout(data, size) do { write(1, (data), (size)); } while (0)
#else
#define pr_stdout(...) {}
#define write_stdout(data, size) {}
#define pr_stdout(...)
#define write_stdout(data, size)
#endif
#if LOG_LEVEL >= 0
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_generic(color, prefix, ...) do { \
printf(color "[%s:%d] " prefix, __FILE__, __LINE__); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
} while (0)
#else
#define pr_generic(color, prefix, ...) do { \
printf(color prefix); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
} while (0)
#endif
#else
#define pr_generic(color, prefix, ...)
#endif
#if LOG_LEVEL >= 2
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_err(...) { \
printf(COLOR_RED "[%s:%d] Error: ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
}
#else
#define pr_err(...) { \
printf(COLOR_RED "Error: "); \
printf(__VA_ARGS__); \
printf(COLOR_RESET);\
}
#endif
#define pr_err(...) pr_generic(COLOR_RED, "Error: ", __VA_ARGS__)
#else
#define pr_err(...) {}
#define pr_err(...)
#endif
#if LOG_LEVEL >= 3
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_warn(...) { \
printf(COLOR_YELLOW "[%s:%d] Warning: ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
}
#else
#define pr_warn(...) { \
printf(COLOR_YELLOW "Warning: "); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
}
#endif
#define pr_warn(...) pr_generic(COLOR_YELLOW, "Warning: ", __VA_ARGS__)
#else
#define pr_warn(...) {}
#define pr_warn(...)
#endif
#if LOG_LEVEL >= 4
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_info(...) { \
printf("[%s:%d] Info: ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
}
#else
#define pr_info(...) { printf("Info: "); printf(__VA_ARGS__); }
#endif
#define pr_info(...) pr_generic(COLOR_RESET, "Info: ", __VA_ARGS__)
#else
#define pr_info(...) {}
#define pr_info(...)
#endif