diff options
| author | наб <nabijaczleweli@nabijaczleweli.xyz> | 2025-01-23 19:33:57 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-14 19:45:12 +0100 |
| commit | 2499d9ff0c55a445a62643028a9d3bc9faf1195a (patch) | |
| tree | 1bab22e439296982bb4cc380a2420a9d805d5a7a /apt-pkg/contrib | |
| parent | 4f6d379124bc51a09608fa3f45d66713f927b959 (diff) | |
string{=> _view} flExtension(string{=> _view})
Diffstat (limited to 'apt-pkg/contrib')
| -rw-r--r-- | apt-pkg/contrib/fileutl.cc | 14 | ||||
| -rw-r--r-- | apt-pkg/contrib/fileutl.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index e57662abc..1a417f7e2 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -485,7 +485,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c { if (RealFileExists(File) == false) { - string d_ext = flExtension(Ent->d_name); + auto d_ext = flExtension(Ent->d_name); // do not show ignoration warnings for directories if (( #ifdef _DIRENT_HAVE_D_TYPE @@ -505,7 +505,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c // extensions given -> "" extension allows no extension if (Ext.empty() == false) { - string d_ext = flExtension(Ent->d_name); + auto d_ext = flExtension(Ent->d_name); if (d_ext == Ent->d_name) // no extension { if (std::find(Ext.begin(), Ext.end(), "") == Ext.end()) @@ -694,13 +694,13 @@ string flNotFile(string File) // flExtension - Return the extension for the file /*{{{*/ // --------------------------------------------------------------------- /* */ -string flExtension(string File) +string_view flExtension(string_view File) { - string::size_type Res = File.rfind('.'); - if (Res == string::npos) + string_view::size_type Res = File.rfind('.'); + if (Res == string_view::npos) return File; - Res++; - return string(File,Res); + File.remove_prefix(Res + 1); + return File; } /*}}}*/ // flNoLink - If file is a symlink then deref it /*{{{*/ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 4ecddbf86..52f9bc657 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -255,7 +255,7 @@ APT_PUBLIC bool DropPrivileges(); APT_PUBLIC std::string flNotDir(std::string File); APT_PUBLIC std::string flNotFile(std::string File); APT_PUBLIC std::string flNoLink(std::string File); -APT_PUBLIC std::string flExtension(std::string File); +APT_PUBLIC std::string_view flExtension(std::string_view File); APT_PUBLIC std::string flCombine(std::string Dir,std::string File); /** \brief Takes a file path and returns the absolute path |
