getTplErrors :: FilePath -> FsEntry -> IO [String]
getTplErrors tplDir e
  | _entryTmpl e == Default   = return []
  | otherwise = do
    fileExists <- doesFileExist path
    dirExists  <- doesDirectoryExist path
    return $ if _entryKind e == File
                then if not fileExists
                        then if dirExists then [errFDir] else [errF]
                        else []
                else if not dirExists
                        then if fileExists then [errDFile] else [errD]
                        else []
  where
    path     = tplDir `combine` (_entryTmplSource . _entryTmpl) e
    errFDir  = "Template '" ++ path ++ "' is a directory, expected a file"
    errF     = "Template file '" ++ path ++ "' not found"
    errDFile = "Template '" ++ path ++ "' is a file, expected a directory"
    errD     = "Template directory '" ++ path ++ "' not found"

-- Return errors if name is invalid or path is absolute
getTplErrors :: FilePath -> FsEntry -> IO [String]
getTplErrors tplDir e
  | _entryTmpl e == Default   = return []
  | otherwise = do
    fileExists <- doesFileExist path
    dirExists  <- doesDirectoryExist path
    return $ if _entryKind e == File
                then if not fileExists
                        then if dirExists then [errFDir] else [errF]
                        else []
                else if not dirExists
                        then if fileExists then [errDFile] else [errD]
                        else []
  where
    path     = tplDir `combine` (_entryTmplSource . _entryTmpl) e
    errFDir  = "Template '" ++ path ++ "' is a directory, expected a file"
    errF     = "Template file '" ++ path ++ "' not found"
    errDFile = "Template '" ++ path ++ "' is a file, expected a directory"
    errD     = "Template directory '" ++ path ++ "' not found"

-- Return errors if name is invalid or path is absolute
getTplErrors tplDir e
  | _entryTmpl e == Default   = return []
  | otherwise = do
    fileExists <- doesFileExist path
    dirExists  <- doesDirectoryExist path
    return $ if _entryKind e == File
                then if not fileExists
                        then if dirExists then [errFDir] else [errF]
                        else []
                else if not dirExists
                        then if fileExists then [errDFile] else [errD]
                        else []
  where
    path     = tplDir `combine` (_entryTmplSource . _entryTmpl) e
    errFDir  = "Template '" ++ path ++ "' is a directory, expected a file"
    errF     = "Template file '" ++ path ++ "' not found"
    errDFile = "Template '" ++ path ++ "' is a file, expected a directory"
    errD     = "Template directory '" ++ path ++ "' not found"

-- Return errors if name is invalid or path is absolute