Lines 46-51
Link Here
|
46 |
import java.io.File; |
46 |
import java.io.File; |
47 |
import java.io.IOException; |
47 |
import java.io.IOException; |
48 |
import java.io.OutputStream; |
48 |
import java.io.OutputStream; |
|
|
49 |
import java.util.Arrays; |
50 |
import java.util.List; |
49 |
import java.util.logging.Handler; |
51 |
import java.util.logging.Handler; |
50 |
import java.util.logging.Level; |
52 |
import java.util.logging.Level; |
51 |
import java.util.logging.LogRecord; |
53 |
import java.util.logging.LogRecord; |
Lines 57-62
Link Here
|
57 |
import org.openide.filesystems.FileObject; |
59 |
import org.openide.filesystems.FileObject; |
58 |
import org.openide.filesystems.FileUtil; |
60 |
import org.openide.filesystems.FileUtil; |
59 |
import org.openide.util.Exceptions; |
61 |
import org.openide.util.Exceptions; |
|
|
62 |
import org.openide.util.Utilities; |
60 |
|
63 |
|
61 |
/** |
64 |
/** |
62 |
* |
65 |
* |
Lines 174-177
Link Here
|
174 |
f.setWritable(true); |
177 |
f.setWritable(true); |
175 |
} |
178 |
} |
176 |
} |
179 |
} |
|
|
180 |
|
181 |
public void testFileObjectForBrokenLinkWithGetChildren () throws Exception { |
182 |
if (!Utilities.isUnix()) { |
183 |
return; |
184 |
} |
185 |
doFileObjectForBrokenLink(true); |
186 |
} |
187 |
// public void testFileObjectForBrokenLink() throws Exception { |
188 |
// if (!Utilities.isUnix()) { |
189 |
// return; |
190 |
// } |
191 |
// doFileObjectForBrokenLink(false); |
192 |
// } |
193 |
|
194 |
private void doFileObjectForBrokenLink (boolean listFirst) throws Exception { |
195 |
clearWorkDir(); |
196 |
File wd = new File(getWorkDir(), "wd"); |
197 |
wd.mkdirs(); |
198 |
|
199 |
File original = new File(wd, "original"); |
200 |
// original.createNewFile(); |
201 |
for (int i = 0; i < 2; ++i) { |
202 |
File lockFile = new File(wd, "wlock"); |
203 |
lockFile.delete(); |
204 |
FileUtil.toFileObject(wd).refresh(); |
205 |
ProcessBuilder pb = new ProcessBuilder().directory(wd).command( |
206 |
new String[]{"ln", "-s", original.getName(), lockFile.getName()}); |
207 |
pb.start().waitFor(); |
208 |
final List<String> names = Arrays.asList(lockFile.getParentFile().list()); |
209 |
assertEquals("One file", 1, names.size()); |
210 |
// file exists, or at least dir.listFiles lists the file |
211 |
assertTrue(names.contains(lockFile.getName())); |
212 |
// java.io.File.exists returns false |
213 |
assertFalse(lockFile.exists()); |
214 |
if (listFirst) { |
215 |
FileObject root = FileUtil.toFileObject(wd); |
216 |
List<FileObject> arr = Arrays.asList(root.getChildren()); |
217 |
assertEquals("One files: " + arr, 1, arr.size()); |
218 |
assertEquals("Has the right name", lockFile.getName(), arr.get(0).getName()); |
219 |
} |
220 |
|
221 |
// and no FileObject is reated for such a file |
222 |
assertNotNull(FileUtil.toFileObject(lockFile)); |
223 |
} |
224 |
} |
177 |
} |
225 |
} |