forked from Archive/PX4-Autopilot
Merge pull request #1137 from DonLakeFlyer/FTPLogging
Better FTP logging
This commit is contained in:
commit
9a1e920f4b
|
@ -199,13 +199,19 @@ MavlinkFTP::ErrorCode
|
||||||
MavlinkFTP::_workList(Request *req)
|
MavlinkFTP::_workList(Request *req)
|
||||||
{
|
{
|
||||||
auto hdr = req->header();
|
auto hdr = req->header();
|
||||||
DIR *dp = opendir(req->dataAsCString());
|
|
||||||
|
char dirPath[kMaxDataLength];
|
||||||
|
strncpy(dirPath, req->dataAsCString(), kMaxDataLength);
|
||||||
|
|
||||||
|
DIR *dp = opendir(dirPath);
|
||||||
|
|
||||||
if (dp == nullptr) {
|
if (dp == nullptr) {
|
||||||
printf("FTP: can't open path '%s'\n", req->dataAsCString());
|
printf("FTP: can't open path '%s'\n", dirPath);
|
||||||
return kErrNotDir;
|
return kErrNotDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("FTP: list %s offset %d\n", dirPath, hdr->offset);
|
||||||
|
|
||||||
ErrorCode errorCode = kErrNone;
|
ErrorCode errorCode = kErrNone;
|
||||||
struct dirent entry, *result = nullptr;
|
struct dirent entry, *result = nullptr;
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
@ -216,6 +222,7 @@ MavlinkFTP::_workList(Request *req)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// read the directory entry
|
// read the directory entry
|
||||||
if (readdir_r(dp, &entry, &result)) {
|
if (readdir_r(dp, &entry, &result)) {
|
||||||
|
printf("FTP: list %s readdir_r failure\n", dirPath);
|
||||||
errorCode = kErrIO;
|
errorCode = kErrIO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -251,8 +258,8 @@ MavlinkFTP::_workList(Request *req)
|
||||||
|
|
||||||
// copy the name, which we know will fit
|
// copy the name, which we know will fit
|
||||||
strcpy((char *)&hdr->data[offset], entry.d_name);
|
strcpy((char *)&hdr->data[offset], entry.d_name);
|
||||||
|
//printf("FTP: list %s %s\n", dirPath, (char *)&hdr->data[offset-1]);
|
||||||
offset += strlen(entry.d_name) + 1;
|
offset += strlen(entry.d_name) + 1;
|
||||||
printf("FTP: list %s\n", entry.d_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
|
|
Loading…
Reference in New Issue