Create parent directory when creating database.

This commit is contained in:
Brian Pellin
2009-11-16 10:07:42 -06:00
parent 0d76b4067f
commit 14bf2496e0
3 changed files with 23 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
KeePassDroid (0.9.5)
* Add notification based username and password copy
* Add German translations
* Try to create parent directory when creating database
KeePassdroid (0.9.4)
* Add French translation

View File

@@ -54,8 +54,10 @@
<string name="entry_user_name">User Name: </string>
<string name="error_can_not_handle_uri">KeePassDroid cannot handle this uri.</string>
<string name="error_could_not_create_group">Error creating group.</string>
<string name="error_could_not_create_parent">Could not create parent directory.</string>
<string name="error_database_exists">This file already exists.</string>
<string name="error_database_settings">Failed to determine database settings.</string>
<string name="error_invalid_path">Invalid path.</string>
<string name="error_failed_to_launch_link">Failed to launch link.</string>
<string name="error_filename_required">A filename is required.</string>
<string name="error_file_not_create">Could not create file:</string>

View File

@@ -114,6 +114,25 @@ public class FileSelectActivity extends ListActivity {
Toast.LENGTH_LONG).show();
return;
}
File parent = file.getParentFile();
if ( parent.exists() && ! parent.isDirectory() ) {
Toast.makeText(FileSelectActivity.this,
R.string.error_invalid_path,
Toast.LENGTH_LONG).show();
return;
}
if ( ! parent.exists() ) {
// Create parent dircetory
if ( ! parent.mkdirs() ) {
Toast.makeText(FileSelectActivity.this,
R.string.error_could_not_create_parent,
Toast.LENGTH_LONG).show();
return;
}
}
file.createNewFile();
} catch (IOException e) {