2023_open_source_contest_preliminary_1st_issue3
This commit is contained in:
parent
62d51144e8
commit
06b334d4e0
|
@ -46,7 +46,7 @@ typedef struct ftp_client_struct
|
|||
|
||||
4. 切换目录到 `test`,需要根据实际情况修改。
|
||||
|
||||
5. 根据 10 个文件的文件名进行文件下载,文件内容通过终端打印输出。
|
||||
5. 根据 10 个文件的文件名进行文件下载,根据需求修改 `ftp_downloadfile` 函数对文件的处理为下载保存还是打印输出,为了测试方便此处将文件内容通过终端打印输出。
|
||||
|
||||
6. 关闭 FTP client。
|
||||
|
||||
|
|
|
@ -512,11 +512,18 @@ int ftp_downloadfile(ftp_client *ftp, char *file_name)
|
|||
ret = 0;
|
||||
}
|
||||
|
||||
char name[64];
|
||||
sprintf(name, "/%s", file_name);
|
||||
int f = PrivOpen(name, O_RDWR|O_CREAT);
|
||||
/* Read the file */
|
||||
while(file_size > file_pos) {
|
||||
if (ftp_downloaddata(ftp->data_socket, 10000, filebuf, 128, &getlen) == 0) {
|
||||
if (ftp_downloaddata(ftp->data_socket, 10000, filebuf, 16, &getlen) == 0) {
|
||||
if (getlen) {
|
||||
printf("%s\n", filebuf); // Temporarily process the document as a printout
|
||||
ret = PrivWrite(f, filebuf, strlen(filebuf));
|
||||
if (ret < 0) {
|
||||
printf("write failed,error:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
|
@ -528,7 +535,7 @@ int ftp_downloadfile(ftp_client *ftp, char *file_name)
|
|||
file_pos = file_pos + getlen;
|
||||
}
|
||||
printf("Total length: %d\n", file_pos); // Compare the size of the file previously returned by the server
|
||||
|
||||
PrivClose(f);
|
||||
__exit:
|
||||
if(ftp->data_socket >= 0)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,8 @@ void TestFtpClient() {
|
|||
lwip_config_tcp(0, self_ipaddr, self_netmask, self_gwaddr);
|
||||
|
||||
/* Use the appropriate username and password as login parameters */
|
||||
ftp_client *f = ftp_login("192.168.130.78", "why", "7355");
|
||||
ftp_client *f = ftp_login("192.168.130.78", "anonymous", "anonymous");
|
||||
if (f == NULL) return;
|
||||
|
||||
/* Choosing the right path */
|
||||
ftp_changedir(f, "test");
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
time_t time(time_t *t)
|
||||
{
|
||||
NULL_PARAM_CHECK(t);
|
||||
if (NULL == t) {
|
||||
return 0;
|
||||
}
|
||||
time_t current = 0;
|
||||
|
||||
#ifdef RESOURCES_RTC
|
||||
|
|
Loading…
Reference in New Issue