github.com/kayoticsully/syncthing@v0.8.9-0.20140724133906-c45a2fdc03f8/model/tempname_windows.go (about)

     1  // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
     2  // All rights reserved. Use of this source code is governed by an MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build windows
     6  
     7  package model
     8  
     9  import (
    10  	"fmt"
    11  	"path/filepath"
    12  	"strings"
    13  )
    14  
    15  type tempNamer struct {
    16  	prefix string
    17  }
    18  
    19  var defTempNamer = tempNamer{"~syncthing~"}
    20  
    21  func (t tempNamer) IsTemporary(name string) bool {
    22  	return strings.HasPrefix(filepath.Base(name), t.prefix)
    23  }
    24  
    25  func (t tempNamer) TempName(name string) string {
    26  	tdir := filepath.Dir(name)
    27  	tname := fmt.Sprintf("%s.%s.tmp", t.prefix, filepath.Base(name))
    28  	return filepath.Join(tdir, tname)
    29  }