Path: blob/main/component/common/loki/positions/write_positions_windows.go
4096 views
//go:build windows12package positions34// This code is copied from Promtail. The positions package allows logging5// components to keep track of read file offsets on disk and continue from the6// same place in case of a restart.78import (9"os"10"path/filepath"1112yaml "gopkg.in/yaml.v2"13)1415// writePositionFile is a fallback for Windows because renameio does not support Windows.16// See https://github.com/google/renameio#windows-support17func writePositionFile(filename string, positions map[Entry]string) error {18buf, err := yaml.Marshal(File{19Positions: positions,20})21if err != nil {22return err23}2425target := filepath.Clean(filename)26temp := target + "-new"2728err = os.WriteFile(temp, buf, os.FileMode(positionFileMode))29if err != nil {30return err31}3233return os.Rename(temp, target)34}353637