diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-13 20:18:08 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-13 20:18:08 -0400 |
| commit | c455e7b67d2e55e6ed03e3449203d4e307f5a7dd (patch) | |
| tree | 27d9d4c77193f7aa1fe3a3c6fe5631d0ccfd59e2 /stdlib/paths.h | |
| parent | 816aa29b799132acb8c71d4968df6c4619fb2b1d (diff) | |
Rename builtins/ -> stdlib/
Diffstat (limited to 'stdlib/paths.h')
| -rw-r--r-- | stdlib/paths.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/stdlib/paths.h b/stdlib/paths.h new file mode 100644 index 00000000..e0d85258 --- /dev/null +++ b/stdlib/paths.h @@ -0,0 +1,50 @@ +#pragma once + +// A lang for filesystem paths + +#include <stdbool.h> +#include <stdint.h> + +#include "types.h" +#include "datatypes.h" + +#define Path_t Text_t +#define Path(text) ((Path_t)Text(text)) +#define Paths(...) Path$_concat(sizeof((Path_t[]){__VA_ARGS__})/sizeof(Path_t), (Path_t[]){__VA_ARGS__}) + +Path_t Path$cleanup(Path_t path); +Path_t Path$_concat(int n, Path_t items[n]); +#define Path$concat(a, b) Paths(a, Path("/"), b) +PUREFUNC Path_t Path$escape_text(Text_t text); +PUREFUNC Path_t Path$escape_path(Text_t path); +Path_t Path$resolved(Path_t path, Path_t relative_to); +Path_t Path$relative(Path_t path, Path_t relative_to); +bool Path$exists(Path_t path); +bool Path$is_file(Path_t path, bool follow_symlinks); +bool Path$is_directory(Path_t path, bool follow_symlinks); +bool Path$is_pipe(Path_t path, bool follow_symlinks); +bool Path$is_socket(Path_t path, bool follow_symlinks); +bool Path$is_symlink(Path_t path); +void Path$write(Path_t path, Text_t text, int permissions); +void Path$append(Path_t path, Text_t text, int permissions); +Text_t Path$read(Path_t path); +void Path$remove(Path_t path, bool ignore_missing); +void Path$create_directory(Path_t path, int permissions); +Array_t Path$children(Path_t path, bool include_hidden); +Array_t Path$files(Path_t path, bool include_hidden); +Array_t Path$subdirectories(Path_t path, bool include_hidden); +Path_t Path$unique_directory(Path_t path); +Text_t Path$write_unique(Path_t path, Text_t text); +Path_t Path$parent(Path_t path); +Text_t Path$base_name(Path_t path); +Text_t Path$extension(Path_t path, bool full); +Closure_t Path$by_line(Path_t path); + +#define Path$hash Text$hash +#define Path$compare Text$compare +#define Path$equal Text$equal + +extern const TypeInfo Path$info; + +// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 + |
