ls :: FileSystem -> Path -> IO [FileInfo]
ls (FileSystem fs) p =
  withCString p $ \path   ->
  alloca        $ \numptr -> do
    cinfo <- c_hdfs_list_directory fs path numptr
    num   <- peek numptr
    info  <- peekArray (fromIntegral num) cinfo >>= mapM mkFileInfo
    c_hdfs_free_file_info cinfo num
    errNo <- getErrno
    if errNo == eOK
      then return info
      else throwErrno "ls"
ls :: FileSystem -> Path -> IO [FileInfo]
ls (FileSystem fs) p =
  withCString p $ \path   ->
  alloca        $ \numptr -> do
    cinfo <- c_hdfs_list_directory fs path numptr
    num   <- peek numptr
    info  <- peekArray (fromIntegral num) cinfo >>= mapM mkFileInfo
    c_hdfs_free_file_info cinfo num
    errNo <- getErrno
    if errNo == eOK
      then return info
      else throwErrno "ls"
ls (FileSystem fs) p =
  withCString p $ \path   ->
  alloca        $ \numptr -> do
    cinfo <- c_hdfs_list_directory fs path numptr
    num   <- peek numptr
    info  <- peekArray (fromIntegral num) cinfo >>= mapM mkFileInfo
    c_hdfs_free_file_info cinfo num
    errNo <- getErrno
    if errNo == eOK
      then return info
      else throwErrno "ls"