From 04651f3b8edc43b7c88cfb603e55fbe5444403a5 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sat, 13 Jan 2024 15:12:03 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AE=9F=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/model/PublicPath.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/model/src/main/java/one/nem/lacerta/model/PublicPath.java b/model/src/main/java/one/nem/lacerta/model/PublicPath.java index 8ca9e9ff..3181d00e 100644 --- a/model/src/main/java/one/nem/lacerta/model/PublicPath.java +++ b/model/src/main/java/one/nem/lacerta/model/PublicPath.java @@ -1,23 +1,47 @@ package one.nem.lacerta.model; +import java.util.ArrayList; +import java.util.List; + public class PublicPath { /* * ユーザーが扱うパス(内部パスの代替) */ - String[] path; + List path = new ArrayList(); public PublicPath() { - this.path = new String[0]; } - public PublicPath load(String[] path) { + public PublicPath(List path) { this.path = path; + } + + private void add(String path) { + this.path.add(path); + } + + public PublicPath resolve(String path) { + if (path.equals("..")) { + this.path.remove(this.path.size() - 1); + } else { + add(path); + } return this; } - public PublicPath load(String path) { - this.path = path.split("/"); + public PublicPath resolve(List path) { + for (String p : path) { + resolve(p); + } return this; } + + public List getPath() { + return path; + } + + public String getStringPath() { + return String.join("/", path); + } }