2014-01-20 06:38:57 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
mr "math/rand"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
|
|
|
func name() string {
|
|
|
|
var b [16]byte
|
|
|
|
rand.Reader.Read(b[:])
|
|
|
|
return fmt.Sprintf("%x", b[:])
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var files int
|
2014-01-20 21:22:27 +00:00
|
|
|
var maxexp int
|
2014-01-20 06:38:57 +00:00
|
|
|
|
|
|
|
flag.IntVar(&files, "files", 1000, "Number of files")
|
2014-01-20 21:22:27 +00:00
|
|
|
flag.IntVar(&maxexp, "maxexp", 20, "Maximum file size (max = 2^n + 128*1024 B)")
|
2014-01-20 06:38:57 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
for i := 0; i < files; i++ {
|
|
|
|
n := name()
|
|
|
|
p0 := path.Join(string(n[0]), n[0:2])
|
|
|
|
os.MkdirAll(p0, 0755)
|
2014-01-20 21:22:27 +00:00
|
|
|
s := 1 << uint(mr.Intn(maxexp))
|
|
|
|
a := 128 * 1024
|
|
|
|
if a > s {
|
|
|
|
a = s
|
|
|
|
}
|
|
|
|
s += mr.Intn(a)
|
2014-01-20 06:38:57 +00:00
|
|
|
b := make([]byte, s)
|
|
|
|
rand.Reader.Read(b)
|
|
|
|
p1 := path.Join(p0, n)
|
|
|
|
ioutil.WriteFile(p1, b, 0644)
|
|
|
|
}
|
|
|
|
}
|