Skip to content

Commit

Permalink
Update proto, clean up server
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes committed Aug 21, 2023
1 parent 3b156ab commit 0012fe4
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 2,368 deletions.
2 changes: 1 addition & 1 deletion proto
13 changes: 7 additions & 6 deletions src/mavsdk/core/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "fs.h"
#include "filesystem_include.h"
#include "log.h"
#include "unused.h"

#ifndef PATH_MAX
#define PATH_MAX 4096
Expand All @@ -26,10 +27,9 @@

namespace mavsdk {

bool fs_exists(const std::string& filename)
bool fs_exists(const fs::path& path)
{
struct stat buffer;
return (stat(filename.c_str(), &buffer) == 0);
return fs::exists(path);
}

uint32_t fs_file_size(const std::string& filename)
Expand Down Expand Up @@ -115,10 +115,11 @@ bool fs_create_directory(const std::string& path)
return (mkdir(path.c_str(), (S_IRWXU | S_IRWXG | S_IRWXO)) == 0);
}

bool fs_remove(const std::string& path)
bool fs_remove(const fs::path& path)
{
LogWarn() << "Removing file: " << path;
return (remove(path.c_str()) == 0);
std::error_code ec;
return fs::remove(path, ec);
UNUSED(ec);
}

bool fs_rename(const std::string& old_name, const std::string& new_name)
Expand Down
9 changes: 6 additions & 3 deletions src/mavsdk/core/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <string>
#include <optional>
#include <cstdint>
#include <filesystem>

namespace fs = std::filesystem;

namespace mavsdk {

Expand All @@ -12,7 +15,7 @@ const std::string path_separator = "\\";
const std::string path_separator = "/";
#endif

bool fs_exists(const std::string& filename);
bool fs_exists(const fs::path& filename);

uint32_t fs_file_size(const std::string& filename);

Expand All @@ -22,10 +25,10 @@ std::string fs_canonical(const std::string& path);

bool fs_create_directory(const std::string& path);

bool fs_remove(const std::string& path);
bool fs_remove(const fs::path& path);

bool fs_rename(const std::string& old_name, const std::string& new_name);

std::optional<std::string> create_tmp_directory(const std::string& prefix);

} // namespace mavsdk
} // namespace mavsdk
Loading

0 comments on commit 0012fe4

Please sign in to comment.