Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
78779952
Commit
78779952
authored
Feb 14, 2018
by
Hugo Beauzée-Luyssen
Browse files
utils: Fix removePath return value when path is not found
parent
1ee15d32
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/utils/Filename.cpp
View file @
78779952
...
...
@@ -151,7 +151,10 @@ std::string removePath( const std::string& fullPath, const std::string& toRemove
{
if
(
toRemove
.
length
()
==
0
)
return
fullPath
;
auto
pos
=
fullPath
.
find
(
toRemove
)
+
toRemove
.
length
();
auto
pos
=
fullPath
.
find
(
toRemove
);
if
(
pos
==
std
::
string
::
npos
)
return
fullPath
;
pos
+=
toRemove
.
length
();
while
(
fullPath
[
pos
]
==
DIR_SEPARATOR
#ifdef _WIN32
||
fullPath
[
pos
]
==
'/'
...
...
test/unittest/FsUtilsTests.cpp
View file @
78779952
...
...
@@ -93,6 +93,7 @@ TEST( FsUtils, removePath )
ASSERT_EQ
(
"bar"
,
utils
::
file
::
removePath
(
"bar"
,
""
)
);
ASSERT_EQ
(
""
,
utils
::
file
::
removePath
(
"bar/"
,
"bar"
)
);
ASSERT_EQ
(
""
,
utils
::
file
::
removePath
(
"/f00/"
,
"/f00/"
)
);
ASSERT_EQ
(
"/f00"
,
utils
::
file
::
removePath
(
"/f00"
,
"/path/not/found"
)
);
}
TEST
(
FsUtils
,
parentFolder
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment