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.") } }
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.") } }
func (d *Directory) File(s string) iface.File { return file.New(filepath.Join(d.path, s)) }
func (f *FileInfo) File() iface.File { if f.isDir { panic("Not a file") } return file.New(f.path) }
func (d *Directory) File(s ...string) iface.File { arg := []string{d.path} arg = append(arg, s...) return file.New(filepath.Join(arg...)) }