LCOV - code coverage report
Current view: top level - src/base - file-utils.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 12 13 92.3 %
Date: 2019-02-19 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/base/file-utils.h"
       6             : 
       7             : #include <stdlib.h>
       8             : #include <string.h>
       9             : 
      10             : #include "src/base/platform/platform.h"
      11             : 
      12             : namespace v8 {
      13             : namespace base {
      14             : 
      15      175739 : char* RelativePath(char** buffer, const char* exec_path, const char* name) {
      16             :   DCHECK(exec_path);
      17      175739 :   int path_separator = static_cast<int>(strlen(exec_path)) - 1;
      18     2020065 :   while (path_separator >= 0 &&
      19      922163 :          !OS::isDirectorySeparator(exec_path[path_separator])) {
      20      746424 :     path_separator--;
      21             :   }
      22      175739 :   if (path_separator >= 0) {
      23      175739 :     int name_length = static_cast<int>(strlen(name));
      24             :     *buffer =
      25      175739 :         reinterpret_cast<char*>(calloc(path_separator + name_length + 2, 1));
      26      175739 :     *buffer[0] = '\0';
      27      175739 :     strncat(*buffer, exec_path, path_separator + 1);
      28      175739 :     strncat(*buffer, name, name_length);
      29             :   } else {
      30           0 :     *buffer = strdup(name);
      31             :   }
      32      175739 :   return *buffer;
      33             : }
      34             : 
      35             : }  // namespace base
      36             : }  // namespace v8

Generated by: LCOV version 1.10