200 def apply(path: Path, ssh: SSH.System = SSH.Local): Directory = |
200 def apply(path: Path, ssh: SSH.System = SSH.Local): Directory = |
201 new Directory(ssh.absolute_path(path), ssh) |
201 new Directory(ssh.absolute_path(path), ssh) |
202 } |
202 } |
203 |
203 |
204 class Directory private(val path: Path, val ssh: SSH.System = SSH.Local) { |
204 class Directory private(val path: Path, val ssh: SSH.System = SSH.Local) { |
205 override def toString: String = path.toString |
205 override def toString: String = path.toString + ssh.print |
206 |
206 |
207 def etc: Path = path + Path.basic("etc") |
207 def etc: Path = path + Path.basic("etc") |
208 def src: Path = path + Path.basic("src") |
208 def src: Path = path + Path.basic("src") |
209 def lib: Path = path + Path.basic("lib") |
209 def lib: Path = path + Path.basic("lib") |
210 def settings: Path = etc + Path.basic("settings") |
210 def settings: Path = etc + Path.basic("settings") |
212 def build_props: Path = etc + Path.basic("build.props") |
212 def build_props: Path = etc + Path.basic("build.props") |
213 def README: Path = path + Path.basic("README") |
213 def README: Path = path + Path.basic("README") |
214 def LICENSE: Path = path + Path.basic("LICENSE") |
214 def LICENSE: Path = path + Path.basic("LICENSE") |
215 |
215 |
216 def create(progress: Progress = new Progress): Directory = { |
216 def create(progress: Progress = new Progress): Directory = { |
217 progress.echo("Creating component directory " + path) |
217 progress.echo("Creating component directory " + toString) |
218 ssh.new_directory(path) |
218 ssh.new_directory(path) |
219 ssh.make_directory(etc) |
219 ssh.make_directory(etc) |
220 this |
220 this |
221 } |
221 } |
222 |
222 |
223 def ok: Boolean = |
223 def ok: Boolean = |
224 ssh.is_file(settings) || ssh.is_file(components) || Sessions.is_session_dir(path, ssh = ssh) |
224 ssh.is_file(settings) || ssh.is_file(components) || Sessions.is_session_dir(path, ssh = ssh) |
225 |
225 |
226 def check: Directory = |
226 def check: Directory = |
227 if (!ssh.is_dir(path)) error("Bad component directory: " + path) |
227 if (!ssh.is_dir(path)) error("Bad component directory: " + toString) |
228 else if (!ok) { |
228 else if (!ok) { |
229 error("Malformed component directory: " + path + |
229 error("Malformed component directory: " + toString + |
230 "\n (missing \"etc/settings\" or \"etc/components\" or \"ROOT\" or \"ROOTS\")") |
230 "\n (missing \"etc/settings\" or \"etc/components\" or \"ROOT\" or \"ROOTS\")") |
231 } |
231 } |
232 else this |
232 else this |
233 |
233 |
234 def read_components(): List[String] = |
234 def read_components(): List[String] = |