import os
from os import PathLike
from typing import Union, Optional


class File(object):
    base_path: Optional[Union[os.PathLike[str], str]]
    file: Union[PathLike[str], str]

    def __init__(self, file: Union[os.PathLike[str], str], base_path: Optional[Union[os.PathLike[str], str]] = None):
        self.file = file
        self.base_path = base_path

    @property
    def full_path(self) -> str:
        if self.base_path is None or len(self.base_path.strip()) == 0:
            return self.file
        else:
            return os.path.join(self.base_path, self.file)

    def abs_path(self) -> str:
        return os.path.abspath(self.full_path)

    def exist(self) -> bool:
        return os.path.exists(self.full_path)