aboutsummaryrefslogtreecommitdiff
path: root/internal/imap/folder.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/imap/folder.go')
-rw-r--r--internal/imap/folder.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/imap/folder.go b/internal/imap/folder.go
new file mode 100644
index 0000000..1f4e0bf
--- /dev/null
+++ b/internal/imap/folder.go
@@ -0,0 +1,33 @@
+package imap
+
+import "strings"
+
+type Folder struct {
+ str string
+ delimiter string
+}
+
+func (f Folder) String() string {
+ return f.str
+}
+
+func (f Folder) Append(other Folder) Folder {
+ if f.delimiter != other.delimiter {
+ panic("Delimiters do not match")
+ }
+ return Folder{
+ str: f.str + f.delimiter + other.str,
+ delimiter: f.delimiter,
+ }
+}
+
+func (client *Client) folderName(path []string) Folder {
+ return Folder{
+ strings.Join(path, client.delimiter),
+ client.delimiter,
+ }
+}
+
+func (client *Client) NewFolder(path []string) Folder {
+ return client.toplevel.Append(client.folderName(path))
+}