func OpenProject(fileName string) (*Project, error) { var err error p := &Project{} p.projectFile, _ = filepath.Abs(fileName) p.projectDir = filepath.Dir(p.projectFile) p.cfg, err = loadConfig(fileName) for _, fn := range p.cfg.Files { fp := file.NewFile(fn) p.files = append(p.files, fp) fp.Open(p.projectDir) } return p, err }
func (p *Project) AddFile(relpath string) error { ppath := filepath.Join(p.projectDir, relpath) if _, err := os.Lstat(ppath); err != nil { return err } if p.GetFile(relpath) != nil { return nil } file := file.NewFile(relpath) p.files = append(p.files, file) return nil }
func (p *Project) NewFile(relpath string) error { ppath := filepath.Join(p.projectDir, relpath) f, err := os.Create(ppath) if err != nil { return err } f.Close() if p.GetFile(relpath) != nil { return nil } file := file.NewFile(relpath) p.files = append(p.files, file) return nil }