mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[eel] EelPath: add helper functions
GitOrigin-RevId: e7755f3826ed8c6b0fa71279b4a9a55a03fc3925
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8ff7aa9802
commit
3a6c75410b
@@ -6,8 +6,16 @@ import com.intellij.platform.eel.EelUserPosixInfo
|
||||
import com.intellij.platform.eel.EelUserWindowsInfo
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.StatError
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import com.intellij.platform.eel.path.EelPathResult
|
||||
import java.nio.ByteBuffer
|
||||
import kotlin.Throws
|
||||
|
||||
fun EelFileSystemApi.getPath(string: String): EelPathResult<out EelPath.Absolute> {
|
||||
return EelPath.Absolute.parse(string, when (this) {
|
||||
is EelFileSystemPosixApi -> EelPath.Absolute.OS.UNIX
|
||||
is EelFileSystemWindowsApi -> EelPath.Absolute.OS.WINDOWS
|
||||
else -> throw UnsupportedOperationException("Unsupported OS: ${this::class.java}")
|
||||
})
|
||||
}
|
||||
|
||||
// TODO Integrate case-(in)sensitiveness into the interface.
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.eel.provider.utils
|
||||
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import com.intellij.platform.eel.path.EelPathResult
|
||||
|
||||
fun <T : EelPath> EelPathResult<T>.unwrap(): T {
|
||||
return when (this) {
|
||||
is EelPathResult.Ok -> path
|
||||
is EelPathResult.Err -> throw RuntimeException(reason)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user