MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _rym_send_begin

Function _rym_send_begin

components/utilities/ymodem/ry_sy.c:113–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static enum rym_code _rym_send_begin(
114 struct rym_ctx *ctx,
115 rt_uint8_t *buf,
116 rt_size_t len)
117{
118 struct custom_ctx *cctx = (struct custom_ctx *)ctx;
119 struct stat file_buf;
120 char insert_0 = '\0';
121 rt_err_t err;
122
123 cctx->fd = open(cctx->fpath, O_RDONLY);
124 if (cctx->fd < 0)
125 {
126 err = rt_get_errno();
127 rt_kprintf("error open file: %d\n", err);
128 return RYM_ERR_FILE;
129 }
130 rt_memset(buf, 0, len);
131 err = stat(cctx->fpath, &file_buf);
132 if (err != RT_EOK)
133 {
134 rt_kprintf("error open file.\n");
135 return RYM_ERR_FILE;
136 }
137
138 const char *fdst = _get_path_lastname(cctx->fpath);
139 if(fdst != cctx->fpath)
140 {
141 fdst = dfs_normalize_path(RT_NULL, fdst);
142 if (fdst == RT_NULL)
143 {
144 return RYM_ERR_FILE;
145 }
146 }
147
148 rt_sprintf((char *)buf, "%s%c%d", fdst, insert_0, file_buf.st_size);
149
150 return RYM_CODE_SOH;
151}
152
153static enum rym_code _rym_send_data(
154 struct rym_ctx *ctx,

Callers

nothing calls this directly

Calls 8

rt_get_errnoFunction · 0.85
rt_kprintfFunction · 0.85
rt_memsetFunction · 0.85
rt_sprintfFunction · 0.85
statClass · 0.70
_get_path_lastnameFunction · 0.70
openFunction · 0.50
dfs_normalize_pathFunction · 0.50

Tested by

no test coverage detected