tempname_windows.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. //
  3. // This program is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by the Free
  5. // Software Foundation, either version 3 of the License, or (at your option)
  6. // any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful, but WITHOUT
  9. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. // more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program. If not, see <http://www.gnu.org/licenses/>.
  15. // +build windows
  16. package model
  17. import (
  18. "fmt"
  19. "path/filepath"
  20. "strings"
  21. )
  22. type tempNamer struct {
  23. prefix string
  24. }
  25. var defTempNamer = tempNamer{"~syncthing~"}
  26. func (t tempNamer) IsTemporary(name string) bool {
  27. return strings.HasPrefix(filepath.Base(name), t.prefix)
  28. }
  29. func (t tempNamer) TempName(name string) string {
  30. tdir := filepath.Dir(name)
  31. tname := fmt.Sprintf("%s.%s.tmp", t.prefix, filepath.Base(name))
  32. return filepath.Join(tdir, tname)
  33. }