@@ -52,12 +52,11 @@ static bool no_arg(std::string_view fun){
52
52
{" has_statx" , fs_has_statx}
53
53
};
54
54
55
- using fs_function = std::function<std::variant<std::string, bool , int , char , long , pid_t , std::size_t >()>;
55
+ using fs_function = std::function<std::variant<std::string, bool , int , char , long , std::size_t >()>;
56
56
57
57
std::unordered_map<std::string_view, fs_function> fs_function_map = {
58
58
{" backend" , []() { return fs_backend (); }},
59
59
{" is_wsl" , []() { return fs_is_wsl (); }},
60
- {" pid" , []() { return fs_getpid (); }},
61
60
{" pathsep" , []() { return fs_pathsep (); }},
62
61
{" cpp_lang" , []() { return fs_cpp_lang (); }},
63
62
{" c_lang" , []() { return fs_c_lang (); }},
@@ -102,6 +101,8 @@ std::unordered_map<std::string_view, fs_function> fs_function_map = {
102
101
103
102
} else if (mbool.find (fun) != mbool.end ())
104
103
std::cout << mbool[fun]();
104
+ else if (fun == " pid" )
105
+ std::cout << fs_getpid ();
105
106
else
106
107
ok = false ;
107
108
@@ -118,11 +119,7 @@ static bool one_arg(std::string_view fun, std::string_view a1)
118
119
std::error_code ec;
119
120
120
121
// each possible return type for the function
121
- using fs_one_arg_function = std::function<std::variant<std::string, bool , std::size_t , int
122
- #if uintmax_t != size_t
123
- , uintmax_t
124
- #endif
125
- >(std::string_view)>;
122
+ using fs_one_arg_function = std::function<std::variant<std::string, bool , std::size_t , int >(std::string_view)>;
126
123
127
124
std::unordered_map<std::string_view, fs_one_arg_function> fs_one_arg_function_map = {
128
125
{" lexically_normal" , [](std::string_view a1) { return fs_lexically_normal (a1); }},
@@ -133,7 +130,6 @@ static bool one_arg(std::string_view fun, std::string_view a1)
133
130
{" weakly_canonical" , [](std::string_view a1) { return fs_canonical (a1, false ); }},
134
131
{" resolve" , [](std::string_view a1) { return fs_resolve (a1, true ); }},
135
132
{" weakly_resolve" , [](std::string_view a1) { return fs_resolve (a1, false ); }},
136
- {" hard" , [](std::string_view a1) { return fs_hard_link_count (a1); }},
137
133
{" normal" , [](std::string_view a1) { return fs_normal (a1); }},
138
134
{" type" , [](std::string_view a1) { return fs_filesystem_type (a1); }},
139
135
{" is_reserved" , [](std::string_view a1) { return fs_is_reserved (a1); }},
@@ -160,7 +156,6 @@ static bool one_arg(std::string_view fun, std::string_view a1)
160
156
{" drop_slash" , [](std::string_view a1) { return fs_drop_slash (a1); }},
161
157
{" root_name" , [](std::string_view a1) { return fs_root_name (a1); }},
162
158
{" filename" , [](std::string_view a1) { return fs_file_name (a1); }},
163
- {" file_size" , [](std::string_view a1) { return fs_file_size (a1); }},
164
159
{" is_absolute" , [](std::string_view a1) { return fs_is_absolute (a1); }},
165
160
{" is_exe" , [](std::string_view a1) { return fs_is_exe (a1); }},
166
161
{" is_exe_bin" , [](std::string_view a1) { return fs_is_executable_binary (a1); }},
@@ -180,8 +175,6 @@ static bool one_arg(std::string_view fun, std::string_view a1)
180
175
{" read_symlink" , [](std::string_view a1) { return fs_read_symlink (a1); }},
181
176
{" stem" , [](std::string_view a1) { return fs_stem (a1); }},
182
177
{" exists" , [](std::string_view a1) { return fs_exists (a1); }},
183
- {" space_available" , [](std::string_view a1) { return fs_space_available (a1); }},
184
- {" space_capacity" , [](std::string_view a1) { return fs_space_capacity (a1); }},
185
178
{" blksize" , [](std::string_view a1) { return fs_get_blksize (a1); }},
186
179
{" absolute" , [](std::string_view a1) { return fs_absolute (a1, true ); }},
187
180
{" is_empty" , [](std::string_view a1) { return fs_is_empty (a1); }},
@@ -190,6 +183,14 @@ static bool one_arg(std::string_view fun, std::string_view a1)
190
183
{" which_all" , [](std::string_view a1) { return fs_which (a1, " " , true ); }},
191
184
};
192
185
186
+ std::map<std::string_view, std::function<std::uintmax_t (std::string_view)>> m1uintm =
187
+ {
188
+ {" file_size" , [](std::string_view a1) { return fs_file_size (a1); }},
189
+ {" space_available" , [](std::string_view a1) { return fs_space_available (a1); }},
190
+ {" space_capacity" , [](std::string_view a1) { return fs_space_capacity (a1); }},
191
+ {" hard_link_count" , [](std::string_view a1) { return fs_hard_link_count (a1); }}
192
+ };
193
+
193
194
bool ok = true ;
194
195
195
196
auto it = fs_one_arg_function_map.find (fun);
@@ -209,6 +210,8 @@ static bool one_arg(std::string_view fun, std::string_view a1)
209
210
else
210
211
ok = false ;
211
212
213
+ } else if (m1uintm.find (fun) != m1uintm.end ()) {
214
+ std::cout << m1uintm[fun](a1);
212
215
} else if (fun == " modtime" ){
213
216
214
217
#if defined(HAVE_CXX_FILESYSTEM) && defined(__cpp_lib_format) // C++20
0 commit comments