MCPcopy Create free account
hub / github.com/arun11299/cpp-subprocess / WindowsEnvironmentVectorFromMap

Function WindowsEnvironmentVectorFromMap

cpp-subprocess/subprocess.hpp:490–510  ·  view source on GitHub ↗

env_vector_t WindowsEnvironmentVectorFromMap(const env_map_t &source_map) Creates a vector buffer for the new environment string table Copies in the mapped variables Returns the vector

Source from the content-addressed store, hash-verified

488 // * Copies in the mapped variables
489 // * Returns the vector
490 inline env_vector_t WindowsEnvironmentVectorFromMap(const env_map_t &source_map)
491 {
492 // Make a new environment map buffer.
493 env_vector_t environment_map_buffer;
494 // Give it some space.
495 environment_map_buffer.reserve(4096);
496
497 // And fill'er up.
498 for(auto kv: source_map){
499 // Create the line
500 platform_str_t current_line(kv.first); current_line += L"="; current_line += kv.second;
501 // Add the line to the buffer.
502 std::copy(current_line.begin(), current_line.end(), std::back_inserter(environment_map_buffer));
503 // Append a null
504 environment_map_buffer.push_back(0);
505 }
506 // Append one last null because of how Windows does it's environment maps.
507 environment_map_buffer.push_back(0);
508
509 return environment_map_buffer;
510 }
511
512 // env_vector_t CreateUpdatedWindowsEnvironmentVector(const env_map_t &changes_map)
513 // * Merges host environment with new mapped variables

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected