Changeset View
Changeset View
Standalone View
Standalone View
sftp/kio_sftp.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 60 | { | |||
---|---|---|---|---|---|
71 | sftpProtocol slave(argv[2], argv[3]); | 71 | sftpProtocol slave(argv[2], argv[3]); | ||
72 | slave.dispatchLoop(); | 72 | slave.dispatchLoop(); | ||
73 | 73 | | |||
74 | qCDebug(KIO_SFTP_LOG) << "*** kio_sftp Done"; | 74 | qCDebug(KIO_SFTP_LOG) << "*** kio_sftp Done"; | ||
75 | return 0; | 75 | return 0; | ||
76 | } | 76 | } | ||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | // Converts SSH error into KIO error | 79 | // Converts SSH error into KIO error. Only must be called for error handling | ||
80 | // as this will always return an error state and never NoError. | ||||
80 | static int toKIOError (const int err) | 81 | static int toKIOError (const int err) | ||
81 | { | 82 | { | ||
82 | switch (err) { | 83 | switch (err) { | ||
83 | case SSH_FX_OK: | | |||
84 | break; | | |||
85 | case SSH_FX_NO_SUCH_FILE: | 84 | case SSH_FX_NO_SUCH_FILE: | ||
86 | case SSH_FX_NO_SUCH_PATH: | 85 | case SSH_FX_NO_SUCH_PATH: | ||
87 | return KIO::ERR_DOES_NOT_EXIST; | 86 | return KIO::ERR_DOES_NOT_EXIST; | ||
88 | case SSH_FX_PERMISSION_DENIED: | 87 | case SSH_FX_PERMISSION_DENIED: | ||
89 | return KIO::ERR_ACCESS_DENIED; | 88 | return KIO::ERR_ACCESS_DENIED; | ||
90 | case SSH_FX_FILE_ALREADY_EXISTS: | 89 | case SSH_FX_FILE_ALREADY_EXISTS: | ||
91 | return KIO::ERR_FILE_ALREADY_EXIST; | 90 | return KIO::ERR_FILE_ALREADY_EXIST; | ||
92 | case SSH_FX_INVALID_HANDLE: | 91 | case SSH_FX_INVALID_HANDLE: | ||
93 | return KIO::ERR_MALFORMED_URL; | 92 | return KIO::ERR_MALFORMED_URL; | ||
94 | case SSH_FX_OP_UNSUPPORTED: | 93 | case SSH_FX_OP_UNSUPPORTED: | ||
95 | return KIO::ERR_UNSUPPORTED_ACTION; | 94 | return KIO::ERR_UNSUPPORTED_ACTION; | ||
96 | case SSH_FX_BAD_MESSAGE: | 95 | case SSH_FX_BAD_MESSAGE: | ||
97 | return KIO::ERR_UNKNOWN; | 96 | return KIO::ERR_UNKNOWN; | ||
98 | default: | 97 | default: | ||
99 | return KIO::ERR_INTERNAL; | 98 | return KIO::ERR_INTERNAL; | ||
100 | } | 99 | } | ||
101 | return 0; | 100 | // We should not get here. When this function gets called we've | ||
101 | // encountered an error on the libssh side, this needs to be mapped to *any* | ||||
102 | // KIO error. Not mapping is not an option at this point, even if the ssh err | ||||
103 | // is wrong or 'ok'. | ||||
104 | Q_ASSERT(false); | ||||
broulik: `Q_UNREACHABLE` | |||||
105 | return KIO::ERR_UNKNOWN; | ||||
Actually we can't get here given the default case, only before when the case SSH_FX_OK would fall-through we could broulik: Actually we can't get here given the `default` case, only before when the `case SSH_FX_OK`… | |||||
Yeah. The comment as well as the unreachable /assertion are primarily for future KDE to know not to bring back bad code mappings. sitter: Yeah. The comment as well as the unreachable /assertion are primarily for future KDE to know… | |||||
102 | } | 106 | } | ||
103 | 107 | | |||
104 | // Writes 'len' bytes from 'buf' to the file handle 'fd'. | 108 | // Writes 'len' bytes from 'buf' to the file handle 'fd'. | ||
105 | static int writeToFile(int fd, const char *buf, size_t len) | 109 | static int writeToFile(int fd, const char *buf, size_t len) | ||
106 | { | 110 | { | ||
107 | while (len > 0) { | 111 | while (len > 0) { | ||
108 | ssize_t written = write(fd, buf, len); | 112 | ssize_t written = write(fd, buf, len); | ||
109 | 113 | | |||
▲ Show 20 Lines • Show All 2181 Lines • Show Last 20 Lines |
Q_UNREACHABLE