comparison dwtx/jface/preference/DirectoryFieldEditor.d @ 97:0168c579a3f9

Fix path handling, thanks yidabu for reporting.
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Aug 2008 07:06:52 +0200
parents 3ed358ab21c9
children
comparison
equal deleted inserted replaced
96:b492ba44e44d 97:0168c579a3f9
20 import dwt.widgets.DirectoryDialog; 20 import dwt.widgets.DirectoryDialog;
21 import dwtx.jface.resource.JFaceResources; 21 import dwtx.jface.resource.JFaceResources;
22 22
23 import dwt.dwthelper.utils; 23 import dwt.dwthelper.utils;
24 import tango.io.FilePath; 24 import tango.io.FilePath;
25 static import tango.io.Path;
25 import tango.io.FileSystem; 26 import tango.io.FileSystem;
26 27
27 /** 28 /**
28 * A field editor for a directory path type preference. A standard directory 29 * A field editor for a directory path type preference. A standard directory
29 * dialog appears when the user presses the change button. 30 * dialog appears when the user presses the change button.
54 /* (non-Javadoc) 55 /* (non-Javadoc)
55 * Method declared on StringButtonFieldEditor. 56 * Method declared on StringButtonFieldEditor.
56 * Opens the directory chooser dialog and returns the selected directory. 57 * Opens the directory chooser dialog and returns the selected directory.
57 */ 58 */
58 protected override String changePressed() { 59 protected override String changePressed() {
59 auto f = new FilePath(getTextControl().getText()); 60 auto f = new FilePath(tango.io.Path.standard(getTextControl().getText()));
60 if (!f.exists()) { 61 if (!f.exists()) {
61 f = cast(FilePath)null; 62 f = cast(FilePath)null;
62 } 63 }
63 auto d = getDirectory(f); 64 auto d = getDirectory(f);
64 if (d is null) { 65 if (d is null) {
76 String fileName = getTextControl().getText(); 77 String fileName = getTextControl().getText();
77 fileName = fileName.trim(); 78 fileName = fileName.trim();
78 if (fileName.length is 0 && isEmptyStringAllowed()) { 79 if (fileName.length is 0 && isEmptyStringAllowed()) {
79 return true; 80 return true;
80 } 81 }
81 auto file = new FilePath(fileName); 82 auto file = new FilePath(tango.io.Path.standard(fileName));
82 return file.exists() && file.isFolder(); 83 return file.exists() && file.isFolder();
83 } 84 }
84 85
85 /** 86 /**
86 * Helper that opens the directory chooser dialog. 87 * Helper that opens the directory chooser dialog.
96 } 97 }
97 String dir = fileDialog.open(); 98 String dir = fileDialog.open();
98 if (dir !is null) { 99 if (dir !is null) {
99 dir = dir.trim(); 100 dir = dir.trim();
100 if (dir.length > 0) { 101 if (dir.length > 0) {
101 return new FilePath(dir); 102 return new FilePath(tango.io.Path.standard(dir));
102 } 103 }
103 } 104 }
104 105
105 return null; 106 return null;
106 } 107 }