3 minibuffer.prototype.read_file_path = function () {
4 keywords(arguments, $prompt = "File:", $initial_value = default_directory.path,
6 var result = yield this.read(
7 $prompt = arguments.$prompt,
8 $initial_value = arguments.$initial_value,
9 $history = arguments.$history,
10 $completer = file_path_completer(),
11 $auto_complete = true);
12 yield co_return(result);
15 minibuffer.prototype.read_file = function () {
16 var result = yield this.read_file_path(forward_keywords(arguments));
17 yield co_return(get_file(result));
21 minibuffer.prototype.read_existing_file = minibuffer.prototype.read_file;
24 minibuffer.prototype.read_file_check_overwrite = function () {
26 var initial_value = arguments.$initial_value;
28 var path = yield this.read_file_path(forward_keywords(arguments), $initial_value = initial_value);
30 var file = get_file(path);
33 var overwrite = yield this.read_yes_or_no($prompt = "Overwrite existing file " + path + "?");
39 yield co_return(file);
43 function file_path_completer() {
44 return function(input, pos, conservative) {
45 var f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
49 f.initWithPath(input);
50 if(f.exists() && f.isDirectory())
54 if(!dir.exists()) return null;
55 var iter = dir.directoryEntries;
56 while(iter.hasMoreElements()) {
57 var e = iter.getNext();
63 function id(x) { return x};
64 return prefix_completer($completions = ents,
66 $get_description = id,
67 $get_value = id)(input, pos, conservative);