Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
02a1a9fd
Commit
02a1a9fd
authored
Jan 11, 2017
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: Move url related function to its own file
parent
63617f2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
22 deletions
+106
-22
Makefile.am
Makefile.am
+2
-0
src/utils/Filename.cpp
src/utils/Filename.cpp
+2
-22
src/utils/Url.cpp
src/utils/Url.cpp
+66
-0
src/utils/Url.h
src/utils/Url.h
+36
-0
No files found.
Makefile.am
View file @
02a1a9fd
...
...
@@ -74,6 +74,7 @@ libmedialibrary_la_SOURCES = \
src/parser/ParserService.cpp
\
src/utils/Filename.cpp
\
src/utils/ModificationsNotifier.cpp
\
src/utils/Url.cpp
\
src/utils/VLCInstance.cpp
\
$(NULL)
...
...
@@ -155,6 +156,7 @@ noinst_HEADERS = \
src/utils/Filename.h
\
src/utils/ModificationsNotifier.h
\
src/utils/SWMRLock.h
\
src/utils/Url.h
\
src/utils/VLCInstance.h
\
src/VideoTrack.h
\
src/compat/Thread.h
\
...
...
src/utils/Filename.cpp
View file @
02a1a9fd
...
...
@@ -25,9 +25,9 @@
#endif
#include "utils/Filename.h"
#include "utils/Url.h"
#include <stdexcept>
#include <cstdlib>
#ifdef _WIN32
#define DIR_SEPARATOR '\\'
...
...
@@ -167,27 +167,7 @@ std::string toLocalPath( const std::string& mrl )
{
if
(
mrl
.
compare
(
0
,
7
,
"file://"
)
!=
0
)
throw
std
::
runtime_error
(
mrl
+
" is not representing a local path"
);
std
::
string
res
;
res
.
reserve
(
mrl
.
size
()
-
7
);
auto
it
=
mrl
.
cbegin
()
+
7
;
auto
ite
=
mrl
.
cend
();
for
(
;
it
!=
ite
;
++
it
)
{
if
(
*
it
==
'%'
)
{
++
it
;
char
hex
[
3
];
if
(
(
hex
[
0
]
=
*
it
)
==
0
||
(
hex
[
1
]
=
*
(
it
+
1
)
)
==
0
)
throw
std
::
runtime_error
(
mrl
+
": Incomplete character sequence"
);
hex
[
2
]
=
0
;
auto
val
=
strtoul
(
hex
,
nullptr
,
16
);
res
.
push_back
(
static_cast
<
std
::
string
::
value_type
>
(
val
)
);
++
it
;
}
else
res
.
push_back
(
*
it
);
}
return
res
;
return
utils
::
url
::
decode
(
mrl
.
substr
(
7
)
);
}
std
::
string
scheme
(
const
std
::
string
&
mrl
)
...
...
src/utils/Url.cpp
0 → 100644
View file @
02a1a9fd
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2017 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "Url.h"
#include <stdexcept>
#include <cstdlib>
namespace
medialibrary
{
namespace
utils
{
namespace
url
{
std
::
string
decode
(
const
std
::
string
&
str
)
{
std
::
string
res
;
res
.
reserve
(
str
.
size
()
);
auto
it
=
str
.
cbegin
();
auto
ite
=
str
.
cend
();
for
(
;
it
!=
ite
;
++
it
)
{
if
(
*
it
==
'%'
)
{
++
it
;
char
hex
[
3
];
if
(
(
hex
[
0
]
=
*
it
)
==
0
||
(
hex
[
1
]
=
*
(
it
+
1
)
)
==
0
)
throw
std
::
runtime_error
(
str
+
": Incomplete character sequence"
);
hex
[
2
]
=
0
;
auto
val
=
strtoul
(
hex
,
nullptr
,
16
);
res
.
push_back
(
static_cast
<
std
::
string
::
value_type
>
(
val
)
);
++
it
;
}
else
res
.
push_back
(
*
it
);
}
return
res
;
}
}
}
}
src/utils/Url.h
0 → 100644
View file @
02a1a9fd
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2017 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <string>
namespace
medialibrary
{
namespace
utils
{
namespace
url
{
std
::
string
decode
(
const
std
::
string
&
str
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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