mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
win_stat: Add stat.isreg support (#27732)
* win_stat: Add stat.isreg support This PR includes the following changes: - Adds stat.isreg support (cfr. the stat module) - Always returns stat.isdir, stat.islnk, stat.isreg, stat.isshared * Remove the controversial part
This commit is contained in:
parent
477ed3cc96
commit
60276b60a2
2 changed files with 11 additions and 6 deletions
|
@ -78,7 +78,9 @@ $checksum_algorithm = Get-AnsibleParam -obj $params -name "checksum_algorithm" -
|
||||||
|
|
||||||
$result = @{
|
$result = @{
|
||||||
changed = $false
|
changed = $false
|
||||||
stat = @{}
|
stat = @{
|
||||||
|
exists = $false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Backward compatibility
|
# Backward compatibility
|
||||||
|
@ -93,6 +95,7 @@ If (Test-Path -Path $path)
|
||||||
# Initial values
|
# Initial values
|
||||||
$result.stat.isdir = $false
|
$result.stat.isdir = $false
|
||||||
$result.stat.islnk = $false
|
$result.stat.islnk = $false
|
||||||
|
$result.stat.isreg = $false
|
||||||
$result.stat.isshared = $false
|
$result.stat.isshared = $false
|
||||||
|
|
||||||
# Need to use -Force so it picks up hidden files
|
# Need to use -Force so it picks up hidden files
|
||||||
|
@ -160,8 +163,9 @@ If (Test-Path -Path $path)
|
||||||
}
|
}
|
||||||
Else
|
Else
|
||||||
{
|
{
|
||||||
$result.stat.size = $info.Length
|
|
||||||
$result.stat.extension = $info.Extension
|
$result.stat.extension = $info.Extension
|
||||||
|
$result.stat.isreg = $true
|
||||||
|
$result.stat.size = $info.Length
|
||||||
|
|
||||||
If ($get_md5) {
|
If ($get_md5) {
|
||||||
$result.stat.md5 = Get-FileChecksum -path $path -algorithm "md5"
|
$result.stat.md5 = Get-FileChecksum -path $path -algorithm "md5"
|
||||||
|
@ -172,9 +176,5 @@ If (Test-Path -Path $path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else
|
|
||||||
{
|
|
||||||
$result.stat.exists = $false
|
|
||||||
}
|
|
||||||
|
|
||||||
Exit-Json $result
|
Exit-Json $result
|
||||||
|
|
|
@ -173,6 +173,11 @@ stat:
|
||||||
returned: success, path exists
|
returned: success, path exists
|
||||||
type: boolean
|
type: boolean
|
||||||
sample: True
|
sample: True
|
||||||
|
isreg:
|
||||||
|
description: if the path is a regular file
|
||||||
|
returned: success, path exists
|
||||||
|
type: boolean
|
||||||
|
sample: True
|
||||||
isshared:
|
isshared:
|
||||||
description: if the path is shared or not
|
description: if the path is shared or not
|
||||||
returned: success, path exists
|
returned: success, path exists
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue