Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions portable-file-dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1234,11 +1234,20 @@ inline internal::file_dialog::file_dialog(type in_type,

if (default_path.size())
{
if (in_type == type::folder || is_directory(default_path))
script += " default location ";
if (in_type == type::save && !is_directory(default_path) && default_path.find("/") != std::string::npos)
{
std::size_t last_slash = default_path.find_last_of("/");
script += " default location " + osascript_quote(default_path.substr(0, last_slash));
script += " default name " + osascript_quote(default_path.substr(last_slash + 1, default_path.length()));
}
else
script += " default name ";
script += osascript_quote(default_path);
{
if (in_type == type::folder || is_directory(default_path))
script += " default location ";
else
script += " default name ";
script += osascript_quote(default_path);
}
}

script += " with prompt " + osascript_quote(title);
Expand Down