mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 23:49:00 +08:00
[paparazzi-center] Allow settings/modules/flightplans outside the conf directory
This commit is contained in:
committed by
Gautier Hattenberger
parent
a7bd583683
commit
07d789e413
@@ -59,14 +59,19 @@ let run_and_log = fun log exit_cb com ->
|
|||||||
let io_watch_out = Glib.Io.add_watch [`IN] cb channel_out in
|
let io_watch_out = Glib.Io.add_watch [`IN] cb channel_out in
|
||||||
pid, channel_out, com_stdout, io_watch_out
|
pid, channel_out, com_stdout, io_watch_out
|
||||||
|
|
||||||
let strip_prefix = fun dir file ->
|
let strip_prefix = fun dir file subdir ->
|
||||||
let n = String.length dir in
|
let n = String.length dir in
|
||||||
if not (String.length file > n && String.sub file 0 n = dir) then begin
|
if not (String.length file > n && String.sub file 0 n = dir) then begin
|
||||||
let msg = sprintf "Selected file '%s' should be in '%s'" file dir in
|
let home = Env.paparazzi_home in
|
||||||
GToolbox.message_box ~title:"Error" msg;
|
let nn = String.length home in
|
||||||
raise Exit
|
if (String.length file > nn && String.sub file 0 nn = home) then begin
|
||||||
|
".." // String.sub file (nn+1) (String.length file - nn -1)
|
||||||
|
end else
|
||||||
|
let msg = sprintf "Selected file '%s' should be in '%s'" file dir in
|
||||||
|
GToolbox.message_box ~title:"Error" msg;
|
||||||
|
raise Exit
|
||||||
end else
|
end else
|
||||||
String.sub file (n+1) (String.length file - n - 1)
|
subdir // String.sub file (n+1) (String.length file - n - 1)
|
||||||
|
|
||||||
|
|
||||||
let choose_xml_file = fun ?(multiple = false) title subdir cb ->
|
let choose_xml_file = fun ?(multiple = false) title subdir cb ->
|
||||||
@@ -81,10 +86,10 @@ let choose_xml_file = fun ?(multiple = false) title subdir cb ->
|
|||||||
| `OPEN, _ when multiple ->
|
| `OPEN, _ when multiple ->
|
||||||
let names = dialog#get_filenames in
|
let names = dialog#get_filenames in
|
||||||
dialog#destroy ();
|
dialog#destroy ();
|
||||||
cb (List.map (fun f -> subdir // strip_prefix dir f) names)
|
cb (List.map (fun f -> strip_prefix dir f subdir) names)
|
||||||
| `OPEN, Some name ->
|
| `OPEN, Some name ->
|
||||||
dialog#destroy ();
|
dialog#destroy ();
|
||||||
cb [subdir // strip_prefix dir name]
|
cb [strip_prefix dir name subdir]
|
||||||
| _ -> dialog#destroy ()
|
| _ -> dialog#destroy ()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user