Axe unused fd.cpp:read_exact()

This commit is contained in:
наб 2023-11-25 17:42:08 +01:00
parent 1ae0e258a7
commit c651450b5d
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1
3 changed files with 13 additions and 31 deletions

View File

@ -6,70 +6,70 @@ msgstr "Language: pl\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
#: src/fd.cpp:79
#: src/fd.cpp:64
#, c-format
msgid "Passphrase for %s"
msgstr "Hasło do %s"
#: src/fd.cpp:81
#: src/fd.cpp:66
#, c-format
msgid "Passphrase for %s (again)"
msgstr "Powtórz hasło do %s"
#: src/fd.cpp:83
#: src/fd.cpp:68
#, c-format
msgid "New passphrase for %s"
msgstr "Nowe hasło do %s"
#. newkey && again
#: src/fd.cpp:85
#: src/fd.cpp:70
#, c-format
msgid "New passphrase for %s (again)"
msgstr "Powtórz howe hasło do %s"
#. exit status
#: src/fd.cpp:132
#: src/fd.cpp:117
#, c-format
msgid "Helper '%s' failed with %d.\n"
msgstr "'%s' zawiódł: %d.\n"
#: src/fd.cpp:135
#: src/fd.cpp:120
#, c-format
msgid "Helper '%s' died to signal %d: %s.\n"
msgstr "'%s' zabity przez sygnał %d: %s.\n"
#: src/fd.cpp:171
#: src/fd.cpp:156
#, c-format
msgid "Enter passphrase for %s: "
msgstr "Hasło do %s"
#: src/fd.cpp:173
#: src/fd.cpp:158
#, c-format
msgid "Enter passphrase for new %s: "
msgstr "Hasło do nowego %s"
#: src/fd.cpp:175
#: src/fd.cpp:160
#, c-format
msgid "Re-enter passphrase for %s: "
msgstr "Ponownie, hasło do %s"
#. again && newkey
#: src/fd.cpp:177
#: src/fd.cpp:162
#, c-format
msgid "Re-enter passphrase for new %s: "
msgstr "Ponownie, hasło do nowego %s"
#: src/fd.cpp:254 src/fd.cpp:270
#: src/fd.cpp:239 src/fd.cpp:255
#, c-format
msgid "Passphrase too long (max %zu)\n"
msgstr "Hasło za długie (maks. %zu)\n"
#: src/fd.cpp:268
#: src/fd.cpp:253
#, c-format
msgid "Passphrase too short (min %u)\n"
msgstr "Hasło za krótkie (maks. %u)\n"
#: src/fd.cpp:278
#: src/fd.cpp:263
#, c-format
msgid "Provided passphrases do not match.\n"
msgstr "Hasła się różnią\n"

View File

@ -34,21 +34,6 @@ int filled_fd(int & fd, const void * with, size_t with_len) {
}
int read_exact(const char * path, void * data, size_t len) {
auto infd = TRY("open input file", open(path, O_RDONLY | O_CLOEXEC));
quickscope_wrapper infd_deleter{[=] { close(infd); }};
while(len)
if(const auto rd = TRY("read input file", read(infd, data, len))) {
len -= rd;
data = static_cast<char *>(data) + rd;
} else
return fprintf(stderr, "Couldn't read %zu bytes from input file: too short\n", len), __LINE__;
return 0;
}
int write_exact(const char * path, const void * data, size_t len, mode_t mode) {
auto outfd = TRY("create output file", open(path, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode));
quickscope_wrapper outfd_deleter{[=] { close(outfd); }};

View File

@ -29,9 +29,6 @@ int with_stdin_at(int fd, F && what) {
/// with_len may not exceed pipe capacity (64k by default)
extern int filled_fd(int & fd, const void * with, size_t with_len);
/// Read exactly len bytes from path into data, or error
extern int read_exact(const char * path, void * data, size_t len);
/// Write exactly len bytes from data into path, or error
extern int write_exact(const char * path, const void * data, size_t len, mode_t mode);