Skip to content

Conversation

Kbz-8
Copy link

@Kbz-8 Kbz-8 commented Jun 30, 2025

Just a small PR to be able to do things like :

let mut path = std::env::home_dir().expect("nah");
path.push(".local/share/myapp/");
dioxus_storage::set_dir!(path);

I am not sure about the dioxus versions bump tho.

@Kbz-8
Copy link
Author

Kbz-8 commented Jul 16, 2025

up !

@chunleng
Copy link

I am faced with the situation where Android doesn't work because the default is not writing to an accessible path. (Not sure if it's related to this issue)

This PR will definitely be a good workaround so that a correct path derived programatically can be included

#[cfg(not(target_family = "wasm"))]
$crate::set_directory(std::path::PathBuf::from($path))
};
($path:expr) => {

Choose a reason for hiding this comment

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

Rather than having an expr to be used freely on set_directory, why not just extend the current $path:literal to use an expr?

Something like

    ($path: expr) => {
        #[cfg(not(target_family = "wasm"))]
        $crate::storage::set_directory(std::path::PathBuf::from(format!("{}", $path)))
    };

Copy link
Author

Choose a reason for hiding this comment

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

wouldn't it force users to do dioxus_storage::set_dir!(path.display()); ?

Copy link
Member

@ealmloff ealmloff Sep 3, 2025

Choose a reason for hiding this comment

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

std::path::PathBuf::from($path) should work with Paths, PathBufs and &strs

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.

3 participants