Mercurial > projects > dwt-linux
comparison dwt/dwthelper/System.d @ 350:373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Sun, 02 Nov 2008 01:30:09 -0800 |
parents | a4b331f75790 |
children | 59b54fea05d0 |
comparison
equal
deleted
inserted
replaced
349:676785ef6d24 | 350:373b48b9eaf0 |
---|---|
8 import tango.sys.Environment; | 8 import tango.sys.Environment; |
9 import tango.core.Exception; | 9 import tango.core.Exception; |
10 import tango.io.model.IFile : FileConst; | 10 import tango.io.model.IFile : FileConst; |
11 import tango.time.Clock; | 11 import tango.time.Clock; |
12 import tango.stdc.stdlib : exit; | 12 import tango.stdc.stdlib : exit; |
13 import tango.stdc.locale; | |
14 import tango.stdc.string; | |
13 | 15 |
14 template SimpleType(T) { | 16 template SimpleType(T) { |
15 debug{ | 17 debug{ |
16 static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ | 18 static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ |
17 if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ | 19 if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ |
152 return res; | 154 return res; |
153 } | 155 } |
154 return defval; | 156 return defval; |
155 } | 157 } |
156 public static String getProperty( String key ){ | 158 public static String getProperty( String key ){ |
159 /* get values for global system keys (environment) */ | |
160 switch( key ) { | |
161 case "os.name": return Environment.get("OSTYPE"); | |
162 case "user.name": return Environment.get("USER"); | |
163 case "user.home": return Environment.get("HOME"); | |
164 case "user.dir" : return Environment.get("PWD"); | |
165 case "file.separator" : return FileConst.PathSeparatorString ; | |
166 case "file.encoding" : | |
167 char* encoding; | |
168 encoding = setlocale(LC_CTYPE, null); | |
169 if (encoding is null) | |
170 return "CP1252"; //default | |
171 else | |
172 return encoding[0..strlen(encoding)].dup; | |
173 default: return null; | |
174 } | |
175 | |
157 /* Get values for local dwt specific keys */ | 176 /* Get values for local dwt specific keys */ |
158 String* p; | 177 String* p; |
159 if (key[0..3] == "dwt") { | 178 return ((p = key in localProperties) != null) ? *p : null; |
160 return ((p = key in localProperties) != null) ? *p : null; | |
161 /* else get values for global system keys (environment) */ | |
162 } else { | |
163 switch( key ){ | |
164 case "os.name": return Environment.get("OSTYPE"); | |
165 case "user.name": return Environment.get("USER"); | |
166 case "user.home": return Environment.get("HOME"); | |
167 case "user.dir" : return Environment.get("PWD"); | |
168 case "file.separator" : return FileConst.PathSeparatorString ; | |
169 case "file.encoding" : implMissing( __FILE__, __LINE__); | |
170 case "network.proxy_host" : implMissing( __FILE__, __LINE__); | |
171 case "network.proxy_port" : implMissing( __FILE__, __LINE__); | |
172 | |
173 default: return null; | |
174 } | |
175 } | |
176 } | 179 } |
177 | 180 |
178 public static void setProperty ( String key, String value ) { | 181 public static void setProperty ( String key, String value ) { |
179 /* set property for local dwt keys */ | 182 /* set property for LOCAL dwt keys */ |
180 if (key[0..3] == "dwt") { | 183 if (key !is null && value !is null) |
181 if (key !is null && value !is null) | 184 localProperties[ key ] = value; |
182 localProperties[ key ] = value; | |
183 /* else set properties for global system keys (environment) */ | |
184 } else { | |
185 | |
186 } | |
187 | |
188 } | 185 } |
189 | 186 |
190 static class Output { | 187 static class Output { |
191 public void println( String str ){ | 188 public void println( String str ){ |
192 implMissing( __FILE__, __LINE__ ); | 189 implMissing( __FILE__, __LINE__ ); |