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
aeb3682f
Commit
aeb3682f
authored
Sep 14, 2016
by
Tycho Andersen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add lxc_deslashify
Signed-off-by:
Tycho Andersen
<
tycho.andersen@canonical.com
>
parent
36662416
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
+18
-0
utils.h
src/lxc/utils.h
+2
-0
No files found.
src/lxc/utils.c
View file @
aeb3682f
...
@@ -716,6 +716,24 @@ char **lxc_normalize_path(const char *path)
...
@@ -716,6 +716,24 @@ char **lxc_normalize_path(const char *path)
return
components
;
return
components
;
}
}
bool
lxc_deslashify
(
char
*
path
)
{
char
**
parts
=
NULL
,
*
path2
;
parts
=
lxc_normalize_path
(
path
);
if
(
!
parts
)
return
false
;
path2
=
lxc_string_join
(
"/"
,
(
const
char
**
)
parts
,
*
path
==
'/'
);
lxc_free_array
((
void
**
)
parts
,
free
);
if
(
!
path2
)
return
false
;
strncpy
(
path
,
path2
,
strlen
(
path
));
free
(
path2
);
return
true
;
}
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
)
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
)
{
{
size_t
len
=
strlen
(
first
)
+
strlen
(
second
)
+
1
;
size_t
len
=
strlen
(
first
)
+
strlen
(
second
)
+
1
;
...
...
src/lxc/utils.h
View file @
aeb3682f
...
@@ -248,6 +248,8 @@ extern char *lxc_string_join(const char *sep, const char **parts, bool use_as_pr
...
@@ -248,6 +248,8 @@ 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
);
/* remove multiple slashes from the path, e.g. ///foo//bar -> /foo/bar */
extern
bool
lxc_deslashify
(
char
*
path
);
extern
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
);
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
...
...
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