Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
dcd19c05
Commit
dcd19c05
authored
3 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Path: use StringView::Split()
parent
109159e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
21 deletions
+8
-21
Path.cxx
src/config/Path.cxx
+8
-21
No files found.
src/config/Path.cxx
View file @
dcd19c05
...
@@ -23,11 +23,10 @@
...
@@ -23,11 +23,10 @@
#include "fs/Traits.hxx"
#include "fs/Traits.hxx"
#include "fs/StandardDirectory.hxx"
#include "fs/StandardDirectory.hxx"
#include "util/RuntimeError.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringView.hxx"
#include <cassert>
#include <cassert>
#include <string.h>
#ifndef _WIN32
#ifndef _WIN32
#include <pwd.h>
#include <pwd.h>
...
@@ -96,30 +95,18 @@ ParsePath(const char *path)
...
@@ -96,30 +95,18 @@ ParsePath(const char *path)
if
(
*
path
==
'\0'
)
if
(
*
path
==
'\0'
)
return
GetConfiguredHome
();
return
GetConfiguredHome
();
AllocatedPath
home
=
nullptr
;
if
(
*
path
==
'/'
)
{
if
(
*
path
==
'/'
)
{
home
=
GetConfiguredHome
();
++
path
;
++
path
;
}
else
{
const
char
*
slash
=
std
::
strchr
(
path
,
'/'
);
const
char
*
end
=
slash
==
nullptr
?
path
+
strlen
(
path
)
:
slash
;
const
std
::
string
user
(
path
,
end
);
home
=
GetHome
(
user
.
c_str
());
if
(
slash
==
nullptr
)
return
GetConfiguredHome
()
/
return
home
;
AllocatedPath
::
FromUTF8Throw
(
path
);
}
else
{
const
auto
[
user
,
rest
]
=
StringView
{
path
}.
Split
(
'/'
);
path
=
slash
+
1
;
return
GetHome
(
std
::
string
{
user
}.
c_str
())
/
AllocatedPath
::
FromUTF8Throw
(
rest
);
}
}
if
(
home
.
IsNull
())
return
nullptr
;
return
home
/
AllocatedPath
::
FromUTF8Throw
(
path
);
}
else
if
(
!
PathTraitsUTF8
::
IsAbsolute
(
path
))
{
}
else
if
(
!
PathTraitsUTF8
::
IsAbsolute
(
path
))
{
throw
FormatRuntimeError
(
"not an absolute path: %s"
,
path
);
throw
FormatRuntimeError
(
"not an absolute path: %s"
,
path
);
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
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