Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Mac project logs moved to ~/Library/Logs #148

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ interface PathProvider {
fun resolve(fileName: String?, fileType: FileType): Path {
val path = when (fileType) {
FileType.USER -> clipUserPath
FileType.LOG -> clipUserPath.resolve("logs")
FileType.ENCRYPT -> clipUserPath.resolve("encrypt")
FileType.DATA -> clipUserPath.resolve("data")
FileType.LOG -> clipLogPath.resolve("logs")
FileType.ENCRYPT -> clipEncryptPath.resolve("encrypt")
FileType.DATA -> clipDataPath.resolve("data")
}

if (!path.toFile().exists()) {
Expand All @@ -23,4 +23,9 @@ interface PathProvider {

val clipUserPath: Path

val clipLogPath: Path get() = clipUserPath

val clipEncryptPath get() = clipUserPath

val clipDataPath get() = clipUserPath
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class WindowsPathProvider: PathProvider {

class MacosPathProvider: PathProvider {

private val userHome = System.getProperty("user.home")

override val clipUserPath: Path = getAppSupportPath()

private fun getAppSupportPath(): Path {
val userHome = System.getProperty("user.home")
val appSupportPath = Paths.get(userHome, "Library", "Application Support", "Clipevery")

if (Files.notExists(appSupportPath)) {
Expand All @@ -41,6 +42,16 @@ class MacosPathProvider: PathProvider {
return appSupportPath
}

override val clipLogPath: Path
get() = run {
val appLogsPath = Paths.get(userHome, "Library", "Logs", "Clipevery")

if (Files.notExists(appLogsPath)) {
Files.createDirectories(appLogsPath)
}

return appLogsPath
}
}

class LinuxPathProvider: PathProvider {
Expand Down
Loading