From 072f86ca83bb7138fe33f10b6380badd9ef7f065 Mon Sep 17 00:00:00 2001 From: Tobias Sargeant Date: Wed, 18 Oct 2017 16:39:09 +0100 Subject: Provide helper wrappers for basename(3) and dirname(3) This hides the need to provide mutable C strings, and unifies existing basename calls and variations in a single location. Change-Id: Idfb449c47b1421f1a751efc3d7404f15f8b369ca Reviewed-on: https://chromium-review.googlesource.com/725731 Reviewed-by: Mark Mentovai Reviewed-by: Mike Frysinger --- src/common/linux/dump_symbols.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/common/linux/dump_symbols.cc') diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index 13a545f3..4e9afd2e 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -66,6 +66,7 @@ #include "common/linux/file_id.h" #include "common/memory_allocator.h" #include "common/module.h" +#include "common/path_helper.h" #include "common/scoped_ptr.h" #ifndef NO_STABS_SUPPORT #include "common/stabs_reader.h" @@ -877,16 +878,6 @@ const char* ElfArchitecture(const typename ElfClass::Ehdr* elf_header) { } } -// Return the non-directory portion of FILENAME: the portion after the -// last slash, or the whole filename if there are no slashes. -string BaseFileName(const string &filename) { - // Lots of copies! basename's behavior is less than ideal. - char* c_filename = strdup(filename.c_str()); - string base = basename(c_filename); - free(c_filename); - return base; -} - template bool SanitizeDebugFile(const typename ElfClass::Ehdr* debug_elf_header, const string& debuglink_file, @@ -937,7 +928,7 @@ bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header, return false; } - string name = BaseFileName(obj_filename); + string name = google_breakpad::BaseName(obj_filename); string os = "Linux"; // Add an extra "0" at the end. PDB files on Windows have an 'age' // number appended to the end of the file identifier; this isn't -- cgit v1.2.1