Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADDH
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
ntof
daq
ADDH
Commits
9c14956c
Commit
9c14956c
authored
5 years ago
by
Maria Fava
Browse files
Options
Downloads
Patches
Plain Diff
applied modifications
parent
1998a2e6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
filepath
Pipeline
#1562449
passed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ADDHCmd.cpp
+20
-17
20 additions, 17 deletions
src/ADDHCmd.cpp
tests/test_ADDHCmd.cpp
+1
-3
1 addition, 3 deletions
tests/test_ADDHCmd.cpp
with
21 additions
and
20 deletions
src/ADDHCmd.cpp
+
20
−
17
View file @
9c14956c
...
...
@@ -31,8 +31,7 @@ ADDHCmd::ADDHCmd() :
char
hostname
[
_SC_HOST_NAME_MAX
];
gethostname
(
hostname
,
_SC_HOST_NAME_MAX
);
std
::
string
hostnameString
(
hostname
);
this
->
m_filePathPrefix
=
Config
::
instance
().
getValue
(
"outputDirPrefix"
,
std
::
string
());
this
->
m_filePathPrefix
=
Config
::
instance
().
getValue
(
"outputDirPrefix"
,
""
);
}
ADDHCmd
::~
ADDHCmd
()
{}
...
...
@@ -95,23 +94,27 @@ void ADDHCmd::commandReceived(ntof::dim::DIMCmd &cmdData)
bool
ADDHCmd
::
isValidPath
(
const
std
::
string
&
filePath
,
const
std
::
string
&
m_filePathPrefix
)
{
bfs
::
path
absPath
=
filePath
;
if
(
filePath
[
0
]
!=
'/'
)
if
(
m_filePathPrefix
!=
""
)
{
// filePath is relative, convert to m_filePathPrefix/filePath form
absPath
=
m_filePathPrefix
+
"/"
+
filePath
;
}
try
{
absPath
=
bfs
::
canonical
(
absPath
).
string
();
}
catch
(
std
::
exception
const
&
e
)
{
// No such file or directory
return
false
;
bfs
::
path
absPath
=
filePath
;
if
(
filePath
[
0
]
!=
'/'
)
{
// filePath is relative, convert to m_filePathPrefix/filePath form
absPath
=
m_filePathPrefix
+
"/"
+
filePath
;
}
try
{
absPath
=
bfs
::
canonical
(
absPath
).
string
();
}
catch
(
std
::
exception
const
&
e
)
{
// No such file or directory
return
false
;
}
return
(
absPath
.
string
().
compare
(
0
,
m_filePathPrefix
.
length
(),
m_filePathPrefix
)
==
0
);
}
return
(
absPath
.
string
().
compare
(
0
,
m_filePathPrefix
.
length
(),
m_filePathPrefix
)
==
0
);
return
true
;
}
}
// namespace addh
...
...
This diff is collapsed.
Click to expand it.
tests/test_ADDHCmd.cpp
+
1
−
3
View file @
9c14956c
...
...
@@ -77,7 +77,7 @@ public:
void
validatePathCheck
()
{
ADDHCmd
*
addhCmd_
=
new
ADDHCmd
(
);
std
::
shared_ptr
<
ADDHCmd
>
addhCmd_
(
new
ADDHCmd
);
bfs
::
path
correct_prefixed_path
=
m_correct_prefix_dir
/
"correct_path"
;
bfs
::
create_directories
(
correct_prefixed_path
);
...
...
@@ -115,8 +115,6 @@ public:
EQ
(
false
,
addhCmd_
->
isValidPath
(
correct_prefixed_path
.
string
()
+
"/../.."
,
m_correct_prefix_dir
.
string
()));
delete
addhCmd_
;
}
};
...
...
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