-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de6f06e
commit 6d85ac4
Showing
14 changed files
with
504 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
app/desktop/src/main/java/dev/schlaubi/tonbrett/app/desktop/NativeUtil.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dev.schlaubi.tonbrett.app.desktop | ||
|
||
import dev.schlaubi.tonbrett.app.desktop.uwp_helper.AppDataRoamingResult.`is_error$get` | ||
import dev.schlaubi.tonbrett.app.desktop.uwp_helper.AppDataRoamingResult.`length$get` | ||
import dev.schlaubi.tonbrett.app.desktop.uwp_helper.UwpHelper.* | ||
import java.lang.foreign.Arena | ||
import java.net.URI | ||
|
||
/** | ||
* Tries to launch the URI using the UWP `Launcher`. | ||
* | ||
* @param uri the [URI] to launch | ||
*/ | ||
fun launchUri(uri: URI) = Arena.openConfined().use { arena -> | ||
val url = arena.allocateUtf8String(uri.toString()) | ||
launch_uri(url) | ||
} | ||
|
||
/** | ||
* Tries to retrieve the current UWP app data folder. | ||
* | ||
* @return the absolute path to the folder | ||
*/ | ||
fun getAppDataRoaming() = Arena.openConfined().use { arena -> | ||
val result = get_app_data_roaming(arena) | ||
val isError = `is_error$get`(result) | ||
val length = `length$get`(result).coerceAtLeast(0) | ||
val buffer = arena.allocateArray(uint16_t, length) | ||
copy_string_from_get_app_data_roaming_result_into_buffer(result, buffer) | ||
val shortArray = buffer.toArray(uint16_t) | ||
val charArray = CharArray(shortArray.size) | ||
for ((index, short) in shortArray.withIndex()) { | ||
charArray[index] = short.toInt().toChar() | ||
} | ||
val string = String(charArray) | ||
if (isError) throw Exception(string) else string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.