| Index: chrome/browser/ui/views/select_file_dialog_win.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/select_file_dialog_win.cc (revision 144786)
|
| +++ chrome/browser/ui/views/select_file_dialog_win.cc (working copy)
|
| @@ -77,6 +77,13 @@
|
| }
|
| }
|
|
|
| +// Distinguish directories from regular files.
|
| +bool IsDirectory(const FilePath& path) {
|
| + base::PlatformFileInfo file_info;
|
| + return file_util::GetFileInfo(path, &file_info) ?
|
| + file_info.is_directory : file_util::EndsWithSeparator(path);
|
| +}
|
| +
|
| } // namespace
|
|
|
| // This function takes the output of a SaveAs dialog: a filename, a filter and
|
| @@ -332,8 +339,14 @@
|
|
|
| // Set up the initial directory for the dialog.
|
| std::wstring directory;
|
| - if (!suggested_name.empty())
|
| - directory = suggested_path.DirName().value();
|
| + if (!suggested_name.empty()) {
|
| + if (IsDirectory(suggested_path)) {
|
| + directory = suggested_path.value();
|
| + file_part.clear();
|
| + } else {
|
| + directory = suggested_path.DirName().value();
|
| + }
|
| + }
|
|
|
| save_as.lpstrInitialDir = directory.c_str();
|
| save_as.lpstrTitle = NULL;
|
| @@ -762,13 +775,7 @@
|
| FilePath dir;
|
| // Use lpstrInitialDir to specify the initial directory
|
| if (!path->empty()) {
|
| - bool is_dir;
|
| - base::PlatformFileInfo file_info;
|
| - if (file_util::GetFileInfo(*path, &file_info))
|
| - is_dir = file_info.is_directory;
|
| - else
|
| - is_dir = file_util::EndsWithSeparator(*path);
|
| - if (is_dir) {
|
| + if (IsDirectory(*path)) {
|
| ofn.lpstrInitialDir = path->value().c_str();
|
| } else {
|
| dir = path->DirName();
|
|
|