Return error if path not exists when sending image and file.
This commit is contained in:
parent
6bc96c58d2
commit
aa3703e9f5
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@ -37,6 +38,8 @@
|
|||||||
#define BASE_URL "tcp://0.0.0.0"
|
#define BASE_URL "tcp://0.0.0.0"
|
||||||
#define G_BUF_SIZE (16 * 1024 * 1024)
|
#define G_BUF_SIZE (16 * 1024 * 1024)
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
extern int IsLogin(void); // Defined in spy.cpp
|
extern int IsLogin(void); // Defined in spy.cpp
|
||||||
|
|
||||||
bool gIsListening = false;
|
bool gIsListening = false;
|
||||||
@ -251,6 +254,9 @@ bool func_send_img(char *path, char *receiver, uint8_t *out, size_t *len)
|
|||||||
if ((path == NULL) || (receiver == NULL)) {
|
if ((path == NULL) || (receiver == NULL)) {
|
||||||
LOG_ERROR("Empty path or receiver.");
|
LOG_ERROR("Empty path or receiver.");
|
||||||
rsp.msg.status = -1;
|
rsp.msg.status = -1;
|
||||||
|
} else if (!fs::exists(path)) {
|
||||||
|
LOG_ERROR("Path does not exists: {}", path);
|
||||||
|
rsp.msg.status = -2;
|
||||||
} else {
|
} else {
|
||||||
SendImageMessage(receiver, path);
|
SendImageMessage(receiver, path);
|
||||||
rsp.msg.status = 0;
|
rsp.msg.status = 0;
|
||||||
@ -275,6 +281,9 @@ bool func_send_file(char *path, char *receiver, uint8_t *out, size_t *len)
|
|||||||
if ((path == NULL) || (receiver == NULL)) {
|
if ((path == NULL) || (receiver == NULL)) {
|
||||||
LOG_ERROR("Empty path or receiver.");
|
LOG_ERROR("Empty path or receiver.");
|
||||||
rsp.msg.status = -1;
|
rsp.msg.status = -1;
|
||||||
|
} else if (!fs::exists(path)) {
|
||||||
|
LOG_ERROR("Path does not exists: {}", path);
|
||||||
|
rsp.msg.status = -2;
|
||||||
} else {
|
} else {
|
||||||
SendImageMessage(receiver, path);
|
SendImageMessage(receiver, path);
|
||||||
rsp.msg.status = 0;
|
rsp.msg.status = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user