Mercurial > projects > dwt2
comparison base/src/java/io/File.d @ 120:536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
===D2===
* added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements
used these templates to work with strict type storage rules of dmd-2.053
* com.ibm.icu now also compilable with D2, but not tested yet
* small fixes
Snippet288 - shared data is in TLS
===Phobos===
* fixed critical bugs in Phobos implemention
completely incorrect segfault prone fromStringz (Linux's port ruthless killer)
terrible, incorrect StringBuffer realization (StyledText killer)
* fixed small bugs as well
Snippet72 - misprint in the snippet
* implemented missed functionality for Phobos
ByteArrayOutputStream implemented (image loading available)
formatting correctly works for all DWT's cases
As a result, folowing snippets now works with Phobos (Snippet### - what is fixed):
Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting
Snippet48, 282 - crash on image loading
Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText
Snippet244 - hang-up
===Tango===
* few changes for the latest Tango trunc-r5661
* few small performance improvments
===General===
* implMissing-s for only one version changed to implMissingInTango/InPhobos
* incorrect calls to Format in toString-s fixed
* fixed loading \uXXXX characters in ResourceBundle
* added good UTF-8 support for StyledText, TextLayout (Win32) and friends
UTF functions revised and tested. It is now in java.nonstandard.*Utf modules
StyledText and TextLayout (Win32) modules revised for UTF-8 support
* removed small diferences in most identical files in *.swt.* folders
*.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32
now 179 of 576 (~31%) files in *.swt.* folders are fully identical
* Win32: snippets now have right subsystem, pretty icons and native system style controls
* small fixes in snippets
Snippet44 - it's not Snippet44
Snippet212 - functions work with different images and offsets arrays
Win32: Snippet282 - crash on close if the button has an image
Snippet293 - setGrayed is commented
and others
Win32: As a result, folowing snippets now works
Snippet68 - color doesn't change
Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above)
Snippet193 - no tabel headers
author | Denis Shelomovskij <verylonglogin.reg@gmail.com> |
---|---|
date | Sat, 09 Jul 2011 15:50:20 +0300 |
parents | e944a4cf537b |
children |
comparison
equal
deleted
inserted
replaced
119:d00e8db0a568 | 120:536e43f63c81 |
---|---|
9 static import tango.io.model.IFile; | 9 static import tango.io.model.IFile; |
10 static import tango.io.FilePath; | 10 static import tango.io.FilePath; |
11 static import tango.io.Path; | 11 static import tango.io.Path; |
12 static import tango.io.FileSystem; | 12 static import tango.io.FileSystem; |
13 static import tango.sys.Environment; | 13 static import tango.sys.Environment; |
14 static import tango.sys.Common; | |
15 static import tango.stdc.stringz; //for toStringz | |
16 version(Posix) static import tango.stdc.posix.unistd; //for access | |
14 } else { // Phobos | 17 } else { // Phobos |
15 static import std.file; | 18 static import std.file; |
16 static import std.path; | 19 static import std.path; |
20 static import std.string; //for toStringz | |
21 version(Posix) static import core.sys.posix.unistd; //for access | |
17 } | 22 } |
18 // Implement this more efficient by using FilePath in Tango | 23 // Implement this more efficient by using FilePath in Tango |
19 public class File { | 24 public class File { |
20 | 25 |
21 public static char separatorChar; | 26 public static char separatorChar; |
30 separator = tango.io.model.IFile.FileConst.PathSeparatorString; | 35 separator = tango.io.model.IFile.FileConst.PathSeparatorString; |
31 separatorChar = tango.io.model.IFile.FileConst.PathSeparatorChar; | 36 separatorChar = tango.io.model.IFile.FileConst.PathSeparatorChar; |
32 pathSeparator = tango.io.model.IFile.FileConst.SystemPathString; | 37 pathSeparator = tango.io.model.IFile.FileConst.SystemPathString; |
33 pathSeparatorChar = tango.io.model.IFile.FileConst.SystemPathChar; | 38 pathSeparatorChar = tango.io.model.IFile.FileConst.SystemPathChar; |
34 } else { // Phobos | 39 } else { // Phobos |
35 version(Windows){ | 40 separator = std.path.sep; |
36 separator = "\\"; | 41 separatorChar = std.path.sep[0]; |
37 separatorChar = '\\'; | 42 pathSeparator = std.path.pathsep; |
38 pathSeparator = ";"; | 43 pathSeparatorChar = std.path.pathsep[0]; |
39 pathSeparatorChar = ';'; | 44 } |
45 } | |
46 | |
47 private static String toStd( String path ){ | |
48 version(Tango){ | |
49 return tango.io.Path.standard( path.dup ); | |
50 } else { // Phobos | |
51 return path; | |
52 } | |
53 } | |
54 private static String join( String path, String file ){ | |
55 version(Tango){ | |
56 return tango.io.Path.join( toStd(path), toStd(file) ); | |
57 } else { // Phobos | |
58 return std.path.join( toStd(path), toStd(file) ); | |
59 } | |
60 } | |
61 | |
62 public this ( String pathname ){ | |
63 mFilePath = toStd( pathname ); | |
64 } | |
65 | |
66 public this ( String parent, String child ){ | |
67 mFilePath = join( parent, child ); | |
68 } | |
69 | |
70 public this ( java.io.File.File parent, String child ){ | |
71 version(Tango){ | |
72 mFilePath = tango.io.Path.join( parent.mFilePath, toStd(child) ); | |
73 } else { // Phobos | |
74 mFilePath = std.path.join( parent.mFilePath, toStd(child) ); | |
75 } | |
76 } | |
77 | |
78 public int getPrefixLength(){ | |
79 implMissing( __FILE__, __LINE__ ); | |
80 return 0; | |
81 } | |
82 | |
83 public String getName(){ | |
84 implMissing( __FILE__, __LINE__ ); | |
85 return null; | |
86 } | |
87 | |
88 public String getParent(){ | |
89 implMissing( __FILE__, __LINE__ ); | |
90 return null; | |
91 } | |
92 | |
93 public java.io.File.File getParentFile(){ | |
94 implMissing( __FILE__, __LINE__ ); | |
95 return null; | |
96 } | |
97 | |
98 public String getPath(){ | |
99 implMissing( __FILE__, __LINE__ ); | |
100 return null; | |
101 } | |
102 | |
103 public bool isAbsolute(){ | |
104 implMissing( __FILE__, __LINE__ ); | |
105 return false; | |
106 } | |
107 | |
108 public String getAbsolutePath(){ | |
109 version(Tango){ | |
110 return (new tango.io.FilePath.FilePath(mFilePath)).absolute(tango.sys.Environment.Environment.cwd).toString; | |
111 } else { // Phobos | |
112 return std.path.rel2abs(mFilePath); | |
113 } | |
114 } | |
115 | |
116 public java.io.File.File getAbsoluteFile(){ | |
117 return new File( getAbsolutePath() ); | |
118 } | |
119 | |
120 public String getCanonicalPath(){ | |
121 implMissing( __FILE__, __LINE__ ); | |
122 return null; | |
123 } | |
124 | |
125 public java.io.File.File getCanonicalFile(){ | |
126 implMissing( __FILE__, __LINE__ ); | |
127 return null; | |
128 } | |
129 | |
130 public bool canRead(){ | |
131 implMissing( __FILE__, __LINE__ ); | |
132 return false; | |
133 } | |
134 | |
135 public bool canWrite(){ | |
136 version(Windows) { //Windows's ACL isn't supported | |
137 version(Tango) { | |
138 return tango.io.Path.isWritable(mFilePath); | |
139 } else { // Phobos | |
140 return !(std.file.getAttributes(mFilePath) & 1); //FILE_ATTRIBUTE_READONLY = 1 | |
40 } | 141 } |
41 else{ | 142 } else version(Posix) { //workaround Tango's bug (isWritable is always true) |
42 separator = "/"; | 143 version(Tango) { |
43 separatorChar = '/'; | 144 return tango.stdc.posix.unistd.access (tango.stdc.stringz.toStringz(mFilePath), 2) is 0; //W_OK = 2 |
44 pathSeparator = ":"; | 145 } else { // Phobos |
45 pathSeparatorChar = ':'; | 146 return core.sys.posix.unistd.access (std.string.toStringz(mFilePath), 2) is 0; //W_OK = 2 |
46 } | 147 } |
47 } | 148 } else |
48 } | 149 static assert(0); |
49 | 150 } |
50 private static String toStd( CString path ){ | 151 |
51 version(Tango){ | 152 public bool exists(){ |
52 return tango.io.Path.standard( path._idup() ); | 153 version(Tango){ |
53 } else { // Phobos | 154 return tango.io.Path.exists(mFilePath); |
54 return path._idup(); | 155 } else { // Phobos |
55 } | 156 return std.file.exists(mFilePath); |
56 } | 157 } |
57 private static String join( CString path, CString file ){ | 158 } |
58 version(Tango){ | 159 |
59 return tango.io.Path.join( path._idup(), file._idup() ); | 160 public bool isDirectory(){ |
60 } else { // Phobos | 161 version(Tango){ |
61 return std.path.join( path._idup(), file._idup() ); | 162 return tango.io.Path.isFolder(mFilePath); |
62 } | 163 } else { // Phobos |
63 } | 164 return std.file.isDir(mFilePath); |
64 | 165 } |
65 public this ( CString pathname ){ | 166 } |
66 mFilePath = toStd( pathname ); | 167 |
67 } | 168 public bool isFile(){ |
68 | 169 implMissing( __FILE__, __LINE__ ); |
69 public this ( CString parent, CString child ){ | 170 return false; |
70 mFilePath = join( toStd(parent), toStd(child) ); | 171 } |
71 } | 172 |
72 | 173 public bool isHidden(){ |
73 public this ( java.io.File.File parent, CString child ){ | 174 implMissing( __FILE__, __LINE__ ); |
74 mFilePath = join( parent.mFilePath, toStd(child) ); | 175 return false; |
75 } | 176 } |
76 | 177 |
77 public int getPrefixLength(){ | 178 public long lastModified(){ |
179 implMissing( __FILE__, __LINE__ ); | |
180 return 0L; | |
181 } | |
182 | |
183 public long length(){ | |
184 implMissing( __FILE__, __LINE__ ); | |
185 return 0L; | |
186 } | |
187 | |
188 public bool createNewFile(){ | |
189 implMissing( __FILE__, __LINE__ ); | |
190 return false; | |
191 } | |
192 | |
193 public bool delete_KEYWORDESCAPE(){ | |
194 implMissing( __FILE__, __LINE__ ); | |
195 return false; | |
196 } | |
197 | |
198 public void deleteOnExit(){ | |
199 implMissing( __FILE__, __LINE__ ); | |
200 } | |
201 | |
202 public String[] list(){ | |
203 implMissing( __FILE__, __LINE__ ); | |
204 return null; | |
205 } | |
206 | |
207 public java.io.File.File[] listFiles(){ | |
208 implMissing( __FILE__, __LINE__ ); | |
209 return null; | |
210 } | |
211 | |
212 public bool mkdir(){ | |
213 implMissing( __FILE__, __LINE__ ); | |
214 return false; | |
215 } | |
216 | |
217 public bool mkdirs(){ | |
218 implMissing( __FILE__, __LINE__ ); | |
219 return false; | |
220 } | |
221 | |
222 public bool renameTo( java.io.File.File dest ){ | |
223 implMissing( __FILE__, __LINE__ ); | |
224 return false; | |
225 } | |
226 | |
227 public bool setLastModified( long time ){ | |
228 implMissing( __FILE__, __LINE__ ); | |
229 return false; | |
230 } | |
231 | |
232 public bool setReadOnly(){ | |
233 implMissing( __FILE__, __LINE__ ); | |
234 return false; | |
235 } | |
236 | |
237 public static java.io.File.File[] listRoots(){ | |
238 implMissing( __FILE__, __LINE__ ); | |
239 return null; | |
240 } | |
241 | |
242 public static java.io.File.File createTempFile( String prefix, String suffix, java.io.File.File directory ){ | |
243 implMissing( __FILE__, __LINE__ ); | |
244 return null; | |
245 } | |
246 | |
247 public static java.io.File.File createTempFile( String prefix, String suffix ){ | |
248 implMissing( __FILE__, __LINE__ ); | |
249 return null; | |
250 } | |
251 | |
252 public int compareTo( java.io.File.File pathname ){ | |
78 implMissing( __FILE__, __LINE__ ); | 253 implMissing( __FILE__, __LINE__ ); |
79 return 0; | 254 return 0; |
80 } | 255 } |
81 | 256 |
82 public String getName(){ | |
83 implMissing( __FILE__, __LINE__ ); | |
84 return null; | |
85 } | |
86 | |
87 public String getParent(){ | |
88 implMissing( __FILE__, __LINE__ ); | |
89 return null; | |
90 } | |
91 | |
92 public java.io.File.File getParentFile(){ | |
93 implMissing( __FILE__, __LINE__ ); | |
94 return null; | |
95 } | |
96 | |
97 public String getPath(){ | |
98 implMissing( __FILE__, __LINE__ ); | |
99 return null; | |
100 } | |
101 | |
102 public bool isAbsolute(){ | |
103 implMissing( __FILE__, __LINE__ ); | |
104 return false; | |
105 } | |
106 | |
107 public String getAbsolutePath(){ | |
108 version(Tango){ | |
109 return (new tango.io.FilePath.FilePath(mFilePath)).absolute(tango.sys.Environment.Environment.cwd).toString; | |
110 } else { // Phobos | |
111 implMissing( __FILE__, __LINE__ ); | |
112 return ""; | |
113 } | |
114 } | |
115 | |
116 public java.io.File.File getAbsoluteFile(){ | |
117 version(Tango){ | |
118 return new File( getAbsolutePath() ); | |
119 } else { // Phobos | |
120 implMissing( __FILE__, __LINE__ ); | |
121 return null; | |
122 } | |
123 } | |
124 | |
125 public String getCanonicalPath(){ | |
126 implMissing( __FILE__, __LINE__ ); | |
127 return null; | |
128 } | |
129 | |
130 public java.io.File.File getCanonicalFile(){ | |
131 implMissing( __FILE__, __LINE__ ); | |
132 return null; | |
133 } | |
134 | |
135 public bool canRead(){ | |
136 implMissing( __FILE__, __LINE__ ); | |
137 return false; | |
138 } | |
139 | |
140 public bool canWrite(){ | |
141 version(Tango){ | |
142 return tango.io.Path.isWritable(mFilePath); | |
143 } else { // Phobos | |
144 implMissing( __FILE__, __LINE__ ); | |
145 return false; | |
146 } | |
147 } | |
148 | |
149 public bool exists(){ | |
150 version(Tango){ | |
151 return tango.io.Path.exists(mFilePath); | |
152 } else { // Phobos | |
153 implMissing( __FILE__, __LINE__ ); | |
154 return false; | |
155 } | |
156 } | |
157 | |
158 public bool isDirectory(){ | |
159 version(Tango){ | |
160 return tango.io.Path.isFolder(mFilePath); | |
161 } else { // Phobos | |
162 implMissing( __FILE__, __LINE__ ); | |
163 return false; | |
164 } | |
165 } | |
166 | |
167 public bool isFile(){ | |
168 implMissing( __FILE__, __LINE__ ); | |
169 return false; | |
170 } | |
171 | |
172 public bool isHidden(){ | |
173 implMissing( __FILE__, __LINE__ ); | |
174 return false; | |
175 } | |
176 | |
177 public long lastModified(){ | |
178 implMissing( __FILE__, __LINE__ ); | |
179 return 0L; | |
180 } | |
181 | |
182 public long length(){ | |
183 implMissing( __FILE__, __LINE__ ); | |
184 return 0L; | |
185 } | |
186 | |
187 public bool createNewFile(){ | |
188 implMissing( __FILE__, __LINE__ ); | |
189 return false; | |
190 } | |
191 | |
192 public bool delete_KEYWORDESCAPE(){ | |
193 implMissing( __FILE__, __LINE__ ); | |
194 return false; | |
195 } | |
196 | |
197 public void deleteOnExit(){ | |
198 implMissing( __FILE__, __LINE__ ); | |
199 } | |
200 | |
201 public String[] list(){ | |
202 implMissing( __FILE__, __LINE__ ); | |
203 return null; | |
204 } | |
205 | |
206 public java.io.File.File[] listFiles(){ | |
207 implMissing( __FILE__, __LINE__ ); | |
208 return null; | |
209 } | |
210 | |
211 public bool mkdir(){ | |
212 implMissing( __FILE__, __LINE__ ); | |
213 return false; | |
214 } | |
215 | |
216 public bool mkdirs(){ | |
217 implMissing( __FILE__, __LINE__ ); | |
218 return false; | |
219 } | |
220 | |
221 public bool renameTo( java.io.File.File dest ){ | |
222 implMissing( __FILE__, __LINE__ ); | |
223 return false; | |
224 } | |
225 | |
226 public bool setLastModified( long time ){ | |
227 implMissing( __FILE__, __LINE__ ); | |
228 return false; | |
229 } | |
230 | |
231 public bool setReadOnly(){ | |
232 implMissing( __FILE__, __LINE__ ); | |
233 return false; | |
234 } | |
235 | |
236 public static java.io.File.File[] listRoots(){ | |
237 implMissing( __FILE__, __LINE__ ); | |
238 return null; | |
239 } | |
240 | |
241 public static java.io.File.File createTempFile( CString prefix, CString suffix, java.io.File.File directory ){ | |
242 implMissing( __FILE__, __LINE__ ); | |
243 return null; | |
244 } | |
245 | |
246 public static java.io.File.File createTempFile( CString prefix, CString suffix ){ | |
247 implMissing( __FILE__, __LINE__ ); | |
248 return null; | |
249 } | |
250 | |
251 public int compareTo( java.io.File.File pathname ){ | |
252 implMissing( __FILE__, __LINE__ ); | |
253 return 0; | |
254 } | |
255 | |
256 public String toString(){ | 257 public String toString(){ |
257 implMissing( __FILE__, __LINE__ ); | 258 implMissing( __FILE__, __LINE__ ); |
258 return null; | 259 return null; |
259 } | 260 } |
260 | 261 |