Boost.Nowide
system.hpp
1 //
2 // Copyright (c) 2012 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_NOWIDE_CSTDLIB_HPP
9 #define BOOST_NOWIDE_CSTDLIB_HPP
10 
11 #include <stdlib.h>
12 #include <errno.h>
13 #include <boost/nowide/stackstring.hpp>
14 namespace boost {
15 namespace nowide {
16 
17 #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
18 
19 using ::system;
20 
21 #else // Windows
22 
28 inline int system(char const *cmd)
29 {
30  if(!cmd)
31  return _wsystem(0);
32  wstackstring wcmd;
33  if(!wcmd.convert(cmd)) {
34  errno = EINVAL;
35  return -1;
36  }
37  return _wsystem(wcmd.c_str());
38 }
39 
40 #endif
41 } // nowide
42 } // namespace boost
43 
44 #endif
45 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
Definition: args.hpp:18
int system(char const *cmd)
Definition: system.hpp:28
A class that allows to create a temporary wide or narrow UTF strings from wide or narrow UTF source...
Definition: stackstring.hpp:25