| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.mockftpserver.fake.filesystem; |
| 17 | |
|
| 18 | |
import org.mockftpserver.core.util.Assert; |
| 19 | |
|
| 20 | |
import java.util.Date; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
public abstract class AbstractFileSystemEntry implements FileSystemEntry { |
| 29 | |
|
| 30 | |
private String path; |
| 31 | 807 | private boolean pathLocked = false; |
| 32 | |
|
| 33 | |
private Date lastModified; |
| 34 | |
private String owner; |
| 35 | |
private String group; |
| 36 | |
|
| 37 | |
public Date getLastModified() { |
| 38 | 762 | return lastModified; |
| 39 | |
} |
| 40 | |
|
| 41 | |
public void setLastModified(Date lastModified) { |
| 42 | 710 | this.lastModified = lastModified; |
| 43 | 710 | } |
| 44 | |
|
| 45 | |
public String getOwner() { |
| 46 | 119 | return owner; |
| 47 | |
} |
| 48 | |
|
| 49 | |
public void setOwner(String owner) { |
| 50 | 66 | this.owner = owner; |
| 51 | 66 | } |
| 52 | |
|
| 53 | |
public String getGroup() { |
| 54 | 75 | return group; |
| 55 | |
} |
| 56 | |
|
| 57 | |
public void setGroup(String group) { |
| 58 | 66 | this.group = group; |
| 59 | 66 | } |
| 60 | |
|
| 61 | |
public Permissions getPermissions() { |
| 62 | 234 | return permissions; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public void setPermissions(Permissions permissions) { |
| 66 | 96 | this.permissions = permissions; |
| 67 | 96 | } |
| 68 | |
|
| 69 | |
private Permissions permissions; |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | 124 | public AbstractFileSystemEntry() { |
| 75 | 124 | } |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | 683 | public AbstractFileSystemEntry(String path) { |
| 83 | 683 | this.path = path; |
| 84 | 683 | } |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
public String getPath() { |
| 90 | 912 | return path; |
| 91 | |
} |
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
public String getName() { |
| 97 | 66 | int separatorIndex1 = path.lastIndexOf('/'); |
| 98 | 66 | int separatorIndex2 = path.lastIndexOf('\\'); |
| 99 | |
|
| 100 | 66 | int separatorIndex = separatorIndex1 > separatorIndex2 ? separatorIndex1 : separatorIndex2; |
| 101 | 66 | return (separatorIndex == -1) ? path : path.substring(separatorIndex + 1); |
| 102 | |
} |
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
public void setPath(String path) { |
| 110 | 132 | Assert.isFalse(pathLocked, "path is locked"); |
| 111 | 126 | this.path = path; |
| 112 | 126 | } |
| 113 | |
|
| 114 | |
public void lockPath() { |
| 115 | 696 | this.pathLocked = true; |
| 116 | 696 | } |
| 117 | |
|
| 118 | |
public void setPermissionsFromString(String permissionsString) { |
| 119 | 6 | this.permissions = new Permissions(permissionsString); |
| 120 | 6 | } |
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
public abstract boolean isDirectory(); |
| 128 | |
|
| 129 | |
} |