Skip to content

Add file_list to Get interface #179

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
merged 5 commits into from
Mar 23, 2025
Merged

Conversation

Gae24
Copy link
Contributor

@Gae24 Gae24 commented Feb 25, 2025

Opening as a draft since osx and wayland are still to do.
While Windows would simply return file paths, X11 returns a uri-list, should we maybe decide a single format to use in all platforms?
Close #51

@complexspaces
Copy link
Collaborator

complexspaces commented Feb 26, 2025

I think it would probably be best if we returned PathBuf in these APIs, so is it possible to normalize the Linux contents across the various implementations (ie do they use a standard URI scheme)? On macOS NSUrl lets you extract a path out of it.

As a secondary question: Do I understand that the primary use case for this is to receive a list of file paths that have been drag-and-dropped into an app's window? So for macOS we'd be looking for NSPasteboardTypeFileURL?

@Gae24
Copy link
Contributor Author

Gae24 commented Feb 26, 2025

Not just for drag and drop, e.g. when trying to copy a file from file explorer, this is the data placed in the clipboard.

@complexspaces
Copy link
Collaborator

Ah right, thanks for clarifying 👍.

@Gae24 Gae24 force-pushed the file-list branch 2 times, most recently from 255ad9d to cd2efdd Compare March 7, 2025 09:40
@Gae24
Copy link
Contributor Author

Gae24 commented Mar 7, 2025

I can't test osx code, so I would like to know if like on Linux file paths are prefixed with file://.

@complexspaces
Copy link
Collaborator

I tested the OSX code this morning using a modified example and confirmed it returns file paths, with no prefixes:

[
"/Applications/Keynote.app", 
"/System/Applications/Maps.app", 
"/System/Applications/Messages.app",
"/System/Applications/Notes.app", 
"/Applications/Pages.app"
]

This is because you're using the .path() method on NSUrl which is doing what we want.

@Gae24
Copy link
Contributor Author

Gae24 commented Mar 9, 2025

Thank you for testing

@Gae24 Gae24 marked this pull request as ready for review March 9, 2025 15:32
@Gae24
Copy link
Contributor Author

Gae24 commented Mar 11, 2025

Upon further testing on Linux, since file paths are exposed as text/uri-list they are percent encoded.
I think we should decode them, we can use percent-encoding.
Does macOS has the same behaviour?

@complexspaces
Copy link
Collaborator

I think we should decode them, we can use percent-encoding.

That sounds good to me.

Does macOS has the same behaviour?

No, the path function handles converting these to normal characters instead of URL encoded ones. For example this is noted in Apple's documentation:

This property contains the path, unescaped using the stringByReplacingPercentEscapesUsingEncoding: method. If the receiver does not conform to RFC 1808, this property contains nil.

Copy link
Collaborator

@complexspaces complexspaces left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, this looks good now.

Thanks for the work!

@complexspaces complexspaces merged commit 1dcc18b into 1Password:master Mar 23, 2025
11 checks passed
@complexspaces
Copy link
Collaborator

Released in v3.5.0 on crates.io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files & directories support by path
2 participants