@@ -124,8 +124,8 @@ namespace
124124#ifndef _WIN32
125125 const int datadir_fd;
126126#endif
127- static const std::vector<std::string> data_exts;
128- static const std::string log_file_prefix;
127+ static const LEX_CSTRING data_exts[] ;
128+ static const LEX_CSTRING log_file_prefix;
129129 using dir_name = std::string;
130130 using dir_contents = std::vector<std::string>;
131131 using database_dir = std::pair<dir_name, dir_contents>;
@@ -258,25 +258,30 @@ namespace
258258
259259 int copy_file (const std::string &path) const noexcept
260260 {
261+ return copy_file (path.c_str ());
262+ }
263+
264+ int copy_file (const char *path) const noexcept
265+ {
261266#ifndef _WIN32
262267 int ret_val = 0 ;
263- int src_fd = openat (datadir_fd, path. c_str () , O_RDONLY );
268+ int src_fd = openat (datadir_fd, path, O_RDONLY );
264269 if (src_fd < 0 )
265270 {
266- my_error (ER_CANT_OPEN_FILE , MYF (0 ), path. c_str () , errno);
271+ my_error (ER_CANT_OPEN_FILE , MYF (0 ), path, errno);
267272 return 1 ;
268273 }
269- int tgt_fd = openat (target.fd , path. c_str () ,
274+ int tgt_fd = openat (target.fd , path,
270275 O_CREAT | O_EXCL | O_WRONLY , 0777 );
271276 if (tgt_fd < 0 )
272277 {
273- my_error (ER_CANT_CREATE_FILE , MYF (0 ), path. c_str () , errno);
278+ my_error (ER_CANT_CREATE_FILE , MYF (0 ), path, errno);
274279 ret_val = 1 ;
275280 goto finish;
276281 }
277282 if (copy_entire_file (src_fd, tgt_fd) != 0 )
278283 {
279- my_error (ER_ERROR_ON_WRITE , MYF (0 ), path. c_str () , errno);
284+ my_error (ER_ERROR_ON_WRITE , MYF (0 ), path, errno);
280285 ret_val = 1 ;
281286 }
282287 close (tgt_fd);
@@ -298,31 +303,22 @@ namespace
298303 }
299304
300305
301- static bool is_db_file (const char * file_name) noexcept
302- {
303- for (const std::string& ext : data_exts)
304- {
305- if (ends_with (file_name, ext))
306- return true ;
307- }
308- /* As a stop-gap db/opt files are also copied here, this should be done in SQL layer. */
309- return !strcmp (file_name, " db.opt" );
310- }
306+ static bool is_db_file (const char * file_name) noexcept ;
311307
312- static bool ends_with (const char * str, const std::string & suffix) noexcept
308+ static bool ends_with (const char * str, const LEX_CSTRING & suffix) noexcept
313309 {
314310 size_t str_len = strlen (str);
315- size_t suffix_len = suffix.size () ;
311+ size_t suffix_len = suffix.length ;
316312 if (str_len < suffix_len)
317313 return false ;
318314 return memcmp (str + str_len - suffix_len,
319- suffix.data () ,
315+ suffix.str ,
320316 suffix_len) == 0 ;
321317 }
322318
323- static bool begins_with (const char * str, const std::string & prefix) noexcept
319+ static bool begins_with (const char * str, const LEX_CSTRING & prefix) noexcept
324320 {
325- return strncmp (str, prefix.data () , prefix.size () ) == 0 ;
321+ return strncmp (str, prefix.str , prefix.length ) == 0 ;
326322 }
327323
328324#ifdef _WIN32
@@ -336,9 +332,23 @@ namespace
336332
337333 /* TODO: .frm failes are not Aria-specific, .MYD and .MYI are MyISAM files;
338334 they are copied here as a stop-gap */
339- const std::vector<std::string>
340- Aria_backup::data_exts {" .MAD" s, " .MAI" s, " MYD" s, " MYI" s, " frm" s};
341- const std::string Aria_backup::log_file_prefix {" aria_log." };
335+ const LEX_CSTRING Aria_backup::data_exts[] {{C_STRING_WITH_LEN (" .MAD" )},
336+ {C_STRING_WITH_LEN (" .MAI" )},
337+ {C_STRING_WITH_LEN (" .MYD" )},
338+ {C_STRING_WITH_LEN (" .MYI" )},
339+ {C_STRING_WITH_LEN (" .frm" )}};
340+ const LEX_CSTRING Aria_backup::log_file_prefix {C_STRING_WITH_LEN (" aria_log." )};
341+
342+ bool Aria_backup::is_db_file (const char * file_name) noexcept
343+ {
344+ for (const LEX_CSTRING & ext : data_exts)
345+ {
346+ if (ends_with (file_name, ext))
347+ return true ;
348+ }
349+ /* As a stop-gap db/opt files are also copied here, this should be done in SQL layer. */
350+ return !strcmp (file_name, " db.opt" );
351+ }
342352
343353 std::unique_ptr<Aria_backup> aria_backup;
344354}
0 commit comments