Mercurial > octave
comparison liboctave/system/lo-sysdep.cc @ 30534:f69ddab4b0ec
get_ASCII_filename: Replace VLA with std::wstring.
* liboctave/system/lo-sysdep.cc (get_ASCII_filename): Replace VLA with
std::wstring.
author | Gene Harvey <gharveymn@gmail.com> |
---|---|
date | Mon, 27 Sep 2021 13:55:27 -0500 |
parents | ce4436d2b206 |
children | 83f9f8bda883 |
comparison
equal
deleted
inserted
replaced
30532:5ff87e646505 | 30534:f69ddab4b0ec |
---|---|
697 // Create file from hash of full filename. | 697 // Create file from hash of full filename. |
698 std::string filename_hash | 698 std::string filename_hash |
699 = (oct_ascii_dir + file_ops::dir_sep_str () | 699 = (oct_ascii_dir + file_ops::dir_sep_str () |
700 + crypto::hash ("SHA1", orig_file_name)); | 700 + crypto::hash ("SHA1", orig_file_name)); |
701 | 701 |
702 // FIXME: This is just to check if the file exists. Use a more efficient | |
703 // method. | |
702 std::string abs_filename_hash = canonicalize_file_name (filename_hash); | 704 std::string abs_filename_hash = canonicalize_file_name (filename_hash); |
703 | 705 |
704 if (! abs_filename_hash.empty ()) | 706 if (! abs_filename_hash.empty ()) |
705 sys::unlink (filename_hash); | 707 sys::unlink (filename_hash); |
706 | 708 |
707 wchar_t w_filename_hash[filename_hash.length ()+1] = {0}; | 709 // At this point, we know that we have only ASCII characters. |
708 | 710 // So instead of converting, just copy the characters to std::wstring. |
709 for (std::size_t i=0; i < filename_hash.length (); i++) | 711 std::wstring w_filename_hash (filename_hash.begin (), |
710 w_filename_hash[i] = filename_hash.at (i); | 712 filename_hash.end ()); |
711 | 713 |
712 if (CreateHardLinkW (w_filename_hash, w_orig_file_name, nullptr)) | 714 if (CreateHardLinkW (w_filename_hash.c_str (), w_orig_file_name, nullptr)) |
713 return filename_hash; | 715 return filename_hash; |
714 | 716 |
715 #else | 717 #else |
716 | 718 |
717 octave_unused_parameter (allow_locale); | 719 octave_unused_parameter (allow_locale); |