Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
24b51482
Commit
24b51482
authored
Sep 12, 2013
by
Christian Seiler
Committed by
Serge Hallyn
Sep 12, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: Add lxc_append_paths to join two paths.
Signed-off-by:
Christian Seiler
<
christian@iwakd.de
>
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
4bee03bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
utils.c
src/lxc/utils.c
+19
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
24b51482
...
@@ -658,6 +658,25 @@ char **lxc_normalize_path(const char *path)
...
@@ -658,6 +658,25 @@ char **lxc_normalize_path(const char *path)
return
components
;
return
components
;
}
}
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
)
{
size_t
len
=
strlen
(
first
)
+
strlen
(
second
)
+
1
;
const
char
*
pattern
=
"%s%s"
;
char
*
result
=
NULL
;
if
(
second
[
0
]
!=
'/'
)
{
len
+=
1
;
pattern
=
"%s/%s"
;
}
result
=
calloc
(
1
,
len
);
if
(
!
result
)
return
NULL
;
snprintf
(
result
,
len
,
pattern
,
first
,
second
);
return
result
;
}
bool
lxc_string_in_list
(
const
char
*
needle
,
const
char
*
haystack
,
char
_sep
)
bool
lxc_string_in_list
(
const
char
*
needle
,
const
char
*
haystack
,
char
_sep
)
{
{
char
*
token
,
*
str
,
*
saveptr
=
NULL
;
char
*
token
,
*
str
,
*
saveptr
=
NULL
;
...
...
src/lxc/utils.h
View file @
24b51482
...
@@ -219,6 +219,7 @@ extern char *lxc_string_join(const char *sep, const char **parts, bool use_as_pr
...
@@ -219,6 +219,7 @@ extern char *lxc_string_join(const char *sep, const char **parts, bool use_as_pr
* foo//bar -> { foo, bar, NULL }
* foo//bar -> { foo, bar, NULL }
*/
*/
extern
char
**
lxc_normalize_path
(
const
char
*
path
);
extern
char
**
lxc_normalize_path
(
const
char
*
path
);
extern
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
);
/* Note: the following two functions use strtok(), so they will never
/* Note: the following two functions use strtok(), so they will never
* consider an empty element, even if two delimiters are next to
* consider an empty element, even if two delimiters are next to
* each other.
* each other.
...
...
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