Mercurial > octave
changeset 31196:4c38cf0ce06c stable
canonicalize_file_name: Check root of potential mapped network drive (bug #62847).
* liboctave/system/file-ops.cc (canonicalize_file_name): Make sure to compare
with the canonicalized path corresponding to the root of the drive when checking
if a file is on a mapped network drive.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 23 Aug 2022 19:44:16 +0200 |
parents | 6bcc5e6d77fe |
children | 8d4c87e88d0e 863730dd0f83 |
files | liboctave/system/file-ops.cc |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/system/file-ops.cc Thu Aug 18 08:40:57 2022 +0200 +++ b/liboctave/system/file-ops.cc Tue Aug 23 19:44:16 2022 +0200 @@ -750,11 +750,12 @@ // If the initial path looked like a mapped network drive, replace // portion of path that corresponds to mapped root with drive root. - if (name.size () < 2 || name[1] != ':') + if (name.size () < 3 || name[1] != ':') return retval; // UNC path corresponding to original drive letter (mappped drive) - std::wstring orig_map = wname.substr (0, 2); + std::wstring orig_map = wname.substr (0, 3); + orig_map[2] = L'\\'; HANDLE h_map = CreateFileW (orig_map.c_str (), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS