mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
25 lines
454 B
Go
25 lines
454 B
Go
|
package gio
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"strconv"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// Chtimes applies the given ts to the given path.
|
||
|
func Chtimes(path, ts string) error {
|
||
|
if ts == "" {
|
||
|
return nil
|
||
|
}
|
||
|
modUnix, err := strconv.ParseInt(ts, 10, 64)
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("chtimes: %s: %w", path, err)
|
||
|
}
|
||
|
modTime := time.Unix(modUnix, 0)
|
||
|
if err := os.Chtimes(path, modTime, modTime); err != nil {
|
||
|
return fmt.Errorf("chtimes: %s: %w", path, err)
|
||
|
}
|
||
|
return nil
|
||
|
}
|