Merge pull request #39 from rfjakob/next

Update yes/no prompts. Fixes issue #20
This commit is contained in:
Valient Gough 2014-12-13 19:22:15 -08:00
commit 3643924ba3
2 changed files with 45 additions and 27 deletions

View File

@ -60,11 +60,12 @@ to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
Translating Translating
=========== ===========
EncFS is registered with Rosetta - an online interface for supplying EncFS is registered with Launchpad Translations - an online interface
translations. See https://launchpad.ubuntu.com/rosetta/products/encfs for supplying translations.
See https://translations.launchpad.net/encfs/main/+pots/encfs
If your language is not included in this distribution, you may want If your language is not included in this distribution, you may want
to check if translated text is already available online in Rosetta. to check if translated text is already available online in Launchpad.
If not, consider translating some of the strings, which will then be If not, consider translating some of the strings, which will then be
included in the next EncFS release. included in the next EncFS release.

View File

@ -805,19 +805,51 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
return blockSize; return blockSize;
} }
static bool boolDefaultNo(const char *prompt) { /**
cout << prompt << "\n"; * Prompt the user for a "y" or "n" answer.
cout << _("The default here is No.\n" * An empty answer returns defaultValue.
"Any response that does not begin with 'y' will mean No: "); */
static bool boolDefault(const char *prompt, bool defaultValue) {
char answer[10]; cout << prompt;
char *res = fgets(answer, sizeof(answer), stdin);
cout << "\n"; cout << "\n";
if (res != 0 && tolower(answer[0]) == 'y') string yesno;
return true;
if (defaultValue == true)
yesno = "[y]/n: ";
else else
return false; yesno = "y/[n]: ";
string response;
bool value;
while(true) {
cout << yesno;
getline(cin, response);
if (cin.fail() || response == "") {
value = defaultValue;
break;
} else if (response == "y") {
value = true;
break;
} else if (response == "n") {
value = false;
break;
}
}
cout << "\n";
return value;
}
static bool boolDefaultNo(const char *prompt) {
return boolDefault(prompt, false);
}
static bool boolDefaultYes(const char *prompt) {
return boolDefault(prompt, true);
} }
/** /**
@ -858,21 +890,6 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes) {
*macRandBytes = randSize; *macRandBytes = randSize;
} }
static bool boolDefaultYes(const char *prompt) {
cout << prompt << "\n";
cout << _("The default here is Yes.\n"
"Any response that does not begin with 'n' will mean Yes: ");
char answer[10];
char *res = fgets(answer, sizeof(answer), stdin);
cout << "\n";
if (res != 0 && tolower(answer[0]) == 'n')
return false;
else
return true;
}
/** /**
* Ask the user if per-file unique IVs should be used * Ask the user if per-file unique IVs should be used
*/ */