MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ftp_read_dir

Function ftp_read_dir

libavformat/ftp.c:1055–1100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1053}
1054
1055static int ftp_read_dir(URLContext *h, AVIODirEntry **next)
1056{
1057 FTPContext *s = h->priv_data;
1058 char *start, *found;
1059 int ret, retried;
1060
1061 do {
1062 retried = 0;
1063 start = s->dir_buffer + s->dir_buffer_offset;
1064 while (!(found = strstr(start, "\n"))) {
1065 if (retried)
1066 return AVERROR(EIO);
1067 s->dir_buffer_size -= s->dir_buffer_offset;
1068 s->dir_buffer_offset = 0;
1069 if (s->dir_buffer_size)
1070 memmove(s->dir_buffer, start, s->dir_buffer_size);
1071 ret = ffurl_read(s->conn_data, s->dir_buffer + s->dir_buffer_size, DIR_BUFFER_SIZE - (s->dir_buffer_size + 1));
1072 if (ret < 0)
1073 return ret;
1074 if (!ret) {
1075 *next = NULL;
1076 return 0;
1077 }
1078 s->dir_buffer_size += ret;
1079 s->dir_buffer[s->dir_buffer_size] = 0;
1080 start = s->dir_buffer;
1081 retried = 1;
1082 }
1083 s->dir_buffer_offset += (found + 1 - start);
1084 found[0] = 0;
1085 if (found > start && found[-1] == '\r')
1086 found[-1] = 0;
1087
1088 *next = ff_alloc_dir_entry();
1089 if (!*next)
1090 return AVERROR(ENOMEM);
1091 (*next)->utf8 = s->utf8;
1092 ret = ftp_parse_entry(h, start, *next);
1093 if (ret) {
1094 avio_free_directory_entry(next);
1095 if (ret < 0)
1096 return ret;
1097 }
1098 } while (ret > 0);
1099 return 0;
1100}
1101
1102static int ftp_close_dir(URLContext *h)
1103{

Callers

nothing calls this directly

Calls 4

ffurl_readFunction · 0.85
ff_alloc_dir_entryFunction · 0.85
ftp_parse_entryFunction · 0.85

Tested by

no test coverage detected