You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
522 B

7 years ago
7 years ago
7 years ago
  1. package filer2
  2. import (
  3. "path/filepath"
  4. "strings"
  5. )
  6. type FullPath string
  7. func NewFullPath(dir, name string) FullPath {
  8. if strings.HasSuffix(dir, "/") {
  9. return FullPath(dir + name)
  10. }
  11. return FullPath(dir + "/" + name)
  12. }
  13. func (fp FullPath) DirAndName() (string, string) {
  14. dir, name := filepath.Split(string(fp))
  15. if dir == "/" {
  16. return dir, name
  17. }
  18. if len(dir) < 1 {
  19. return "/", ""
  20. }
  21. return dir[:len(dir)-1], name
  22. }
  23. func (fp FullPath) Name() string {
  24. _, name := filepath.Split(string(fp))
  25. return name
  26. }