Skip to content

Commit

Permalink
MKD return value is now RFC compliant + Fixed linking against asio (a…
Browse files Browse the repository at this point in the history
…pplications don't need to link against it any more) and the FineFTP cmake version
  • Loading branch information
FlorianReimold committed Jul 14, 2020
1 parent bda799d commit 3bea3c7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
10 changes: 7 additions & 3 deletions fineftp-server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.5.1)

project(server)
set(PROJECT_VERSION_STRING 0.1.0)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_STRING 1.0.3)
set(PROJECT_VERSION_MAJOR 1)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_PATCH 3)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -40,10 +42,12 @@ add_library (fineftp::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME}
PRIVATE
asio::asio
Threads::Threads
)

# Link asio as described in this workaround: https://gitlab.kitware.com/cmake/cmake/-/issues/15415#note_633938
target_link_libraries (${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:asio::asio>)

target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_STANDALONE)
target_compile_definitions(${PROJECT_NAME} PRIVATE __USE_FILE_OFFSET64=1)
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601)
Expand Down
25 changes: 16 additions & 9 deletions fineftp-server/src/ftp_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ namespace fineftp

if (ret == 0)
{
return FtpMessage(FtpReplyCode::PATHNAME_CREATED, "Successfully created directory " + createQuotedFtpPath(local_path));
return FtpMessage(FtpReplyCode::PATHNAME_CREATED, createQuotedFtpPath(toAbsoluateFtpPath(param)) + " Successfully created");
}
else
{
Expand Down Expand Up @@ -1065,22 +1065,29 @@ namespace fineftp
});
}

std::string FtpSession::toLocalPath(const std::string& ftp_path) const
std::string FtpSession::toAbsoluateFtpPath(const std::string& rel_or_abs_ftp_path) const
{
assert(logged_in_user_);

// First make the ftp path absolute if it isn't already
std::string absolute_ftp_path;

if (!ftp_path.empty() && (ftp_path[0] == '/'))
if (!rel_or_abs_ftp_path.empty() && (rel_or_abs_ftp_path[0] == '/'))
{
absolute_ftp_path = ftp_path;
absolute_ftp_path = rel_or_abs_ftp_path;
}
else
{
absolute_ftp_path = fineftp::Filesystem::cleanPath(ftp_working_directory_ + "/" + ftp_path, false, '/');
absolute_ftp_path = fineftp::Filesystem::cleanPath(ftp_working_directory_ + "/" + rel_or_abs_ftp_path, false, '/');
}

return absolute_ftp_path;
}

std::string FtpSession::toLocalPath(const std::string& ftp_path) const
{
assert(logged_in_user_);

// First make the ftp path absolute if it isn't already
std::string absolute_ftp_path = toAbsoluateFtpPath(ftp_path);

// Now map it to the local filesystem
return fineftp::Filesystem::cleanPathNative(logged_in_user_->local_root_path_ + "/" + absolute_ftp_path);
}
Expand All @@ -1094,7 +1101,7 @@ namespace fineftp
for (char c : unquoted_ftp_path)
{
output.push_back(c);
if (c == '\"')
if (c == '\"') // Escape quote by double-quote
output.push_back(c);
}

Expand Down
1 change: 1 addition & 0 deletions fineftp-server/src/ftp_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ namespace fineftp
// Helpers
////////////////////////////////////////////////////////
private:
std::string toAbsoluateFtpPath(const std::string& rel_or_abs_ftp_path) const;
std::string toLocalPath(const std::string& ftp_path) const;
std::string createQuotedFtpPath(const std::string& unquoted_ftp_path) const;

Expand Down

0 comments on commit 3bea3c7

Please sign in to comment.