1
0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-12-04 19:08:22 +01:00

dir: Make methods private

This commit is contained in:
adnano 2021-05-10 10:35:54 -04:00
parent ef3d518d9a
commit cf7a24bb6c
2 changed files with 14 additions and 14 deletions

22
dir.go

@ -47,12 +47,12 @@ func NewDir(path string) *Dir {
}
}
// Read reads from a directory and indexes the files and directories within it.
func (d *Dir) Read(srcDir string, task *Task) error {
return d.read(srcDir, "", task)
// read reads from a directory and indexes the files and directories within it.
func (d *Dir) read(srcDir string, task *Task) error {
return d._read(srcDir, "", task)
}
func (d *Dir) read(srcDir, path string, task *Task) error {
func (d *Dir) _read(srcDir, path string, task *Task) error {
entries, err := ioutil.ReadDir(pathpkg.Join(srcDir, path))
if err != nil {
return err
@ -67,7 +67,7 @@ func (d *Dir) read(srcDir, path string, task *Task) error {
if entry.IsDir() {
// Gather directory data
dir := NewDir(path)
if err := dir.read(srcDir, path, task); err != nil {
if err := dir._read(srcDir, path, task); err != nil {
return err
}
d.Dirs = append(d.Dirs, dir)
@ -140,8 +140,8 @@ func (d *Dir) read(srcDir, path string, task *Task) error {
return nil
}
// Process processes the directory's contents.
func (d *Dir) Process(cfg *Config, task *Task) error {
// process processes the directory's contents.
func (d *Dir) process(cfg *Config, task *Task) error {
if task.TemplateExt != "" {
// Create index
if d.index != nil {
@ -198,15 +198,15 @@ func (d *Dir) Process(cfg *Config, task *Task) error {
// Process subdirectories
for _, d := range d.Dirs {
if err := d.Process(cfg, task); err != nil {
if err := d.process(cfg, task); err != nil {
return err
}
}
return nil
}
// Write writes the directory's contents to the provided destination path.
func (d *Dir) Write(dstDir string, task *Task) error {
// write writes the directory's contents to the provided destination path.
func (d *Dir) write(dstDir string, task *Task) error {
// Create the directory
dirPath := pathpkg.Join(dstDir, d.Path)
if err := os.MkdirAll(dirPath, 0755); err != nil {
@ -250,7 +250,7 @@ func (d *Dir) Write(dstDir string, task *Task) error {
// Write subdirectories
for _, dir := range d.Dirs {
dir.Write(dstDir, task)
dir.write(dstDir, task)
}
return nil
}

@ -83,16 +83,16 @@ func run(cfg *Config) error {
func runTask(cfg *Config, task *Task) error {
// Read content
dir := NewDir("")
if err := dir.Read("content", task); err != nil {
if err := dir.read("content", task); err != nil {
return err
}
dir.sort()
// Process content
if err := dir.Process(cfg, task); err != nil {
if err := dir.process(cfg, task); err != nil {
return err
}
// Write content
if err := dir.Write(task.OutputDir, task); err != nil {
if err := dir.write(task.OutputDir, task); err != nil {
return err
}
// Copy static files