1
2
3
4 package net.sf.jpkgmk;
5
6 import java.io.File;
7
8
9
10
11
12
13
14 public class DefaultPermissionProvider implements PermissionProvider
15 {
16 private String defaultDirectoryMode = "0550";
17 private String defaultExecutableMode = "0550";
18 private String defaultFileMode = "0440";
19
20
21
22
23 public String getMode(File file){
24 if(file.isDirectory()) {
25 return defaultDirectoryMode;
26 }
27 else {
28 String filename = file.getName();
29
30 if(filename.endsWith(".sh") || filename.endsWith(".bat")) {
31 return defaultExecutableMode;
32 }
33
34 return defaultFileMode;
35 }
36 }
37
38 @Override
39 public String toString()
40 {
41 StringBuffer sb = new StringBuffer();
42 sb.append(getClass().getName()).append("[");
43 sb.append("defaultDirectoryMode=").append(defaultDirectoryMode);
44 sb.append(",defaultExecutableMode=").append(defaultExecutableMode);
45 sb.append(",defaultFileMode=").append(defaultFileMode);
46 sb.append("]");
47 return sb.toString();
48 }
49
50 }