hidden.go 874 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package hidden
  2. import (
  3. "path/filepath"
  4. "strings"
  5. )
  6. /*
  7. Arozos hidden module
  8. author: tobychui
  9. No, the name didn't mean you can't find this module
  10. Yes, this is actually a module that use to hide files
  11. */
  12. //Hide a given folder
  13. func HideFile(folderpath string) error {
  14. return hide(folderpath)
  15. }
  16. //Check if a given file is hidden. Set recursive to true if you want to check if the file located inside a hidden folder
  17. func IsHidden(filename string, recursive bool) (bool, error) {
  18. if recursive {
  19. filename = filepath.ToSlash(filename)
  20. chunks := strings.Split(filename, "/")
  21. for _, chunk := range chunks {
  22. if strings.TrimSpace(chunk) == "" {
  23. //Empty chunk. Skip this
  24. continue
  25. }
  26. hiddenState, _ := isHidden(strings.TrimSpace(chunk))
  27. if hiddenState {
  28. return true, nil
  29. }
  30. }
  31. return false, nil
  32. } else {
  33. return isHidden(filename)
  34. }
  35. }