Skip to main content

rl_lang/docs/entries/stdlib/fs/
mod.rs

1use crate::docs::entry::{FnEntry, StdEntry};
2
3pub static FS: StdEntry = StdEntry {
4    name: "fs",
5    description: "functions for working with the filesystem",
6    functions: FUNCTIONS,
7    since: None,
8    unstable: false,
9};
10
11static FUNCTIONS: &[&FnEntry] = &[
12    &COPY_FILE,
13    &FILE_MODIFIED,
14    &FILE_SIZE,
15    &LIST_DIR,
16    &MKDIR,
17    &MKDIR_ALL,
18    &MOVE_FILE,
19    &RENAME_FILE,
20    &RMDIR,
21    &RMDIR_ALL,
22    &TEMP_DIR,
23];
24
25static COPY_FILE: FnEntry = FnEntry {
26    signature: "copy_file(src, dst)",
27    description: "copies a file from src to dst, returns the number of bytes copied",
28    example: "get std::fs::copy_file\n\ncopy_file(\"a.txt\", \"b.txt\") // 1024",
29    expected_output: None,
30    returns: "",
31    errors: None,
32    see_also: &[],
33    since: None,
34};
35
36static FILE_MODIFIED: FnEntry = FnEntry {
37    signature: "file_modified(path)",
38    description: "returns the last modification time of the file as a unix timestamp (seconds since epoch)",
39    example: "get std::fs::file_modified\n\nfile_modified(\"./Cargo.toml\") // 1750000000",
40    expected_output: None,
41    returns: "",
42    errors: None,
43    see_also: &[],
44    since: None,
45};
46
47static FILE_SIZE: FnEntry = FnEntry {
48    signature: "file_size(path)",
49    description: "returns the size of the file in bytes",
50    example: "get std::fs::file_size\n\nfile_size(\"./Cargo.toml\") // 215",
51    expected_output: None,
52    returns: "",
53    errors: None,
54    see_also: &[],
55    since: None,
56};
57
58static LIST_DIR: FnEntry = FnEntry {
59    signature: "list_dir(path)",
60    description: "returns an array of paths for the entries in the directory",
61    example: "get std::fs::list_dir\n\nlist_dir(\"./src\") // [\"./src/main.rl\", \"./src/html_tags\"]",
62    expected_output: None,
63    returns: "",
64    errors: None,
65    see_also: &[],
66    since: None,
67};
68
69static MKDIR: FnEntry = FnEntry {
70    signature: "mkdir(path)",
71    description: "creates a directory, fails if the parent directory does not exist",
72    example: "get std::fs::mkdir\n\nmkdir(\"./build\")",
73    expected_output: None,
74    returns: "",
75    errors: None,
76    see_also: &[],
77    since: None,
78};
79
80static MKDIR_ALL: FnEntry = FnEntry {
81    signature: "mkdir_all(path)",
82    description: "creates a directory along with any missing parent directories",
83    example: "get std::fs::mkdir_all\n\nmkdir_all(\"./build/assets/css\")",
84    expected_output: None,
85    returns: "",
86    errors: None,
87    see_also: &[],
88    since: None,
89};
90
91static MOVE_FILE: FnEntry = FnEntry {
92    signature: "move_file(src, dst)",
93    description: "moves a file from src to dst",
94    example: "get std::fs::move_file\n\nmove_file(\"/tmp/a.txt\", \"/tmp/b.txt\")",
95    expected_output: None,
96    returns: "",
97    errors: None,
98    see_also: &[],
99    since: None,
100};
101
102static RENAME_FILE: FnEntry = FnEntry {
103    signature: "rename_file(path, new_name)",
104    description: "renames a file, keeping it in its current directory, and returns the new path",
105    example: "get std::fs::rename_file\n\nrename_file(\"/usr/bin/rl\", \"rl-old\") // \"/usr/bin/rl-old\"",
106    expected_output: None,
107    returns: "",
108    errors: None,
109    see_also: &[],
110    since: None,
111};
112
113static RMDIR: FnEntry = FnEntry {
114    signature: "rmdir(path)",
115    description: "removes an empty directory, fails if it is not empty",
116    example: "get std::fs::rmdir\n\nrmdir(\"./build\")",
117    expected_output: None,
118    returns: "",
119    errors: None,
120    see_also: &[],
121    since: None,
122};
123
124static RMDIR_ALL: FnEntry = FnEntry {
125    signature: "rmdir_all(path)",
126    description: "removes a directory and all of its contents recursively",
127    example: "get std::fs::rmdir_all\n\nrmdir_all(\"./build\")",
128    expected_output: None,
129    returns: "",
130    errors: None,
131    see_also: &[],
132    since: None,
133};
134
135static TEMP_DIR: FnEntry = FnEntry {
136    signature: "temp_dir()",
137    description: "returns the path of the system's temporary directory",
138    example: "get std::fs::temp_dir\n\ntemp_dir() // \"/tmp\"",
139    expected_output: None,
140    returns: "",
141    errors: None,
142    see_also: &[],
143    since: None,
144};