Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f0ced708
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f0ced708
编写于
6月 21, 2016
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce virDirOpen
A helper that calls opendir and reports an error if it fails.
上级
bdb86810
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
4 deletion
+32
-4
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/util/virfile.c
src/util/virfile.c
+29
-4
src/util/virfile.h
src/util/virfile.h
+2
-0
未找到文件。
src/libvirt_private.syms
浏览文件 @
f0ced708
...
@@ -1495,6 +1495,7 @@ safezero;
...
@@ -1495,6 +1495,7 @@ safezero;
virBuildPathInternal;
virBuildPathInternal;
virDirClose;
virDirClose;
virDirCreate;
virDirCreate;
virDirOpen;
virDirRead;
virDirRead;
virFileAbsPath;
virFileAbsPath;
virFileAccessibleAs;
virFileAccessibleAs;
...
...
src/util/virfile.c
浏览文件 @
f0ced708
...
@@ -2732,6 +2732,31 @@ virFileRemove(const char *path,
...
@@ -2732,6 +2732,31 @@ virFileRemove(const char *path,
}
}
#endif
/* WIN32 */
#endif
/* WIN32 */
static
int
virDirOpenInternal
(
DIR
**
dirp
,
const
char
*
name
)
{
*
dirp
=
opendir
(
name
);
if
(
!*
dirp
)
{
virReportSystemError
(
errno
,
_
(
"cannot open directory '%s'"
),
name
);
return
-
1
;
}
return
1
;
}
/**
* virDirOpen
* @dirp: directory stream
* @name: path of the directory
*
* Returns 1 on success.
* On failure, -1 is returned and an error is reported.
*/
int
virDirOpen
(
DIR
**
dirp
,
const
char
*
name
)
{
return
virDirOpenInternal
(
dirp
,
name
);
}
/**
/**
* virDirRead:
* virDirRead:
* @dirp: directory to read
* @dirp: directory to read
...
@@ -2740,13 +2765,13 @@ virFileRemove(const char *path,
...
@@ -2740,13 +2765,13 @@ virFileRemove(const char *path,
*
*
* Wrapper around readdir. Typical usage:
* Wrapper around readdir. Typical usage:
* struct dirent ent;
* struct dirent ent;
* int
value
;
* int
rc
;
* DIR *dir;
* DIR *dir;
* if (
!(dir = opendir(name))
)
* if (
virDirOpen(&dir, name) < 0
)
* goto error;
* goto error;
* while ((
value
= virDirRead(dir, &ent, name)) > 0)
* while ((
rc
= virDirRead(dir, &ent, name)) > 0)
* process ent;
* process ent;
* if (
value
< 0)
* if (
rc
< 0)
* goto error;
* goto error;
*
*
* Returns -1 on error, with error already reported if @name was
* Returns -1 on error, with error already reported if @name was
...
...
src/util/virfile.h
浏览文件 @
f0ced708
...
@@ -230,6 +230,8 @@ enum {
...
@@ -230,6 +230,8 @@ enum {
};
};
int
virDirCreate
(
const
char
*
path
,
mode_t
mode
,
uid_t
uid
,
gid_t
gid
,
int
virDirCreate
(
const
char
*
path
,
mode_t
mode
,
uid_t
uid
,
gid_t
gid
,
unsigned
int
flags
)
ATTRIBUTE_RETURN_CHECK
;
unsigned
int
flags
)
ATTRIBUTE_RETURN_CHECK
;
int
virDirOpen
(
DIR
**
dirp
,
const
char
*
dirname
)
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
2
)
ATTRIBUTE_RETURN_CHECK
;
int
virDirRead
(
DIR
*
dirp
,
struct
dirent
**
ent
,
const
char
*
dirname
)
int
virDirRead
(
DIR
*
dirp
,
struct
dirent
**
ent
,
const
char
*
dirname
)
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
2
)
ATTRIBUTE_RETURN_CHECK
;
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
2
)
ATTRIBUTE_RETURN_CHECK
;
void
virDirClose
(
DIR
**
dirp
)
void
virDirClose
(
DIR
**
dirp
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录