-
Notifications
You must be signed in to change notification settings - Fork 5
Fix copy item functionality and improve path handling #128
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
Merged
patrickkabwe
merged 8 commits into
main
from
fix/copy-item-and-path-handling-improvements
Nov 16, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7106ec2
fix: enable copy item button and improve error handling
patrickkabwe 1da99ea
chore: regenerate bindings after basename signature change
patrickkabwe 5de2c05
fix(android): fix basename syntax and remove ext parameter
patrickkabwe dac8a7a
chore(deps): add react-native-nitro-document-picker dependency
patrickkabwe 73a3a3d
docs: update README and example app to reflect changes in basename fu…
patrickkabwe 55eaa58
fix: improve error handling for path resolution and update dirname me…
patrickkabwe ac0bde0
fix: correct JSX structure in ActionPanel component
patrickkabwe 260725e
fix(android): enhance error handling for file name and extension retr…
patrickkabwe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,14 @@ | ||
| package com.nitrofs | ||
|
|
||
| import com.margelo.nitro.nitrofs.NitroFileStat | ||
| import java.io.File | ||
|
|
||
| fun File.toNitroFileStat(): NitroFileStat { | ||
| return NitroFileStat( | ||
| size = length().toDouble(), | ||
| isFile = isFile, | ||
| isDirectory = isDirectory, | ||
| ctime = lastModified().toDouble(), | ||
| mtime = lastModified().toDouble() | ||
| ) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,57 @@ | ||
| package com.nitrofs | ||
|
|
||
| import android.content.ContentResolver | ||
| import android.content.Context | ||
| import android.net.Uri | ||
| import java.io.File | ||
| import androidx.core.net.toUri | ||
| import java.io.InputStream | ||
| import java.io.OutputStream | ||
|
|
||
| sealed class ResolvedPath { | ||
| data class Content(val uri: Uri) : ResolvedPath() | ||
| data class FilePath(val file: File) : ResolvedPath() | ||
| } | ||
|
|
||
| fun String.toResolvedPath(): ResolvedPath? { | ||
| return when { | ||
| startsWith("content://") || startsWith("file://") -> | ||
| this.toUri().toResolvedPath() | ||
|
|
||
| else -> ResolvedPath.FilePath(File(this)) | ||
| } | ||
| } | ||
|
|
||
| fun Uri.toResolvedPath(): ResolvedPath? { | ||
| return when (scheme) { | ||
| ContentResolver.SCHEME_CONTENT -> | ||
| ResolvedPath.Content(this) | ||
|
|
||
| ContentResolver.SCHEME_FILE -> { | ||
| val p = path ?: return null | ||
| ResolvedPath.FilePath(File(p)) | ||
| } | ||
|
|
||
| else -> null | ||
| } | ||
| } | ||
|
|
||
| fun ResolvedPath.openInputStream(context: Context): InputStream? { | ||
| return when (this) { | ||
| is ResolvedPath.Content -> context.contentResolver.openInputStream(uri) | ||
| is ResolvedPath.FilePath -> if (file.exists()) file.inputStream() else null | ||
| } | ||
| } | ||
|
|
||
| fun ResolvedPath.openOutputStream(context: Context, append: Boolean = false): OutputStream? { | ||
| return when (this) { | ||
| is ResolvedPath.Content -> { | ||
| val mode = if (append) "wa" else "w" | ||
| context.contentResolver.openOutputStream(uri, mode) | ||
| } | ||
| is ResolvedPath.FilePath -> { | ||
| file.parentFile?.mkdirs() | ||
| file.outputStream() | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.