mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
win_tempfile - return absolute path on created temp file (#53827)
* win_tempfile - return absolute path on created temp file * Fix tests for CI
This commit is contained in:
parent
17ed39a009
commit
4f9de45785
5 changed files with 106 additions and 39 deletions
|
@ -16,7 +16,14 @@ Function New-TempFile {
|
|||
$randomname = [System.IO.Path]::GetRandomFileName()
|
||||
$temppath = (Join-Path -Path $path -ChildPath "$prefix$randomname$suffix")
|
||||
Try {
|
||||
New-Item -Path $temppath -ItemType $type -WhatIf:$checkmode | Out-Null
|
||||
$file = New-Item -Path $temppath -ItemType $type -WhatIf:$checkmode
|
||||
# Makes sure we get the full absolute path of the created temp file and not a relative or DOS 8.3 dir
|
||||
if (-not $checkmode) {
|
||||
$temppath = $file.FullName
|
||||
} else {
|
||||
# Just rely on GetFulLpath for check mode
|
||||
$temppath = [System.IO.Path]::GetFullPath($temppath)
|
||||
}
|
||||
} Catch {
|
||||
$temppath = $null
|
||||
$error = $_
|
||||
|
|
|
@ -60,7 +60,7 @@ EXAMPLES = r"""
|
|||
|
||||
RETURN = r'''
|
||||
path:
|
||||
description: Path to created file or directory.
|
||||
description: The absolute path to the created file or directory.
|
||||
returned: success
|
||||
type: str
|
||||
sample: C:\Users\Administrator\AppData\Local\Temp\ansible.bMlvdk
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue