X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=filetree_markup.ml;h=b5f3b48e4a24f0f17ff3795cbde680a306707eef;hb=master;hp=ebae98b5ca1a9b0825cdb80713e198a0adc78330;hpb=4fa4ca7430421c477e7f813819a8a70279de0a65;p=guestfs-browser.git diff --git a/filetree_markup.ml b/filetree_markup.ml index ebae98b..b5f3b48 100644 --- a/filetree_markup.ml +++ b/filetree_markup.ml @@ -18,16 +18,15 @@ open ExtString open ExtList -open CamomileLibrary -open Default.Camomile open Unix open Utils open Slave_types -open Filetree_type open Printf +module CL = CalendarLib + (* Base colours. XXX Should be configurable somewhere. *) let file_color = 0x20, 0x20, 0xff (* regular file *) let dir_color = 0x80, 0x80, 0x20 (* directory *) @@ -116,32 +115,7 @@ and darken (r, g, b) = (* Mark up mode. *) let markup_of_mode mode = - let c = - if is_socket mode then 's' - else if is_symlink mode then 'l' - else if is_regular_file mode then '-' - else if is_block mode then 'b' - else if is_directory mode then 'd' - else if is_char mode then 'c' - else if is_fifo mode then 'p' else '?' in - let ru = if is_ru mode then 'r' else '-' in - let wu = if is_wu mode then 'w' else '-' in - let xu = if is_xu mode then 'x' else '-' in - let rg = if is_rg mode then 'r' else '-' in - let wg = if is_wg mode then 'w' else '-' in - let xg = if is_xg mode then 'x' else '-' in - let ro = if is_ro mode then 'r' else '-' in - let wo = if is_wo mode then 'w' else '-' in - let xo = if is_xo mode then 'x' else '-' in - let str = sprintf "%c%c%c%c%c%c%c%c%c%c" c ru wu xu rg wg xg ro wo xo in - - let suid = is_suid mode in - let sgid = is_sgid mode in - let svtx = is_svtx mode in - if suid then str.[3] <- 's'; - if sgid then str.[6] <- 's'; - if svtx then str.[9] <- 't'; - + let str = file_permissions_string mode in "" ^ str ^ "" (* Mark up dates. *) @@ -152,10 +126,10 @@ let markup_of_date t = let t = Int64.to_float t in let show_full_date () = - let tm = localtime t in - sprintf "%04d-%02d-%02d %02d:%02d:%02d" - (tm.tm_year + 1900) (tm.tm_mon + 1) tm.tm_mday - tm.tm_hour tm.tm_min tm.tm_sec + let cal = CL.Calendar.from_unixfloat t in + let cal = CL.Calendar.convert cal CL.Time_Zone.UTC CL.Time_Zone.Local in + CL.Printer.Calendar.sprint + "%F %T" cal in (* How long ago? *) @@ -201,30 +175,3 @@ let markup_of_regvaluetype h value = let markup_of_regvaluesize h value = let _, len = Hivex.value_type h value in sprintf "%d" len - -(* This is a bit of a hack. Ideally just setting 'visited' would - * darken the colour when the cell was re-rendered. However that would - * mean we couldn't store other stuff in the name column. Therefore, - * repopulate the name column. - *) -let set_visited ({ model = model; name_col = name_col } as t) row = - let hdata = get_hdata t row in - if hdata.visited = false then ( - hdata.visited <- true; - match hdata.content with - | Directory direntry | File direntry -> - debug "set_visited %s" direntry.dent_name; - model#set ~row ~column:name_col - (markup_of_name ~visited:true direntry) - | RegKey node -> - debug "set_visited RegKey"; - let h = Option.get hdata.hiveh in - model#set ~row ~column:name_col - (markup_of_regkey ~visited:true h node) - | RegValue value -> - debug "set_visited RegValue"; - let h = Option.get hdata.hiveh in - model#set ~row ~column:name_col - (markup_of_regvalue ~visited:true h value) - | Loading | ErrorMessage _ | Info _ | Top _ | TopWinReg _ -> () - )