archiveFile :: Options -> String -> FilePath -> IO ()
archiveFile opts suffix fp = do
    dest <- findFreeArchive 0
    when (optReportRemove opts) $
        putStrLn (fp ++ " rename to -> " ++ dest)
    case (optRemove opts) of
        OptDryRun -> return ()
        OptScript -> putStrLn ("mv " ++ fp ++ " " ++ dest)
        OptRemove -> safely fp $ rename fp dest
  where
    findFreeArchive :: Int -> IO FilePath
    findFreeArchive n = do
        let dest = fp ++ suffix ++ "." ++ show n
        dfe <- doesFileExist dest
        if dfe
            then findFreeArchive (n + 1)
            else return dest

-- | For each framework, update the Current symlink if the version it points
-- to will be removed, or remove the whole framework if nothing will be left.
archiveFile :: Options -> String -> FilePath -> IO ()
archiveFile opts suffix fp = do
    dest <- findFreeArchive 0
    when (optReportRemove opts) $
        putStrLn (fp ++ " rename to -> " ++ dest)
    case (optRemove opts) of
        OptDryRun -> return ()
        OptScript -> putStrLn ("mv " ++ fp ++ " " ++ dest)
        OptRemove -> safely fp $ rename fp dest
  where
    findFreeArchive :: Int -> IO FilePath
    findFreeArchive n = do
        let dest = fp ++ suffix ++ "." ++ show n
        dfe <- doesFileExist dest
        if dfe
            then findFreeArchive (n + 1)
            else return dest

-- | For each framework, update the Current symlink if the version it points
-- to will be removed, or remove the whole framework if nothing will be left.
archiveFile opts suffix fp = do
    dest <- findFreeArchive 0
    when (optReportRemove opts) $
        putStrLn (fp ++ " rename to -> " ++ dest)
    case (optRemove opts) of
        OptDryRun -> return ()
        OptScript -> putStrLn ("mv " ++ fp ++ " " ++ dest)
        OptRemove -> safely fp $ rename fp dest
  where
    findFreeArchive :: Int -> IO FilePath
    findFreeArchive n = do
        let dest = fp ++ suffix ++ "." ++ show n
        dfe <- doesFileExist dest
        if dfe
            then findFreeArchive (n + 1)
            else return dest

-- | For each framework, update the Current symlink if the version it points
-- to will be removed, or remove the whole framework if nothing will be left.