Advertisement
antifa-chad

Untitled

Jun 10th, 2024
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- parse file names like 00000000D77119212C419E59@1012_T1642235909_D31_Maf_EEvent(5)_C0.jpeg
  2. parseImage :: Path Abs File -> Either ParseError Image
  3. parseImage fn = let
  4.   sgn = (char '-' >> return (-1)) <|> return 1
  5.   nat = fst . flip (!!) 0 . take 1 . readDec <$> many1 digit
  6.   int = (*) <$> sgn <*> nat
  7.   f = toFilePath . filename $ fn
  8.   p = do
  9.     dev <- many1 hexDigit
  10.     _ <- char '@'
  11.     seq_ <- int
  12.     _ <- char '_'
  13.     _ <- char 'T'
  14.     timestamp_ <- int
  15.     _ <- char '_'
  16.     _ <- char 'D'
  17.  
  18.     d_ <- int
  19.     _ <- string "_Maf_EEvent"
  20.     _ <- char '('
  21.     eevent_ <- int
  22.     _ <- string ")_C"
  23.     c_ <- nat
  24.                    
  25.     return $ Image fn dev seq_ timestamp_ d_ eevent_ c_
  26.   in
  27.     parse p f f
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement