| 111 | } |
| 112 | |
| 113 | static 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 | |
| 153 | static enum rym_code _rym_send_data( |
| 154 | struct rym_ctx *ctx, |
nothing calls this directly
no test coverage detected