Verificando se um arquivo é legível e regular no powershell

0

Sou novo no powershell e quero verificar se o arquivo está legível e regular. Em unix, podemos fazer isso usando -f & -r. Por exemplo, a seguinte função de script de shell aceita o nome do arquivo como argumento e verifica a legibilidade e a regularidade do arquivo, qual é o equivalente a powershell para isso?

_ChkRegularFile_R()        # checks whether a file is regular and readable
{   
    _CRFRfilename=$1                    # name of the file to be checked

_CRFRsts=1                          # default is error

if [ -f "$_CRFRfilename" ]
then
    if [ -r "$_CRFRfilename" ]
    then
        _CRFRsts=0        # success: regular file is readable
    fi
fi

return $_CRFRsts
}
    
por Mayank 26.02.2018 / 12:08

0 respostas