mirror of
https://github.com/itchyny/mmv.git
synced 2025-12-27 06:34:57 +08:00
use strconv.FormatUint with base 16 to generate temporary paths
This commit is contained in:
parent
85ce23caff
commit
5ac7f7d75f
1 changed files with 2 additions and 2 deletions
4
mmv.go
4
mmv.go
|
|
@ -1,10 +1,10 @@
|
|||
package mmv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ func buildRenames(files map[string]string) ([]rename, error) {
|
|||
// create a temporary path where there is no file currently
|
||||
func temporaryPath(dir string) (string, error) {
|
||||
for i := 0; i < 256; i++ {
|
||||
path := filepath.Join(dir, fmt.Sprint(rand.Uint64()))
|
||||
path := filepath.Join(dir, strconv.FormatUint(rand.Uint64()|1<<60, 16))
|
||||
if _, err := os.Stat(path); err != nil && os.IsNotExist(err) {
|
||||
return path, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue