windowsCreateFileScript function

String windowsCreateFileScript(
  1. String path
)

Creates file path (and its parent directories) if missing, or updates its modification time — what mkdir -p … && touch … does.

Implementation

String windowsCreateFileScript(String path) => _psTry(
  '\$d = [IO.Path]::GetDirectoryName(${_psq(path)}); '
  'if (\$d) { [void][IO.Directory]::CreateDirectory(\$d) }; '
  'if ([IO.File]::Exists(${_psq(path)})) '
  '{ [IO.File]::SetLastWriteTime(${_psq(path)}, [DateTime]::Now) } '
  'else { [IO.File]::WriteAllBytes(${_psq(path)}, [byte[]]@()) }',
);