37 std::unique_ptr<LPWSTR[], void (*)(
wchar_t**)> wargv = std::unique_ptr<LPWSTR[],
void (*)(
wchar_t**)>(CommandLineToArgvW(GetCommandLineW(), &
argc), [](
wchar_t** ptr) { LocalFree(ptr); });
45 m_args.reserve(
static_cast<std::size_t
>(
argc));
49#elif defined(__APPLE__)
50 std::size_t
argc{
static_cast<std::size_t
>(*_NSGetArgc())};
52 char**
argv{*_NSGetArgv()};
53 for(std::size_t i = 0; i !=
argc; ++i) {
m_args.push_back(
argv[i]); }
57 std::fstream file_stream;
58 const std::fstream::iostate old_iostate{file_stream.exceptions()};
61 file_stream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
62 file_stream.open(
"/proc/self/cmdline", std::fstream::in | std::fstream::binary);
63 file_stream.ignore(std::numeric_limits<std::streamsize>::max());
64 cmdline.resize(
static_cast<std::size_t
>(file_stream.gcount()));
65 file_stream.seekg(0, std::ios_base::beg);
66 file_stream.get(&cmdline[0],
static_cast<std::streamsize
>(cmdline.size()));
67 file_stream.exceptions(old_iostate);
68 if(file_stream.is_open()) { file_stream.close(); }
69 m_args.reserve(
static_cast<std::size_t
>(std::count(cmdline.begin(), cmdline.end(),
'\0')));
70 for(std::string::iterator it = cmdline.begin(); it != cmdline.end(); it = std::find(it, cmdline.end(),
'\0') + 1) {
m_args.emplace_back(cmdline.data() + (it - cmdline.begin())); }
75 file_stream.exceptions(old_iostate);
76 if(file_stream.is_open()) { file_stream.close(); }