diff 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
line wrap: on
line diff
--- a/dwt/dwthelper/System.d	Fri Oct 31 23:35:10 2008 -0700
+++ b/dwt/dwthelper/System.d	Sun Nov 02 01:30:09 2008 -0800
@@ -10,6 +10,8 @@
 import tango.io.model.IFile : FileConst;
 import tango.time.Clock;
 import tango.stdc.stdlib : exit;
+import tango.stdc.locale;
+import tango.stdc.string;
 
 template SimpleType(T) {
     debug{
@@ -154,37 +156,32 @@
         return defval;
     }
     public static String getProperty( String key ){
+        /* get values for global system keys (environment) */
+        switch( key ) {
+            case "os.name": return Environment.get("OSTYPE");
+            case "user.name": return Environment.get("USER");
+            case "user.home": return Environment.get("HOME");
+            case "user.dir" : return Environment.get("PWD");
+            case "file.separator" : return FileConst.PathSeparatorString ;
+            case "file.encoding" :
+                char* encoding;
+                encoding = setlocale(LC_CTYPE, null);
+                if (encoding is null) 
+                    return "CP1252"; //default
+                else 
+                    return encoding[0..strlen(encoding)].dup;
+            default: return null;
+        }
+
         /* Get values for local dwt specific keys */
         String* p;
-        if (key[0..3] == "dwt") {
-            return ((p = key in localProperties) != null) ? *p : null;
-        /* else get values for global system keys (environment) */
-        } else {
-            switch( key ){
-                case "os.name": return Environment.get("OSTYPE");
-                case "user.name": return Environment.get("USER");
-                case "user.home": return Environment.get("HOME");
-                case "user.dir" : return Environment.get("PWD");
-                case "file.separator" : return FileConst.PathSeparatorString ;
-                case "file.encoding" : implMissing( __FILE__, __LINE__);
-                case "network.proxy_host" : implMissing( __FILE__, __LINE__);
-                case "network.proxy_port" : implMissing( __FILE__, __LINE__);
-                
-                default: return null;
-            }
-        }
+        return ((p = key in localProperties) != null) ? *p : null;
     }
 
     public static void setProperty ( String key, String value ) {
-        /* set property for local dwt keys */
-        if (key[0..3] == "dwt") {
-            if (key !is null && value !is null)
-                localProperties[ key ] = value;
-        /* else set properties for global system keys (environment) */
-        } else {
-
-        }
-
+        /* set property for LOCAL dwt keys */
+        if (key !is null && value !is null)
+            localProperties[ key ] = value;
     }
 
     static class Output {