packages feed

hsc3-0.21: Sound/Sc3/Server/Graphdef/Io.hs

-- | Encoding agnostic i/o.
module Sound.Sc3.Server.Graphdef.Io where

import Data.List {- base -}

import Sound.Sc3.Server.Graphdef {- hsc3 -}
import qualified Sound.Sc3.Server.Graphdef.Binary as Binary {- hsc3 -}
import qualified Sound.Sc3.Server.Graphdef.Text as Text {- hsc3 -}

{- | Encoding agnostic file reader.
If the file has a .scsyndef.text extension it's read as a text file, else as a binary file.

read_graphdef_file "/tmp/stsc3.scsyndef.text"
-}
read_graphdef_file :: FilePath -> IO Graphdef
read_graphdef_file fn =
  if ".scsyndef.text" `isSuffixOf` fn
    then Text.read_graphdef_file fn
    else Binary.read_graphdef_file fn