GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: build/include/testDataPath.h Lines: 8 8 100.0 %
Date: 2017-05-26 Branches: 1 2 50.0 %

Line Branch Exec Source
1
/*
2
  Teem: Tools to process and visualize scientific data and images             .
3
  Copyright (C) 2013, 2012  University of Chicago
4
  Copyright (C) 2011  James Bigler
5
  Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
6
  Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
7
8
  This library is free software; you can redistribute it and/or
9
  modify it under the terms of the GNU Lesser General Public License
10
  (LGPL) as published by the Free Software Foundation; either
11
  version 2.1 of the License, or (at your option) any later version.
12
  The terms of redistributing and/or modifying this software also
13
  include exceptions to the LGPL that facilitate static linking.
14
15
  This library is distributed in the hope that it will be useful,
16
  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
  Lesser General Public License for more details.
19
20
  You should have received a copy of the GNU Lesser General Public License
21
  along with this library; if not, write to Free Software Foundation, Inc.,
22
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
*/
24
25
#define TESTING_DATA_PATH "/Users/scm/git/github/teem/data"
26
27
#include <stdlib.h>
28
#include <string.h>
29
#include <teem/air.h>
30
31
/*
32
** testDataPathPrefix allocates and returns a string which is
33
** the given "base" prefixed with the path to the test datasets,
34
** including the "/" between the path and "base".  Caller is
35
** responsible for freeing.
36
**
37
** Thanks to James Bigler for writing the first version of this.
38
*/
39
static char*
40
testDataPathPrefix(const char* base) {
41
  size_t pathLen, baseLen;
42
  char* result;
43
  /* You could add an environment variable override here */
44
  /* if (getenv(TESTING_DATA_PATH)) */
45
46
  /* concatenate the strings together */
47
  pathLen = strlen(TESTING_DATA_PATH);
48
14
  baseLen = strlen(base);
49
  /* Allocate enough for the two parts of the string, plus one for the /
50
   * and one for the null terminator */
51
7
  result = AIR_CALLOC(pathLen + baseLen + 2, char);
52
7
  if (result) {
53
    /*
54
      strcat(result, TESTING_DATA_PATH);
55
      strcat(result, "/");
56
      strcat(result, base);
57
    */
58
7
    airStrcpy(result, pathLen + 1, TESTING_DATA_PATH);
59
7
    result[pathLen] = '/';
60
7
    airStrcpy(result+pathLen+1, baseLen + 1, base);
61
7
  }
62
7
  return result;
63
}