Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
4238632b
Commit
4238632b
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Add a function to convert file attributes to a string.
And use it in the open() args log.
parent
4f65f46a
No related branches found
No related tags found
No related merge requests found
Pipeline
#6052
passed
1 year ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/sftp.cpp
+68
-1
68 additions, 1 deletion
src/sbbs3/sftp.cpp
with
68 additions
and
1 deletion
src/sbbs3/sftp.cpp
+
68
−
1
View file @
4238632b
#include
<iomanip>
#include
<iostream>
#include
<sstream>
#include
<string>
#include
<stdexcept>
#include
<memory>
#include
<vector>
...
...
@@ -489,6 +493,69 @@ public:
}
};
static
std
::
string
sftp_attr_string
(
sftp_file_attr_t
attr
)
{
uint64_t
u64
;
uint32_t
u32
;
sftp_str_t
str
;
std
::
ostringstream
ret
;
std
::
string
rstr
;
try
{
if
(
sftp_fattr_get_size
(
attr
,
&
u64
))
ret
<<
"size="
<<
u64
<<
", "
;
if
(
sftp_fattr_get_uid
(
attr
,
&
u32
))
ret
<<
"uid="
<<
u32
<<
", "
;
if
(
sftp_fattr_get_gid
(
attr
,
&
u32
))
ret
<<
"gid="
<<
u32
<<
", "
;
if
(
sftp_fattr_get_permissions
(
attr
,
&
u32
))
ret
<<
"perm=0"
<<
std
::
oct
<<
u32
<<
", "
<<
std
::
dec
;
/*
* We can't use std::put_time() because apparently std::gmtime_r() isn't
* available on Win32.
*/
if
(
sftp_fattr_get_atime
(
attr
,
&
u32
))
{
struct
tm
t
;
time_t
tt
=
u32
;
if
(
gmtime_r
(
&
tt
,
&
t
))
ret
<<
"atime="
<<
std
::
put_time
(
&
t
,
"%c"
)
<<
u32
<<
", "
;
else
ret
<<
"atime="
<<
u32
<<
", "
;
}
if
(
sftp_fattr_get_mtime
(
attr
,
&
u32
))
{
struct
tm
t
;
time_t
tt
=
u32
;
if
(
gmtime_r
(
&
tt
,
&
t
))
ret
<<
"mtime="
<<
std
::
put_time
(
&
t
,
"%c"
)
<<
u32
<<
", "
;
else
ret
<<
"mtime="
<<
u32
<<
", "
;
}
u32
=
sftp_fattr_get_ext_count
(
attr
);
for
(
uint32_t
idx
=
0
;
idx
<
u32
;
idx
++
)
{
str
=
sftp_fattr_get_ext_type
(
attr
,
idx
);
if
(
str
)
ret
<<
str
->
c_str
<<
"="
;
else
ret
<<
"<null>="
;
free_sftp_str
(
str
);
str
=
sftp_fattr_get_ext_data
(
attr
,
idx
);
if
(
str
)
ret
<<
str
->
c_str
<<
", "
;
else
ret
<<
"<null>, "
;
free_sftp_str
(
str
);
}
std
::
string
rstr
=
ret
.
str
();
if
(
rstr
.
length
()
>
2
)
rstr
.
erase
(
rstr
.
length
()
-
2
);
}
catch
(...)
{
rstr
=
"<error>"
;
// TODO: This could throw as well. :(
}
return
rstr
;
}
static
bool
is_in_filebase
(
const
char
*
path
)
{
...
...
@@ -1315,7 +1382,7 @@ sftp_open(sftp_str_t filename, uint32_t flags, sftp_file_attr_t attributes, void
bool
ret
;
map_path_mode_t
mmode
;
sbbs
->
lprintf
(
LOG_DEBUG
,
"SFTP open(%.*s, %x, )"
,
filename
->
len
,
filename
->
c_str
,
flags
);
sbbs
->
lprintf
(
LOG_DEBUG
,
"SFTP open(%.*s, %x,
%s
)"
,
filename
->
len
,
filename
->
c_str
,
flags
,
sftp_attr_string
(
attributes
).
c_str
()
);
// See if there's an available file descriptor
for
(
fdidx
=
0
;
fdidx
<
nfdes
;
fdidx
++
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment