-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For some reason, even though the code itself compiles and works, metadata couldn't compile. This is fixed by more carefully separating which code is compiled for each target, so unneeded code doesn't get included in the Native Android implementation.
- Loading branch information
1 parent
8c0f726
commit bf09f25
Showing
9 changed files
with
78 additions
and
81 deletions.
There are no files selected for viewing
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
File renamed without changes.
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,43 @@ | ||
/* | ||
* Copyright 2019-2023 JetBrains s.r.o. and contributors. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
@file:OptIn(ExperimentalForeignApi::class, UnsafeNumber::class) | ||
package kotlinx.datetime.internal | ||
|
||
import kotlinx.cinterop.* | ||
import platform.posix.* | ||
|
||
internal fun Path.chaseSymlinks(maxDepth: Int = 100): Path { | ||
var realPath = this | ||
var depth = maxDepth | ||
while (true) { | ||
realPath = realPath.readLink() ?: break | ||
if (depth-- == 0) throw RuntimeException("Too many levels of symbolic links") | ||
} | ||
return realPath | ||
} | ||
|
||
internal fun Path.traverseDirectory(exclude: Set<String> = emptySet(), stripLeadingComponents: Int = this.components.size, actionOnFile: (Path) -> Unit) { | ||
val handler = opendir(this.toString()) ?: return | ||
try { | ||
while (true) { | ||
val entry = readdir(handler) ?: break | ||
val name = entry.pointed.d_name.toKString() | ||
if (name == "." || name == "..") continue | ||
if (name in exclude) continue | ||
val path = Path(isAbsolute, components + name) | ||
val info = path.check() ?: continue // skip broken symlinks | ||
if (info.isDirectory) { | ||
if (!info.isSymlink) { | ||
path.traverseDirectory(exclude, stripLeadingComponents, actionOnFile) | ||
} | ||
} else { | ||
actionOnFile(Path(false, path.components.drop(stripLeadingComponents))) | ||
} | ||
} | ||
} finally { | ||
closedir(handler) | ||
} | ||
} |
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
File renamed without changes.
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
File renamed without changes.
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