function transform_filter_property(type, FilterProperty) {
if (typeof type == 'binary' && type == "date") {
return ["DATE(", FilterProperty, ")"];
} else {
return FilterProperty;
}
function transform_filter_value(type, FilterValue) {
if (typeof type == 'binary' && type == "date" &&
typeof FilterValue == 'binary' && strlen(FilterValue) == 10) {
return [substr(FilterValue, 6, 4), "-",
substr(FilterValue, 3, 2), "-",
substr(FilterValue, 0, 2), "-"];
} else {
return FilterValue;
}
}
read_file_by_lines(Name, Mode, Array) ->
{ok, Device} = file:open(Name, Mode),
read_each_line(Device, []).
read_each_line(Device, Accum) ->
case io:get_line(Device, "") of
eof -> file:close(Device), array:from_list(lists:reverse(Accum));
Line -> read_each_line(Device, [Line | Accum])
end.
write_file_by_lines(Name, Mode, Array) ->
{ok, Device} = file:open(Name, Mode),
lists:foreach(
fun(Line) -> io:write(Device, Line)
end,
array:to_list(Array)),
file:close(Device).