Skip to content

Commit d98339c

Browse files
sadyrovgouriano
authored andcommitted
Redid formatting without C++20 format. JIRA CXX-13855
git-svn-id: https://anonsvn.ncbi.nlm.nih.gov/repos/v1/trunk/c++@104403 78c7ea69-d796-4a43-9a09-de51944f1b03
1 parent a16cd7c commit d98339c

7 files changed

+44
-38
lines changed

src/connect/CMakeLists.xconnsftp.lib.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ NCBI_begin_lib(xconnsftp SHARED)
44
NCBI_sources(ncbi_sftp)
55
NCBI_add_definitions(NCBI_XCONNSFTP_EXPORTS)
66
NCBI_uses_toolkit_libraries(xncbi)
7-
NCBI_requires(SSH Cxx2020_format_api)
7+
NCBI_requires(SSH)
88
NCBI_project_watchers(sadyrovr)
99
NCBI_end_lib()
1010

src/connect/Makefile.xconnsftp.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SRC = ncbi_sftp
44

55
LIB = xconnsftp
66

7-
REQUIRES = LIBSSH Cxx2020_format_api
7+
REQUIRES = LIBSSH
88

99
LIB_OR_DLL = both
1010

src/connect/ncbi_sftp_impl.hpp

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
#include <corelib/ncbistl.hpp>
3434
#include <corelib/reader_writer.hpp>
3535
#include <corelib/ncbistr.hpp>
36+
#include <corelib/ncbitime.hpp>
3637
#include <connect/ncbi_sftp.hpp>
3738

3839
#ifdef HAVE_SFTP
3940

4041
#include <chrono>
4142
#include <filesystem>
42-
#include <format>
4343
#include <map>
4444
#include <memory>
4545
#include <optional>
@@ -688,7 +688,7 @@ struct SNlstState : SDirReplyState<SNlstState>
688688

689689
string Prepare(sftp_attributes attrs)
690690
{
691-
return *attrs->name == '.' ? ""s : format("{}{}\r\n", m_Path.native(), attrs->name);
691+
return *attrs->name == '.' ? ""s : m_Path.native() + attrs->name + "\r\n"sv;
692692
}
693693

694694
private:
@@ -701,45 +701,51 @@ struct SListState : SDirReplyState<SListState>
701701

702702
string Prepare(sftp_attributes attrs)
703703
{
704-
return *attrs->name == '.' ? ""s : format("{}\r\n", attrs->longname);
704+
return *attrs->name == '.' ? ""s : attrs->longname + "\r\n"s;
705705
}
706706
};
707707

708708
struct SMlsFormat
709709
{
710710
string Prepare(sftp_attributes attrs, const TPath& path = {})
711711
{
712-
return format(
713-
"modify={:%Y%m%d%H%M%S};"
714-
"size={};"
715-
"type={};"
716-
"UNIX.group={};"
717-
"UNIX.groupname={};"
718-
"UNIX.mode=0{:o};"
719-
"UNIX.owner={};"
720-
"UNIX.ownername={};"
721-
" {}{}\n",
722-
chrono::floor<chrono::seconds>(chrono::system_clock::from_time_t(attrs->mtime)),
723-
attrs->size,
724-
x_GetType(attrs->name, attrs->type, path.empty()),
725-
attrs->gid,
726-
attrs->group ? attrs->group : "",
727-
attrs->permissions & 0777,
728-
attrs->uid,
729-
attrs->owner ? attrs->owner : "",
730-
NormalizePath((path / attrs->name).lexically_normal()).native(), path.empty() ? "\r"sv : "");
731-
}
712+
ostringstream os;
713+
os << "modify=" << CTime(attrs->mtime).AsString("YMDhms") <<
714+
";size=" << attrs->size <<
715+
";type=";
732716

733-
private:
734-
string_view x_GetType(string_view name, uint8_t type, bool mlsd)
735-
{
736-
switch (type) {
737-
case SSH_FILEXFER_TYPE_REGULAR: return "file"sv;
738-
case SSH_FILEXFER_TYPE_DIRECTORY: return mlsd && name == "."sv ? "cdir" : mlsd && name == ".."sv ? "pdir"sv : "dir"sv;
739-
case SSH_FILEXFER_TYPE_SYMLINK: return "OS.unix=symlink"sv;
740-
case SSH_FILEXFER_TYPE_SPECIAL: return "special"sv;
741-
default: return "unknown"sv;
717+
switch (attrs->type) {
718+
case SSH_FILEXFER_TYPE_DIRECTORY:
719+
if (path.empty()) {
720+
if (string_view(attrs->name) == "."sv) os << 'c';
721+
if (string_view(attrs->name) == ".."sv) os << 'p';
722+
}
723+
724+
os << "dir";
725+
break;
726+
case SSH_FILEXFER_TYPE_REGULAR: os << "file"; break;
727+
case SSH_FILEXFER_TYPE_SYMLINK: os << "OS.unix=symlink"; break;
728+
case SSH_FILEXFER_TYPE_SPECIAL: os << "special"; break;
729+
default: os << "unknown"; break;
742730
}
731+
732+
os << ";UNIX.group=" << attrs->gid <<
733+
";UNIX.groupname=";
734+
735+
if (attrs->group) os << attrs->group;
736+
737+
os << ";UNIX.mode=0" << oct << (attrs->permissions & 0777) << dec <<
738+
";UNIX.owner=" << attrs->uid <<
739+
";UNIX.ownername=";
740+
741+
if (attrs->owner) os << attrs->owner;
742+
743+
os << "; " << NormalizePath((path / attrs->name).lexically_normal()).native();
744+
745+
if (path.empty()) os << '\r';
746+
747+
os << '\n';
748+
return os.str();
743749
}
744750
};
745751

src/connect/test/CMakeLists.test_ncbi_sftp.app.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
NCBI_begin_app(test_ncbi_sftp)
44
NCBI_sources(test_ncbi_sftp)
5-
NCBI_requires(Boost.Test.Included SSH Cxx2020_format_api)
5+
NCBI_requires(Boost.Test.Included SSH)
66
NCBI_uses_toolkit_libraries(xconnsftp xconnect test_boost)
77
NCBI_project_watchers(sadyrovr)
88
NCBI_add_test()

src/connect/test/Makefile.test_ncbi_sftp.app

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ CPPFLAGS = $(ORIG_CPPFLAGS) $(BOOST_INCLUDE)
88

99
LIBS = $(XCONNSFTP_LIBS) $(NETWORK_LIBS) $(ORIG_LIBS)
1010

11-
REQUIRES = Boost.Test.Included LIBSSH Cxx2020_format_api
11+
REQUIRES = Boost.Test.Included LIBSSH
1212

1313
WATCHERS = sadyrovr

src/sample/app/sftp/CMakeLists.sftp_sample.app.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
NCBI_begin_app(sftp_sample)
44
NCBI_sources(sftp_sample)
5-
NCBI_requires(SSH Cxx2020_format_api)
5+
NCBI_requires(SSH)
66
NCBI_uses_toolkit_libraries(xconnsftp xconnect)
77
NCBI_project_watchers(sadyrovr)
88
NCBI_end_app()

src/sample/app/sftp/Makefile.sftp_sample.app

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ LIB = xconnsftp xconnect xutil xncbi
66

77
LIBS = $(XCONNSFTP_LIBS) $(NETWORK_LIBS) $(ORIG_LIBS)
88

9-
REQUIRES = LIBSSH Cxx2020_format_api
9+
REQUIRES = LIBSSH
1010

1111
WATCHERS = sadyrovr

0 commit comments

Comments
 (0)