Beispiel #1
0
func TestRename(t *testing.T) {
	path := "c:/gowork/example.txt"
	os.Remove(path)
	f := file.New(path)
	err := f.Create()
	if err != nil {
		t.Fatal(err)
	}
	ex, err := exists(path)
	if err != nil {
		t.Fatal(err)
	}
	if !ex {
		t.Fatal("Not created.")
	}
	newname := "laliboy.txt"
	err = f.Rename(newname)
	if err != nil {
		t.Fatal(err)
	}
	newpath := filepath.Join(filepath.Dir(path), newname)
	ex, err = exists(newpath)
	if err != nil {
		t.Fatal(err)
	}
	if !ex {
		t.Fatal("Rename didn't happen.")
	}
}
Beispiel #2
0
func TestCreate(t *testing.T) {
	path := "c:/gowork/example.txt"
	os.Remove(path)
	f := file.New(path)
	err := f.Create()
	if err != nil {
		t.Fatal(err)
	}
	ex, err := exists(path)
	if err != nil {
		t.Fatal(err)
	}
	if !ex {
		t.Fatal("Not created.")
	}
}
Beispiel #3
0
func (d *Directory) File(s string) iface.File {
	return file.New(filepath.Join(d.path, s))
}
Beispiel #4
0
func (f *FileInfo) File() iface.File {
	if f.isDir {
		panic("Not a file")
	}
	return file.New(f.path)
}
Beispiel #5
0
func (d *Directory) File(s ...string) iface.File {
	arg := []string{d.path}
	arg = append(arg, s...)
	return file.New(filepath.Join(arg...))
}