-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
directory.go
36 lines (30 loc) · 980 Bytes
/
directory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package faker
import (
"strings"
)
// Directory is a faker struct for Directory
type Directory struct {
Faker *Faker
OSResolver OSResolver
}
// Directory returns a fake directory path (the directory path style is dependent OS dependent)
func (d Directory) Directory(levels int) string {
switch d.OSResolver.OS() {
case "windows":
return d.WindowsDirectory(levels)
default:
return d.UnixDirectory(levels)
}
}
// UnixDirectory returns a fake Unix directory path, regardless of the host OS
func (d Directory) UnixDirectory(levels int) string {
return "/" + strings.Join(d.Faker.Lorem().Words(levels), "/")
}
// WindowsDirectory returns a fake Windows directory path, regardless of the host OS
func (d Directory) WindowsDirectory(levels int) string {
return d.DriveLetter() + strings.Join(d.Faker.Lorem().Words(levels), "\\")
}
// DriveLetter returns a fake Win32 drive letter
func (d Directory) DriveLetter() string {
return d.Faker.RandomLetter() + ":\\"
}