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.

23 lines
433 B

  1. package util
  2. import (
  3. "code.google.com/p/weed-fs/go/glog"
  4. "errors"
  5. "os"
  6. )
  7. func TestFolderWritable(folder string) (err error) {
  8. fileInfo, err := os.Stat(folder)
  9. if err != nil {
  10. return err
  11. }
  12. if !fileInfo.IsDir() {
  13. return errors.New("Not a valid folder!")
  14. }
  15. perm := fileInfo.Mode().Perm()
  16. glog.V(0).Infoln("Folder", folder, "Permission:", perm)
  17. if 0200&perm != 0 {
  18. return nil
  19. }
  20. return errors.New("Not writable!")
  21. }