tempname_windows.go 711 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at http://mozilla.org/MPL/2.0/.
  6. // +build windows
  7. package model
  8. import (
  9. "fmt"
  10. "path/filepath"
  11. "strings"
  12. )
  13. type tempNamer struct {
  14. prefix string
  15. }
  16. var defTempNamer = tempNamer{"~syncthing~"}
  17. func (t tempNamer) IsTemporary(name string) bool {
  18. return strings.HasPrefix(filepath.Base(name), t.prefix)
  19. }
  20. func (t tempNamer) TempName(name string) string {
  21. tdir := filepath.Dir(name)
  22. tname := fmt.Sprintf("%s.%s.tmp", t.prefix, filepath.Base(name))
  23. return filepath.Join(tdir, tname)
  24. }