-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathcommand_windows.go
More file actions
35 lines (30 loc) · 802 Bytes
/
Copy pathcommand_windows.go
File metadata and controls
35 lines (30 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) Liam Stanley <liam@liam.sh>. All rights reserved. Use of
// this source code is governed by the MIT license that can be found in
// the LICENSE file.
//go:build windows
package ytdlp
import (
"debug/pe"
"os"
"os/exec"
"syscall"
)
// applySyscall applies any OS-specific syscall attributes to the command.
func applySyscall(cmd *exec.Cmd, separateProcessGroup bool) {
cmd.SysProcAttr = &syscall.SysProcAttr{
CreationFlags: 0x08000000, // CREATE_NO_WINDOW.
HideWindow: true,
}
if separateProcessGroup {
cmd.SysProcAttr.CreationFlags |= syscall.CREATE_NEW_PROCESS_GROUP
}
}
func isExecutable(path string, _ os.FileInfo) bool {
// Try to parse as PE (Portable Executable) format.
f, err := pe.Open(path)
if err != nil {
return false
}
f.Close()
return true
}