1package chartify
2
3import (
4	"math/rand"
5	"os"
6	"path/filepath"
7	"strconv"
8	"time"
9)
10
11// exists returns whether the given file or directory exists or not
12func exists(path string) (bool, error) {
13	_, err := os.Stat(path)
14	if err == nil {
15		return true, nil
16	}
17	if os.IsNotExist(err) {
18		return false, nil
19	}
20	return true, err
21}
22
23// MkRandomDir creates a new directory with a random name made of numbers
24func mkRandomDir(basepath string) string {
25	r := strconv.Itoa((rand.New(rand.NewSource(time.Now().UnixNano()))).Int())
26	path := filepath.Join(basepath, r)
27	os.Mkdir(path, 0755)
28
29	return path
30}
31