# _file_system.py
#
# Project: AutoArchive
# License: GNU GPLv3
#
# Copyright (C) 2003 - 2026 Róbert Čerňanský



import os.path
import shutil

from AutoArchive._meta import _Meta
from AutoArchive._ui.cmdline._cmdline_ui import CmdlineUi



class _FileSystem:

    @staticmethod
    def exists(path: str):
        return os.path.exists(path)



    @staticmethod
    def moveWithBackup(src: str, dest: str, cmdLineUi: CmdlineUi):
        if not os.path.exists(src):
            cmdLineUi.showWarning(f"No such file or directory: '{src}'")
            os.makedirs(dest)
            return

        backupCopyPath = src + "_backup_pre-" + _Meta.VERSION
        if not os.path.exists(backupCopyPath):
            shutil.copytree(src, backupCopyPath)
        shutil.move(src, dest)
