Skip to content

When using FIleSystem.Sink, does the file path need to be complete? #446

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

Closed
BitByAVampire opened this issue Apr 8, 2025 · 5 comments
Closed

Comments

@BitByAVampire
Copy link

BitByAVampire commented Apr 8, 2025

I want to use SystemFileSystem for cross platform ios and android support. does the file path given to the sink method need to be the absolute path that you would get from say on android the androidContext.filesDir, or on ios the FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first

or can i just provide the last path component, ie the filename, and the filesystem picks something for me?

Sorry if this is a dumb question.

@fzhinkin
Copy link
Collaborator

fzhinkin commented Apr 8, 2025

@BitByAVampire, both absolute ("/home/username/directory/subdirectory") and relative ("directory/subdirectory") paths are supported. On almost all platforms (including iOS and Android), relative paths will be resolved against a current working directory (so, for instance, if app's current working directory is /data/private/org.example.app, then the directory/subdirectory path will be resolved to /data/private/org.example.app/directory/subdirectory).

@BitByAVampire
Copy link
Author

BitByAVampire commented Apr 8, 2025

how does the api, eg sink, know whether im providing the absolute or relative path?

@fzhinkin
Copy link
Collaborator

fzhinkin commented Apr 8, 2025

There's a Path.isAbsolute property which reports that information (and Path parses the string with a path to figure that out).

@BitByAVampire
Copy link
Author

BitByAVampire commented Apr 8, 2025

Ok smart. Now is there a way for me to get the full path of the file created if i used the sink with only a relative path?

EDIT: Ah i see resolve method in the api! thanks!

@fzhinkin
Copy link
Collaborator

fzhinkin commented Apr 8, 2025

Yes, you can use SystemFileSystem.resolve().

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

No branches or pull requests

2 participants