Commit 9ea6c240 authored by Mart Lubbers's avatar Mart Lubbers

add iTasks helper functions to library

parent 96af2783
definition module iTasksTTY
getTTYDevices :: !*env -> *(![String], !*env)
implementation module iTasksTTY
import StdList
import StdFunc
import StdMisc
import StdString
import System.Directory
import Data.Error
from Text import class Text(startsWith), instance Text String
getTTYDevices :: !*env -> *(![String], !*env)
getTTYDevices w = case readDirectory "/dev" w of
(Error (errcode, errmsg), w) = abort errmsg
(Ok entries, w) = (map ((+++) "/dev/") (filter isTTY entries), w)
where
isTTY s = not (isEmpty (filter (flip startsWith s) prefixes))
prefixes = ["ttyS", "ttyACM", "ttyUSB", "tty.usbserial"]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment