• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pcb2gcode / pcb2gcode / 19811714133

24 Nov 2025 02:34PM UTC coverage: 59.007% (-15.0%) from 74.006%
19811714133

push

github

web-flow
Merge pull request #730 from mar0x/master

Enable windows build in CI

2199 of 4409 branches covered (49.88%)

Branch coverage included in aggregate %.

1902 of 2541 relevant lines covered (74.85%)

117318.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/common.cpp
1
/*
2
 * This file is part of pcb2gcode.
3
 * 
4
 * Copyright (C) 2015 Nicola Corna <nicola@corna.info>
5
 * 
6
 * pcb2gcode is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * 
11
 * pcb2gcode is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with pcb2gcode.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
#include "common.hpp"
21

22
#include <fstream>
23
#include <boost/algorithm/string.hpp>
24

25
#include <boost/format.hpp>
26
using boost::format;
27
using std::string;
28

29
#include <boost/system/api_config.hpp>  // for BOOST_POSIX_API or BOOST_WINDOWS_API
30

31
#include "units.hpp"
32

33
bool workSide( const boost::program_options::variables_map &options, string type )
×
34
{
35
    const string side = type + "-side";
×
36
    const string front = type + "-front";
×
37
    
38
    if( options.count(front) )
39
        return options[front].as<bool>();
×
40
    else
41
    {
42
        switch (options[side].as<BoardSide::BoardSide>()) {
×
43
            case BoardSide::FRONT:
44
                return true;
45
            case BoardSide::BACK:
46
                return false;
47
            case BoardSide::AUTO:
×
48
            default:
49
                if( options.count("front") || !options.count("back") )
×
50
                    return true;    // back+front, front only, <nothing>
51
                else
52
                    return false;   // back only
53
        }
54
    }
55
}
56

57
// Based on the explanation here:
58
// https://www.geeksforgeeks.org/python-os-path-join-method/
59
string build_filename(const string& a, const string& b) {
14✔
60
#ifdef BOOST_WINDOWS_API
61
  static constexpr auto seperator = '\\';
62
#endif
63

64
#ifdef BOOST_POSIX_API
65
  static constexpr auto seperator = '/';
66
#endif
67

68
  if (a.size() == 0 || b.front() == seperator) {
14✔
69
    return b;
4✔
70
  }
71
  if (b.size() == 0) {
10✔
72
    if (a.back() != seperator) {
3✔
73
      return a + seperator;
2✔
74
    } else {
75
      return a;
1✔
76
    }
77
  }
78
  if (a.back() != seperator) {
7✔
79
    return a + seperator + b;
2!
80
  } else {
81
    return a + b;
6✔
82
  }
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc