package com.ruoyi.file.enums;

import java.io.File;

public final class FileType
{
    public static final int FILE = 1;
    public static final int DIRECTORY = 1 << 1;

    public static boolean Test(int flag, int target)
    {
        return (flag & target) != 0;
    }

    public static boolean Is(File file, int flag)
    {
        if(!Test(flag, FILE) && file.isFile())
            return false;
        if(!Test(flag, DIRECTORY) && file.isDirectory())
            return false;
        return true;
    }

    public static int FileType(File file)
    {
        int flag = 0;
        if(file.isFile())
            flag |= FILE;
        if(file.isDirectory())
            flag |= DIRECTORY;
        return flag;
    }
}
