Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 5934946

Browse files
author
vadim
committed
feat: added name and path to StorageElement
1 parent d09d3d2 commit 5934946

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

‎app-core/src/main/java/com/codee/app/core/plugins/files/ChildDirectoryStorageElement.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,10 @@ class ChildDirectoryStorageElement(private val rootDirectory: File, private val
2929
} else throw SecurityException("Unable to get file at ${file.absolutePath}, you don't have such permission.")
3030
}
3131

32+
override val name: String
33+
get() = origin.name
34+
35+
override val path: String
36+
get() = origin.path.replace(rootDirectory.path, "")
37+
3238
}

‎app-core/src/main/java/com/codee/app/core/plugins/files/EmptyStorageElement.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ class EmptyStorageElement(private val origin: File, private val rootDirectory: F
1515
return FileStorageElement(origin, rootDirectory)
1616
}
1717

18+
override val name: String
19+
get() = origin.name
20+
21+
override val path: String
22+
get() = origin.path.replace(rootDirectory.path, "")
23+
1824
}

‎app-core/src/main/java/com/codee/app/core/plugins/files/FileStorageElement.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ class FileStorageElement internal constructor(
2121
origin.delete()
2222
return@withContext EmptyStorageElement(origin, rootDirectory)
2323
}
24+
25+
override val name: String
26+
get() = origin.name
27+
28+
override val path: String
29+
get() = origin.path.replace(rootDirectory.path, "")
2430
}

‎app-core/src/main/java/com/codee/app/core/plugins/files/RootDirectoryStorageElement.kt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ class RootDirectoryStorageElement(private val origin: File) : IRootDirectoryStor
1515
else ChildDirectoryStorageElement(origin, file)
1616
} else throw SecurityException("Unable to get file at ${file.absolutePath}, you don't have such permission.")
1717
}
18+
override val name: String
19+
get() = origin.name
20+
21+
override val path: String
22+
get() = "/"
1823
}

‎plugins-api/src/main/kotlin/com/codee/app/plugins/api/files/DirectoryStorageElement.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.codee.app.plugins.api.files
22

33
public sealed interface DirectoryStorageElement : StorageElement {
4+
45
/**
56
* Gets [StorageElement] at current path + [name].
67
* @return [StorageElement].
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
package com.codee.app.plugins.api.files
22

3-
public sealed interface StorageElement
3+
public sealed interface StorageElement {
4+
/**
5+
* Storage element name.
6+
*/
7+
public val name: String
8+
9+
/**
10+
* Storage element path starts from [DirectoryStorageElement.RootDirectoryStorageElement].
11+
*/
12+
public val path: String
13+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /