Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4b5bf004
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4b5bf004
编写于
1月 21, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
1月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9954 from taosdata/feature/tfs
Feature/tfs
上级
aa4a4d05
451740cb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
425 addition
and
8 deletion
+425
-8
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+6
-2
source/libs/tfs/src/tfsTier.c
source/libs/tfs/src/tfsTier.c
+1
-1
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+418
-5
未找到文件。
source/libs/tfs/src/tfs.c
浏览文件 @
4b5bf004
...
...
@@ -118,7 +118,11 @@ int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, SDiskID *pDiskId) {
pDiskId
->
id
=
-
1
;
if
(
pDiskId
->
level
>=
pTfs
->
nlevel
)
{
pDiskId
->
level
--
;
pDiskId
->
level
=
pTfs
->
nlevel
-
1
;
}
if
(
pDiskId
->
level
<
0
)
{
pDiskId
->
level
=
0
;
}
while
(
pDiskId
->
level
>=
0
)
{
...
...
@@ -289,7 +293,7 @@ int32_t tfsRename(STfs *pTfs, char *orname, char *nrname) {
STfsDisk
*
pDisk
=
pTier
->
disks
[
id
];
snprintf
(
oaname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
orname
);
snprintf
(
naname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
nrname
);
if
(
taosRenameFile
(
oaname
,
naname
)
!=
0
)
{
if
(
taosRenameFile
(
oaname
,
naname
)
!=
0
&&
errno
!=
ENOENT
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
fError
(
"failed to rename %s to %s since %s"
,
oaname
,
naname
,
terrstr
());
return
-
1
;
...
...
source/libs/tfs/src/tfsTier.c
浏览文件 @
4b5bf004
...
...
@@ -69,7 +69,7 @@ STfsDisk *tfsMountDiskToTier(STfsTier *pTier, SDiskCfg *pCfg) {
pTier
->
disks
[
id
]
=
pDisk
;
pTier
->
ndisk
++
;
f
Info
(
"disk %s is mounted to tier level %d id %d"
,
pCfg
->
dir
,
pCfg
->
level
,
id
);
f
Debug
(
"disk %s is mounted to tier level %d id %d"
,
pCfg
->
dir
,
pCfg
->
level
,
id
);
return
pTier
->
disks
[
id
];
}
...
...
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
4b5bf004
...
...
@@ -246,20 +246,19 @@ TEST_F(TfsTest, 04_File) {
snprintf
(
fulldir
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
"t3"
);
EXPECT_STREQ
(
dir
,
fulldir
);
EXPECT_
NE
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
EXPECT_
GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
tfsRemoveFile
(
&
f2
);
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
""
);
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"
t3
"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_
STREQ
(
pf1
->
rname
,
"t3"
);
EXPECT_
NE
(
pf1
,
nullptr
);
EXPECT_EQ
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
did
.
level
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
...
...
@@ -270,6 +269,8 @@ TEST_F(TfsTest, 04_File) {
tfsClosedir
(
pDir
);
}
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
...
...
@@ -280,7 +281,9 @@ TEST_F(TfsTest, 04_File) {
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf2
,
nullptr
);
EXPECT_EQ
(
pf2
->
did
.
id
,
0
);
EXPECT_EQ
(
pf2
->
did
.
level
,
0
);
EXPECT_EQ
(
pf2
->
pTfs
,
pTfs
);
const
STfsFile
*
pf3
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf3
,
nullptr
);
...
...
@@ -289,5 +292,415 @@ TEST_F(TfsTest, 04_File) {
}
}
tfsClose
(
pTfs
);
}
TEST_F
(
TfsTest
,
05
_MultiDisk
)
{
int32_t
code
=
0
;
const
char
*
root00
=
"/tmp/tfsTest00"
;
const
char
*
root01
=
"/tmp/tfsTest01"
;
const
char
*
root10
=
"/tmp/tfsTest10"
;
const
char
*
root11
=
"/tmp/tfsTest11"
;
const
char
*
root12
=
"/tmp/tfsTest12"
;
const
char
*
root20
=
"/tmp/tfsTest20"
;
const
char
*
root21
=
"/tmp/tfsTest21"
;
const
char
*
root22
=
"/tmp/tfsTest22"
;
const
char
*
root23
=
"/tmp/tfsTest23"
;
SDiskCfg
dCfg
[
9
]
=
{
0
};
tstrncpy
(
dCfg
[
0
].
dir
,
root01
,
TSDB_FILENAME_LEN
);
dCfg
[
0
].
level
=
0
;
dCfg
[
0
].
primary
=
0
;
tstrncpy
(
dCfg
[
1
].
dir
,
root00
,
TSDB_FILENAME_LEN
);
dCfg
[
1
].
level
=
0
;
dCfg
[
1
].
primary
=
0
;
tstrncpy
(
dCfg
[
2
].
dir
,
root20
,
TSDB_FILENAME_LEN
);
dCfg
[
2
].
level
=
2
;
dCfg
[
2
].
primary
=
0
;
tstrncpy
(
dCfg
[
3
].
dir
,
root21
,
TSDB_FILENAME_LEN
);
dCfg
[
3
].
level
=
2
;
dCfg
[
3
].
primary
=
0
;
tstrncpy
(
dCfg
[
4
].
dir
,
root22
,
TSDB_FILENAME_LEN
);
dCfg
[
4
].
level
=
2
;
dCfg
[
4
].
primary
=
0
;
tstrncpy
(
dCfg
[
5
].
dir
,
root23
,
TSDB_FILENAME_LEN
);
dCfg
[
5
].
level
=
2
;
dCfg
[
5
].
primary
=
0
;
tstrncpy
(
dCfg
[
6
].
dir
,
root10
,
TSDB_FILENAME_LEN
);
dCfg
[
6
].
level
=
1
;
dCfg
[
6
].
primary
=
0
;
tstrncpy
(
dCfg
[
7
].
dir
,
root11
,
TSDB_FILENAME_LEN
);
dCfg
[
7
].
level
=
1
;
dCfg
[
7
].
primary
=
0
;
tstrncpy
(
dCfg
[
8
].
dir
,
root12
,
TSDB_FILENAME_LEN
);
dCfg
[
8
].
level
=
1
;
dCfg
[
8
].
primary
=
0
;
taosRemoveDir
(
root00
);
taosRemoveDir
(
root01
);
taosRemoveDir
(
root10
);
taosRemoveDir
(
root11
);
taosRemoveDir
(
root12
);
taosRemoveDir
(
root20
);
taosRemoveDir
(
root21
);
taosRemoveDir
(
root22
);
taosRemoveDir
(
root23
);
taosMkDir
(
root00
);
taosMkDir
(
root01
);
taosMkDir
(
root10
);
taosMkDir
(
root11
);
taosMkDir
(
root12
);
taosMkDir
(
root20
);
taosMkDir
(
root21
);
taosMkDir
(
root22
);
taosMkDir
(
root23
);
STfs
*
pTfs
=
tfsOpen
(
dCfg
,
9
);
ASSERT_EQ
(
pTfs
,
nullptr
);
dCfg
[
0
].
primary
=
1
;
dCfg
[
1
].
primary
=
1
;
pTfs
=
tfsOpen
(
dCfg
,
9
);
ASSERT_EQ
(
pTfs
,
nullptr
);
dCfg
[
0
].
primary
=
0
;
dCfg
[
1
].
primary
=
1
;
pTfs
=
tfsOpen
(
dCfg
,
9
);
ASSERT_NE
(
pTfs
,
nullptr
);
tfsUpdateSize
(
pTfs
);
SDiskSize
size
=
tfsGetSize
(
pTfs
);
EXPECT_GT
(
size
.
avail
,
0
);
EXPECT_GT
(
size
.
used
,
0
);
EXPECT_GT
(
size
.
total
,
size
.
avail
);
EXPECT_GT
(
size
.
total
,
size
.
used
);
//------------- AllocDisk -----------------//
{
const
char
*
path
=
NULL
;
SDiskID
did
;
did
.
id
=
0
;
did
.
level
=
0
;
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root00
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root01
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root00
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root01
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root00
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root01
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root10
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root11
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
2
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root12
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root10
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root20
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root21
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
2
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root22
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
3
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root23
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root20
);
code
=
tfsAllocDisk
(
pTfs
,
3
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root21
);
code
=
tfsAllocDisk
(
pTfs
,
4
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
2
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root22
);
const
char
*
primary
=
tfsGetPrimaryPath
(
pTfs
);
EXPECT_STREQ
(
primary
,
root00
);
}
//------------- Dir -----------------//
{
char
p1
[]
=
"p1"
;
char
ap00
[
128
]
=
{
0
};
snprintf
(
ap00
,
128
,
"%s%s%s"
,
root00
,
TD_DIRSEP
,
p1
);
char
ap01
[
128
]
=
{
0
};
snprintf
(
ap01
,
128
,
"%s%s%s"
,
root01
,
TD_DIRSEP
,
p1
);
char
ap10
[
128
]
=
{
0
};
snprintf
(
ap10
,
128
,
"%s%s%s"
,
root10
,
TD_DIRSEP
,
p1
);
char
ap11
[
128
]
=
{
0
};
snprintf
(
ap11
,
128
,
"%s%s%s"
,
root11
,
TD_DIRSEP
,
p1
);
char
ap12
[
128
]
=
{
0
};
snprintf
(
ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p1
);
char
ap20
[
128
]
=
{
0
};
snprintf
(
ap20
,
128
,
"%s%s%s"
,
root20
,
TD_DIRSEP
,
p1
);
char
ap21
[
128
]
=
{
0
};
snprintf
(
ap21
,
128
,
"%s%s%s"
,
root21
,
TD_DIRSEP
,
p1
);
char
ap22
[
128
]
=
{
0
};
snprintf
(
ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p1
);
char
ap23
[
128
]
=
{
0
};
snprintf
(
ap23
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
p1
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap00
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap01
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap10
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap11
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap12
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap20
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap21
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap22
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap23
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p1
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
char
p2
[]
=
"p2"
;
char
_ap21
[
128
]
=
{
0
};
snprintf
(
_ap21
,
128
,
"%s%s%s"
,
root21
,
TD_DIRSEP
,
p2
);
SDiskID
did
=
{
0
};
did
.
level
=
2
;
did
.
id
=
1
;
EXPECT_NE
(
taosDirExist
(
_ap21
),
0
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap21
),
0
);
char
p3
[]
=
"p3/p2/p1/p0"
;
char
_ap12
[
128
]
=
{
0
};
snprintf
(
_ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p3
);
did
.
level
=
1
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap12
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
char
p45
[]
=
"p5"
;
char
p44
[]
=
"p4"
;
char
p4
[]
=
"p4/p2/p1/p0"
;
char
_ap22
[
128
]
=
{
0
};
snprintf
(
_ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p4
);
did
.
level
=
2
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
0
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
}
//------------- File -----------------//
{
STfsFile
file0
;
STfsFile
file1
;
STfsFile
file2
;
STfsFile
file3
;
STfsFile
file4
;
SDiskID
did0
=
{
0
};
SDiskID
did1
=
{
0
};
SDiskID
did2
=
{
0
};
SDiskID
did3
=
{
0
};
SDiskID
did4
=
{
0
};
did3
.
id
=
1
;
did4
.
level
=
1
;
tfsInitFile
(
pTfs
,
&
file0
,
did0
,
"fname"
);
tfsInitFile
(
pTfs
,
&
file1
,
did1
,
"fname"
);
tfsInitFile
(
pTfs
,
&
file2
,
did2
,
"fnamex"
);
tfsInitFile
(
pTfs
,
&
file3
,
did3
,
"fname"
);
tfsInitFile
(
pTfs
,
&
file4
,
did4
,
"fname"
);
EXPECT_TRUE
(
tfsIsSameFile
(
&
file0
,
&
file1
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file2
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file3
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file4
));
{
char
n1
[]
=
"t3/t1.json"
;
char
n2
[]
=
"t3/t2.json"
;
STfsFile
f1
=
{
0
};
STfsFile
f2
=
{
0
};
SDiskID
did
;
did1
.
level
=
1
;
did1
.
id
=
2
;
did2
.
level
=
2
;
did2
.
id
=
3
;
tfsInitFile
(
pTfs
,
&
f1
,
did1
,
n1
);
tfsInitFile
(
pTfs
,
&
f2
,
did2
,
n2
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
"t3"
),
0
);
FILE
*
fp
=
fopen
(
f1
.
aname
,
"w"
);
ASSERT_NE
(
fp
,
nullptr
);
fwrite
(
"12345678"
,
1
,
5
,
fp
);
fclose
(
fp
);
char
base
[
128
]
=
{
0
};
tfsBasename
(
&
f1
,
base
);
char
dir
[
128
]
=
{
0
};
tfsDirname
(
&
f1
,
dir
);
EXPECT_STREQ
(
base
,
"t1.json"
);
char
fulldir
[
128
];
snprintf
(
fulldir
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
"t3"
);
EXPECT_STREQ
(
dir
,
fulldir
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
tfsRemoveFile
(
&
f2
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_EQ
(
pf1
->
did
.
level
,
1
);
EXPECT_EQ
(
pf1
->
did
.
id
,
2
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf2
,
nullptr
);
tfsClosedir
(
pDir
);
}
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_GT
(
pf1
->
did
.
level
,
0
);
EXPECT_GT
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_GT
(
pf1
->
did
.
level
,
0
);
EXPECT_GT
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf3
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf3
,
nullptr
);
tfsClosedir
(
pDir
);
}
}
}
tfsClose
(
pTfs
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录