search for: default_newline

Displaying 2 results from an estimated 2 matches for "default_newline".

2016 Sep 30
2
[PATCH] customize: Add --append-line.
...Boston, MA 02110-1301 USA. + *) + +open Common_utils +open Common_gettext.Gettext + +module G = Guestfs + +let append_line (g : G.guestfs) root path line = + (* The default line ending for this guest type. This is only + * used when we don't know anything more about the file. + *) + let default_newline () = + match g#inspect_get_type root with + | "windows" -> "\r\n" + | _ -> "\n" + in + + if not (g#exists path) then ( + g#write path (line ^ default_newline ()) + ) + else ( + (* Stat the file. We want to know it's a regular file, and +...
2016 Sep 30
0
Re: [PATCH] customize: Add --append-line.
...default for this guest type. > + *) > + let newline = > + let content = g#pread path 8192 0L in > + if String.find content "\r\n" >= 0 then "\r\n" > + else if String.find content "\n" >= 0 then "\n" > + else default_newline () in Should this also check for the Mac end line ('\r')? (If so, the API documentation should mention that too.) Thanks, -- Pino Toscano