@@ -111,65 +111,16 @@ inline constexpr dos_at_flags &operator^=(dos_at_flags &x, dos_at_flags y) noexc
111111namespace details
112112{
113113
114- struct my_dos_concat_path_common_result
115- {
116- bool failed{};
117- ::fast_io::tlc::string path = ::fast_io::tlc::string();
118- };
119-
120- inline my_dos_concat_path_common_result my_dos_concat_path_common (int dirfd, char const *pathname) noexcept
121- {
122- if (dirfd == -100 )
123- {
124- return {false , ::fast_io::tlc::string (::fast_io::mnp::os_c_str (pathname))};
125- }
126- else
127- {
128- auto pathname_cstr{::fast_io::noexcept_call (::__get_fd_name, dirfd)};
129- if (pathname_cstr == nullptr ) [[unlikely]]
130- {
131- return {true };
132- }
133-
134- // check vaildity
135- auto const sz{::fast_io::cstr_len (pathname)};
136-
137- if (sz > 255 ) [[unlikely]]
138- {
139- return {true };
140- }
141-
142- if (::fast_io::details::is_invalid_dos_filename_with_size (pathname, sz)) [[unlikely]]
143- {
144- return {true };
145- }
146-
147- // concat
148- return {false , ::fast_io::tlc::concat_fast_io_tlc (::fast_io::mnp::os_c_str (pathname_cstr), ::fast_io::mnp::chvw (u8 ' \\ ' ), para_pathname)};
149- }
150- }
151-
152- template <bool always_terminate = true >
153- inline ::fast_io::tlc::string my_dos_concat_path (int dirfd, char const *pathname) noexcept (always_terminate)
154- {
155- auto [failed, path] = ::fast_io::details::my_dos_concat_path_common (dirfd, pathname);
156- if (failed) [[unlikely]]
157- {
158- ::fast_io::system_call_throw_error<always_terminate>(-1 );
159- }
160- return ::std::move (path);
161- }
162-
163114inline void dos_renameat_impl (int olddirfd, char const *oldpath, int newdirfd, char const *newpath)
164115{
165- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_rename(::fast_io::details::my_dos_concat_path (olddirfd, oldpath).c_str(),
166- ::fast_io::details::my_dos_concat_path (newdirfd, newpath).c_str()));
116+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_rename(::fast_io::details::my_dos_concat_tlc_path (olddirfd, oldpath).c_str(),
117+ ::fast_io::details::my_dos_concat_tlc_path (newdirfd, newpath).c_str()));
167118}
168119
169120inline void dos_linkat_impl (int olddirfd, char const *oldpath, int newdirfd, char const *newpath)
170121{
171- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_link(::fast_io::details::my_dos_concat_path (olddirfd, oldpath).c_str(),
172- ::fast_io::details::my_dos_concat_path (newdirfd, newpath).c_str()));
122+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_link(::fast_io::details::my_dos_concat_tlc_path (olddirfd, oldpath).c_str(),
123+ ::fast_io::details::my_dos_concat_tlc_path (newdirfd, newpath).c_str()));
173124}
174125
175126template <posix_api_22 dsp, typename ... Args>
@@ -187,7 +138,7 @@ inline auto dos22_api_dispatcher(int olddirfd, char const *oldpath, int newdirfd
187138
188139inline void dos_symlinkat_impl (char const *oldpath, int newdirfd, char const *newpath)
189140{
190- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_symlink(oldpath, ::fast_io::details::my_dos_concat_path (newdirfd, newpath).c_str()));
141+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_symlink(oldpath, ::fast_io::details::my_dos_concat_tlc_path (newdirfd, newpath).c_str()));
191142}
192143
193144template <posix_api_12 dsp, typename ... Args>
@@ -201,37 +152,37 @@ inline auto dos12_api_dispatcher(char const *oldpath, int newdirfd, char const *
201152
202153inline void dos_faccessat_impl (int dirfd, char const *pathname, int flags)
203154{
204- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_access(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str(), flags));
155+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_access(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str(), flags));
205156}
206157
207158inline void dos_fchownat_impl (int dirfd, char const *pathname, uintmax_t owner, uintmax_t group)
208159{
209160 // chown does nothing under MS-DOS, so just check is_valid filename
210- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_chown(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str(),
161+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_chown(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str(),
211162 static_cast<int>(owner), static_cast<int>(group)));
212163}
213164
214165inline void dos_fchmodat_impl (int dirfd, char const *pathname, mode_t mode)
215166{
216- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_chmod(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str(), mode));
167+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_chmod(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str(), mode));
217168}
218169
219170inline posix_file_status dos_fstatat_impl (int dirfd, char const *pathname)
220171{
221172 struct stat buf;
222173
223- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_stat(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str(), __builtin_addressof(buf)));
174+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_stat(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str(), __builtin_addressof(buf)));
224175 return ::fast_io::details::struct_stat_to_posix_file_status (buf);
225176}
226177
227178inline void dos_mkdirat_impl (int dirfd, char const *pathname, mode_t mode)
228179{
229- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_mkdir(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str(), mode));
180+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_mkdir(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str(), mode));
230181}
231182
232183inline void dos_unlinkat_impl (int dirfd, char const *pathname)
233184{
234- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_unlink(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str()));
185+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_unlink(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str()));
235186}
236187
237188inline constexpr ::std::time_t unix_timestamp_to_time_t (unix_timestamp stmp) noexcept
@@ -271,7 +222,7 @@ inline void dos_utimensat_impl(int dirfd, char const *pathname, unix_timestamp_o
271222 ::fast_io::details::unix_timestamp_to_time_t(last_modification_time),
272223 };
273224
274- ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_utime(::fast_io::details::my_dos_concat_path (dirfd, pathname).c_str(), __builtin_addressof(ts)));
225+ ::fast_io::system_call_throw_error (::fast_io::posix::my_dos_utime(::fast_io::details::my_dos_concat_tlc_path (dirfd, pathname).c_str(), __builtin_addressof(ts)));
275226}
276227
277228template <posix_api_1x dsp, typename ... Args>
0 commit comments