Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a47e778b
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a47e778b
编写于
1月 15, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1207
上级
7256bd99
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
152 addition
and
30 deletion
+152
-30
src/os/src/darwin/darwinFile.c
src/os/src/darwin/darwinFile.c
+34
-4
src/os/src/detail/osFile.c
src/os/src/detail/osFile.c
+0
-4
src/os/src/windows/wFile.c
src/os/src/windows/wFile.c
+104
-19
src/os/src/windows/wSysinfo.c
src/os/src/windows/wSysinfo.c
+14
-3
未找到文件。
src/os/src/darwin/darwinFile.c
浏览文件 @
a47e778b
...
...
@@ -51,7 +51,37 @@ int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t co
return
writeLen
;
}
int64_t
taosSendFile
(
int32_t
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
size
)
{
uError
(
"taosSendFile not implemented yet"
);
return
-
1
;
}
\ No newline at end of file
int64_t
taosSendFile
(
SOCKET
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
count
)
{
lseek
(
sfd
,
(
int32_t
)(
*
offset
),
0
);
int64_t
writeLen
=
0
;
uint8_t
buffer
[
_SEND_FILE_STEP_
]
=
{
0
};
for
(
int64_t
len
=
0
;
len
<
(
count
-
_SEND_FILE_STEP_
);
len
+=
_SEND_FILE_STEP_
)
{
int32_t
rlen
=
(
int32_t
)
read
(
sfd
,
buffer
,
_SEND_FILE_STEP_
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
if
(
rlen
<
_SEND_FILE_STEP_
)
{
taosWriteSocket
(
dfd
,
buffer
,
rlen
);
return
(
int64_t
)(
writeLen
+
rlen
);
}
else
{
taosWriteSocket
(
dfd
,
buffer
,
_SEND_FILE_STEP_
);
writeLen
+=
_SEND_FILE_STEP_
;
}
}
int64_t
remain
=
count
-
writeLen
;
if
(
remain
>
0
)
{
int32_t
rlen
=
read
(
sfd
,
buffer
,
(
int32_t
)
remain
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
{
taosWriteSocket
(
sfd
,
buffer
,
(
int32_t
)
remain
);
writeLen
+=
remain
;
}
}
return
writeLen
;
}
src/os/src/detail/osFile.c
浏览文件 @
a47e778b
...
...
@@ -126,10 +126,6 @@ int64_t taosSendFile(SOCKET dfd, int32_t sfd, int64_t *offset, int64_t size) {
int64_t
sentbytes
;
while
(
leftbytes
>
0
)
{
/*
* TODO : Think to check if file is larger than 1GB
*/
// if (leftbytes > 1000000000) leftbytes = 1000000000;
sentbytes
=
sendfile
(
dfd
,
sfd
,
offset
,
leftbytes
);
if
(
sentbytes
==
-
1
)
{
if
(
errno
==
EINTR
||
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
...
...
src/os/src/windows/wFile.c
浏览文件 @
a47e778b
...
...
@@ -15,18 +15,19 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "
tulog
.h"
#include "
osSocket
.h"
#include "tglobal.h"
#include "tulog.h"
void
taosGetTmpfilePath
(
const
char
*
fileNamePrefix
,
char
*
dstPath
)
{
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
char
tmpPath
[
PATH_MAX
];
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
char
tmpPath
[
PATH_MAX
];
int32_t
len
=
(
int32_t
)
strlen
(
tsTempDir
);
memcpy
(
tmpPath
,
tsTempDir
,
len
);
if
(
tmpPath
[
len
-
1
]
!=
'/'
&&
tmpPath
[
len
-
1
]
!=
'\\'
)
{
tmpPath
[
len
++
]
=
'\\'
;
tmpPath
[
len
++
]
=
'\\'
;
}
strcpy
(
tmpPath
+
len
,
tdengineTmpFileNamePrefix
);
...
...
@@ -35,7 +36,7 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat
(
tmpPath
,
fileNamePrefix
);
strcat
(
tmpPath
,
"-%d-%s"
);
}
char
rand
[
8
]
=
{
0
};
taosRandStr
(
rand
,
tListLen
(
rand
)
-
1
);
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
rand
);
...
...
@@ -46,18 +47,16 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
int64_t
taosFSendFile
(
FILE
*
out_file
,
FILE
*
in_file
,
int64_t
*
offset
,
int64_t
count
)
{
fseek
(
in_file
,
(
int32_t
)(
*
offset
),
0
);
int64_t
writeLen
=
0
;
uint8_t
buffer
[
_SEND_FILE_STEP_
]
=
{
0
};
uint8_t
buffer
[
_SEND_FILE_STEP_
]
=
{
0
};
for
(
int64_t
len
=
0
;
len
<
(
count
-
_SEND_FILE_STEP_
);
len
+=
_SEND_FILE_STEP_
)
{
size_t
rlen
=
fread
(
buffer
,
1
,
_SEND_FILE_STEP_
,
in_file
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
if
(
rlen
<
_SEND_FILE_STEP_
)
{
}
else
if
(
rlen
<
_SEND_FILE_STEP_
)
{
fwrite
(
buffer
,
1
,
rlen
,
out_file
);
return
(
int64_t
)(
writeLen
+
rlen
);
}
else
{
}
else
{
fwrite
(
buffer
,
1
,
_SEND_FILE_STEP_
,
in_file
);
writeLen
+=
_SEND_FILE_STEP_
;
}
...
...
@@ -65,12 +64,43 @@ int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t co
int64_t
remain
=
count
-
writeLen
;
if
(
remain
>
0
)
{
size_t
rlen
=
fread
(
buffer
,
1
,
(
size_t
)
remain
,
in_file
);
size_t
rlen
=
fread
(
buffer
,
1
,
(
size_t
)
remain
,
in_file
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
{
fwrite
(
buffer
,
1
,
(
size_t
)
remain
,
out_file
);
writeLen
+=
remain
;
}
else
{
fwrite
(
buffer
,
1
,
(
size_t
)
remain
,
out_file
);
}
return
writeLen
;
}
int64_t
taosSendFile
(
SOCKET
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
count
)
{
lseek
(
sfd
,
(
int32_t
)(
*
offset
),
0
);
int64_t
writeLen
=
0
;
uint8_t
buffer
[
_SEND_FILE_STEP_
]
=
{
0
};
for
(
int64_t
len
=
0
;
len
<
(
count
-
_SEND_FILE_STEP_
);
len
+=
_SEND_FILE_STEP_
)
{
int32_t
rlen
=
(
int32_t
)
read
(
sfd
,
buffer
,
_SEND_FILE_STEP_
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
if
(
rlen
<
_SEND_FILE_STEP_
)
{
taosWriteSocket
(
dfd
,
buffer
,
rlen
);
return
(
int64_t
)(
writeLen
+
rlen
);
}
else
{
taosWriteSocket
(
dfd
,
buffer
,
_SEND_FILE_STEP_
);
writeLen
+=
_SEND_FILE_STEP_
;
}
}
int64_t
remain
=
count
-
writeLen
;
if
(
remain
>
0
)
{
int32_t
rlen
=
read
(
sfd
,
buffer
,
(
int32_t
)
remain
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
{
taosWriteSocket
(
sfd
,
buffer
,
(
int32_t
)
remain
);
writeLen
+=
remain
;
}
}
...
...
@@ -78,12 +108,67 @@ int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t co
return
writeLen
;
}
int64_t
taosSendFile
(
SOCKET
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
size
)
{
uError
(
"taosSendFile no implemented yet"
);
int32_t
taosFtruncate
(
int32_t
fd
,
int64_t
l_size
)
{
if
(
fd
<
0
)
{
errno
=
EBADF
;
uError
(
"%s
\n
"
,
"fd arg was negative"
);
return
-
1
;
}
HANDLE
h
=
(
HANDLE
)
_get_osfhandle
(
fd
);
LARGE_INTEGER
li_0
;
li_0
.
QuadPart
=
(
int64_t
)
0
;
BOOL
cur
=
SetFilePointerEx
(
h
,
li_0
,
NULL
,
FILE_CURRENT
);
if
(
!
cur
)
{
uError
(
"SetFilePointerEx Error getting current position in file.
\n
"
);
return
-
1
;
}
LARGE_INTEGER
li_size
;
li_size
.
QuadPart
=
l_size
;
BOOL
cur2
=
SetFilePointerEx
(
h
,
li_size
,
NULL
,
FILE_BEGIN
);
if
(
cur2
==
0
)
{
int
error
=
GetLastError
();
uError
(
"SetFilePointerEx GetLastError is: %d
\n
"
,
error
);
switch
(
error
)
{
case
ERROR_INVALID_HANDLE
:
errno
=
EBADF
;
break
;
default:
errno
=
EIO
;
break
;
}
return
-
1
;
}
if
(
!
SetEndOfFile
(
h
))
{
int
error
=
GetLastError
();
uError
(
"SetEndOfFile GetLastError is:%d"
,
error
);
switch
(
error
)
{
case
ERROR_INVALID_HANDLE
:
errno
=
EBADF
;
break
;
default:
errno
=
EIO
;
break
;
}
return
-
1
;
}
return
0
;
}
int32_t
taosFtruncate
(
int32_t
fd
,
int64_t
length
)
{
uError
(
"taosFtruncate no implemented yet"
);
int
fsync
(
int
filedes
)
{
if
(
filedes
<
0
)
{
errno
=
EBADF
;
uError
(
"%s
\n
"
,
"fd arg was negative"
);
return
-
1
;
}
HANDLE
h
=
(
HANDLE
)
_get_osfhandle
(
filedes
);
FlushFileBuffers
(
h
);
return
0
;
}
\ No newline at end of file
}
src/os/src/windows/wSysinfo.c
浏览文件 @
a47e778b
...
...
@@ -31,6 +31,8 @@
#pragma comment(lib, "Mswsock.lib ")
#endif
#include <objbase.h>
#pragma warning(push)
#pragma warning(disable : 4091)
#include <DbgHelp.h>
...
...
@@ -233,8 +235,6 @@ int taosSystem(const char *cmd) {
int
flock
(
int
fd
,
int
option
)
{
return
0
;
}
int
fsync
(
int
filedes
)
{
return
0
;
}
int
sigaction
(
int
sig
,
struct
sigaction
*
d
,
void
*
p
)
{
return
0
;
}
LONG
WINAPI
FlCrashDump
(
PEXCEPTION_POINTERS
ep
)
{
...
...
@@ -276,7 +276,18 @@ LONG WINAPI FlCrashDump(PEXCEPTION_POINTERS ep) {
void
taosSetCoreDump
()
{
SetUnhandledExceptionFilter
(
&
FlCrashDump
);
}
bool
taosGetSystemUid
(
char
*
uid
)
{
sprintf
(
uid
,
"uid_not_implemented_yet"
);
GUID
guid
;
CoCreateGuid
(
&
guid
);
sprintf
(
uid
,
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"
,
guid
.
Data1
,
guid
.
Data2
,
guid
.
Data3
,
guid
.
Data4
[
0
],
guid
.
Data4
[
1
],
guid
.
Data4
[
2
],
guid
.
Data4
[
3
],
guid
.
Data4
[
4
],
guid
.
Data4
[
5
],
guid
.
Data4
[
6
],
guid
.
Data4
[
7
]);
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录