comparison dwt/internal/Library.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents 3afcd4ddcf90
children 36f5cb12e1a2
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwt.internal.Library; 13 module dwt.internal.Library;
14 14
15 import tango.util.Convert; 15 import tango.util.Convert;
16 import dwt.dwthelper.utils;
16 17
17 // do it here, so it can be evaluated at compile time 18 // do it here, so it can be evaluated at compile time
18 // this saves a static ctor. 19 // this saves a static ctor.
19 private int buildSWT_VERSION (int major, int minor) { 20 private int buildSWT_VERSION (int major, int minor) {
20 return major * 1000 + minor; 21 return major * 1000 + minor;
45 */ 46 */
46 //public static const int JAVA_VERSION; 47 //public static const int JAVA_VERSION;
47 public static const int SWT_VERSION = .buildSWT_VERSION(MAJOR_VERSION, MINOR_VERSION); 48 public static const int SWT_VERSION = .buildSWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
48 49
49 version( Windows ){ 50 version( Windows ){
50 static const char[] SEPARATOR = "\r\n"; 51 static const String SEPARATOR = "\r\n";
51 } 52 }
52 else { 53 else {
53 static assert( false, "only windows supported for this port" ); 54 static assert( false, "only windows supported for this port" );
54 } 55 }
55 56
56 57
57 static int parseVersion(char[] aVersion) { 58 static int parseVersion(String aVersion) {
58 if (aVersion == null) return 0; 59 if (aVersion == null) return 0;
59 int major = 0, minor = 0, micro = 0; 60 int major = 0, minor = 0, micro = 0;
60 int length = aVersion.length, index = 0, start = 0; 61 int length = aVersion.length, index = 0, start = 0;
61 bool isDigit( char c ){ 62 bool isDigit( char c ){
62 return c >= '0' && c <= '9'; 63 return c >= '0' && c <= '9';
99 */ 100 */
100 public static int buildSWT_VERSION (int major, int minor) { 101 public static int buildSWT_VERSION (int major, int minor) {
101 return .buildSWT_VERSION(major, minor); 102 return .buildSWT_VERSION(major, minor);
102 } 103 }
103 /+ PORTING_LEFT 104 /+ PORTING_LEFT
104 static bool extract (char[] fileName, char[] mappedName) { 105 static bool extract (String fileName, String mappedName) {
105 FileOutputStream os = null; 106 FileOutputStream os = null;
106 InputStream is = null; 107 InputStream is = null;
107 File file = new File(fileName); 108 File file = new File(fileName);
108 try { 109 try {
109 if (!file.exists ()) { 110 if (!file.exists ()) {
135 } 136 }
136 if (file.exists ()) file.delete (); 137 if (file.exists ()) file.delete ();
137 return false; 138 return false;
138 } 139 }
139 140
140 static bool load (char[] libName) { 141 static bool load (String libName) {
141 try { 142 try {
142 if (libName.indexOf (SEPARATOR) != -1) { 143 if (libName.indexOf (SEPARATOR) != -1) {
143 System.load (libName); 144 System.load (libName);
144 } else { 145 } else {
145 System.loadLibrary (libName); 146 System.loadLibrary (libName);
158 * <code>name</code> is used in another attempt to load the library, 159 * <code>name</code> is used in another attempt to load the library,
159 * this time ignoring the DWT version encoding scheme. 160 * this time ignoring the DWT version encoding scheme.
160 * 161 *
161 * @param name the name of the library to load 162 * @param name the name of the library to load
162 */ 163 */
163 public static void loadLibrary (char[] name) { 164 public static void loadLibrary (String name) {
164 loadLibrary (name, true); 165 loadLibrary (name, true);
165 } 166 }
166 167
167 /** 168 /**
168 * Loads the shared library that matches the version of the 169 * Loads the shared library that matches the version of the
174 * this time ignoring the DWT version encoding scheme. 175 * this time ignoring the DWT version encoding scheme.
175 * 176 *
176 * @param name the name of the library to load 177 * @param name the name of the library to load
177 * @param mapName true if the name should be mapped, false otherwise 178 * @param mapName true if the name should be mapped, false otherwise
178 */ 179 */
179 public static void loadLibrary (char[] name, boolean mapName) { 180 public static void loadLibrary (String name, boolean mapName) {
180 181
181 /* Compute the library name and mapped name */ 182 /* Compute the library name and mapped name */
182 String libName1, libName2, mappedName1, mappedName2; 183 String libName1, libName2, mappedName1, mappedName2;
183 if (mapName) { 184 if (mapName) {
184 String version = System.getProperty ("swt.version"); //$NON-NLS-1$ 185 String version = System.getProperty ("swt.version"); //$NON-NLS-1$