Skip to content

Commit 3bea3c7

Browse files
MKD return value is now RFC compliant + Fixed linking against asio (applications don't need to link against it any more) and the FineFTP cmake version
1 parent bda799d commit 3bea3c7

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

fineftp-server/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
cmake_minimum_required(VERSION 3.5.1)
22

33
project(server)
4-
set(PROJECT_VERSION_STRING 0.1.0)
5-
set(PROJECT_VERSION_MAJOR 0)
4+
set(PROJECT_VERSION_STRING 1.0.3)
5+
set(PROJECT_VERSION_MAJOR 1)
6+
set(PROJECT_VERSION_MINOR 0)
7+
set(PROJECT_VERSION_PATCH 3)
68

79
set(CMAKE_CXX_STANDARD 14)
810
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -40,10 +42,12 @@ add_library (fineftp::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
4042

4143
target_link_libraries(${PROJECT_NAME}
4244
PRIVATE
43-
asio::asio
4445
Threads::Threads
4546
)
4647

48+
# Link asio as described in this workaround: https://gitlab.kitware.com/cmake/cmake/-/issues/15415#note_633938
49+
target_link_libraries (${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:asio::asio>)
50+
4751
target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_STANDALONE)
4852
target_compile_definitions(${PROJECT_NAME} PRIVATE __USE_FILE_OFFSET64=1)
4953
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601)

fineftp-server/src/ftp_session.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ namespace fineftp
694694

695695
if (ret == 0)
696696
{
697-
return FtpMessage(FtpReplyCode::PATHNAME_CREATED, "Successfully created directory " + createQuotedFtpPath(local_path));
697+
return FtpMessage(FtpReplyCode::PATHNAME_CREATED, createQuotedFtpPath(toAbsoluateFtpPath(param)) + " Successfully created");
698698
}
699699
else
700700
{
@@ -1065,22 +1065,29 @@ namespace fineftp
10651065
});
10661066
}
10671067

1068-
std::string FtpSession::toLocalPath(const std::string& ftp_path) const
1068+
std::string FtpSession::toAbsoluateFtpPath(const std::string& rel_or_abs_ftp_path) const
10691069
{
1070-
assert(logged_in_user_);
1071-
1072-
// First make the ftp path absolute if it isn't already
10731070
std::string absolute_ftp_path;
10741071

1075-
if (!ftp_path.empty() && (ftp_path[0] == '/'))
1072+
if (!rel_or_abs_ftp_path.empty() && (rel_or_abs_ftp_path[0] == '/'))
10761073
{
1077-
absolute_ftp_path = ftp_path;
1074+
absolute_ftp_path = rel_or_abs_ftp_path;
10781075
}
10791076
else
10801077
{
1081-
absolute_ftp_path = fineftp::Filesystem::cleanPath(ftp_working_directory_ + "/" + ftp_path, false, '/');
1078+
absolute_ftp_path = fineftp::Filesystem::cleanPath(ftp_working_directory_ + "/" + rel_or_abs_ftp_path, false, '/');
10821079
}
10831080

1081+
return absolute_ftp_path;
1082+
}
1083+
1084+
std::string FtpSession::toLocalPath(const std::string& ftp_path) const
1085+
{
1086+
assert(logged_in_user_);
1087+
1088+
// First make the ftp path absolute if it isn't already
1089+
std::string absolute_ftp_path = toAbsoluateFtpPath(ftp_path);
1090+
10841091
// Now map it to the local filesystem
10851092
return fineftp::Filesystem::cleanPathNative(logged_in_user_->local_root_path_ + "/" + absolute_ftp_path);
10861093
}
@@ -1094,7 +1101,7 @@ namespace fineftp
10941101
for (char c : unquoted_ftp_path)
10951102
{
10961103
output.push_back(c);
1097-
if (c == '\"')
1104+
if (c == '\"') // Escape quote by double-quote
10981105
output.push_back(c);
10991106
}
11001107

fineftp-server/src/ftp_session.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ namespace fineftp
142142
// Helpers
143143
////////////////////////////////////////////////////////
144144
private:
145+
std::string toAbsoluateFtpPath(const std::string& rel_or_abs_ftp_path) const;
145146
std::string toLocalPath(const std::string& ftp_path) const;
146147
std::string createQuotedFtpPath(const std::string& unquoted_ftp_path) const;
147148

0 commit comments

Comments
 (0)