Skip to content

Commit

Permalink
Support Env set() without overwrite on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusnaslund committed Apr 1, 2016
1 parent 971ddd3 commit 45ccea8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sdk/os/Env.ooc
Expand Up @@ -25,8 +25,13 @@ Env: class {
set: static func (key, value: String, overwrite: Bool) -> Int {
if(key != null && value != null) {
version(windows) {
// todo: handle overwrite
return putenv( "%s=%s" format(key toCString(), value toCString()) toCString() )
exists := false
if (!overwrite) {
old := This get(key)
exists = (old != null)
}
if (overwrite || !exists)
return putenv( "%s=%s" format(key toCString(), value toCString()) toCString() )
}
version(!windows) {
return setenv(key toCString(), value toCString(), overwrite)
Expand Down

0 comments on commit 45ccea8

Please sign in to comment.