hidden.go 788 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. hiddenState, _ := isHidden(strings.TrimSpace(chunk))
  23. if hiddenState {
  24. return true, nil
  25. }
  26. }
  27. return false, nil
  28. } else {
  29. return isHidden(filename)
  30. }
  31. }