windows: fix for checking locked system files (#30665)

* fix for checking locked system files

* moved functions to share module util and created tests

* fixed windows-paths test based on win_stat changes
This commit is contained in:
Jordan Borean 2017-11-16 10:04:03 +10:00 committed by ansibot
commit e16e6313c7
12 changed files with 166 additions and 29 deletions

View file

@ -6,6 +6,7 @@
#Requires -Module Ansible.ModuleUtils.Legacy
#Requires -Module Ansible.ModuleUtils.CommandUtil
#Requires -Module Ansible.ModuleUtils.FileUtil
# TODO: add check mode support
@ -27,11 +28,11 @@ $result = @{
cmd = $raw_command_line
}
If($creates -and $(Test-Path -Path $creates)) {
if ($creates -and $(Test-FilePath -path $creates)) {
Exit-Json @{msg="skipped, since $creates exists";cmd=$raw_command_line;changed=$false;skipped=$true;rc=0}
}
If($removes -and -not $(Test-Path -Path $removes)) {
if ($removes -and -not $(Test-FilePath -path $removes)) {
Exit-Json @{msg="skipped, since $removes does not exist";cmd=$raw_command_line;changed=$false;skipped=$true;rc=0}
}