Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ff6f16c9
提交
ff6f16c9
authored
10月 18, 2018
作者:
Overbool
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(command): modify int to int64
License: MIT Signed-off-by:
Overbool
<
overbool.xu@gmail.com
>
上级
9cdbb1ea
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
12 行删除
+12
-12
cat.go
core/commands/cat.go
+4
-4
files.go
core/commands/files.go
+8
-8
没有找到文件。
core/commands/cat.go
浏览文件 @
ff6f16c9
...
@@ -29,8 +29,8 @@ var CatCmd = &cmds.Command{
...
@@ -29,8 +29,8 @@ var CatCmd = &cmds.Command{
cmdkit
.
StringArg
(
"ipfs-path"
,
true
,
true
,
"The path to the IPFS object(s) to be outputted."
)
.
EnableStdin
(),
cmdkit
.
StringArg
(
"ipfs-path"
,
true
,
true
,
"The path to the IPFS object(s) to be outputted."
)
.
EnableStdin
(),
},
},
Options
:
[]
cmdkit
.
Option
{
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
IntOption
(
offsetOptionName
,
"o"
,
"Byte offset to begin reading from."
),
cmdkit
.
Int
64
Option
(
offsetOptionName
,
"o"
,
"Byte offset to begin reading from."
),
cmdkit
.
IntOption
(
lengthOptionName
,
"l"
,
"Maximum number of bytes to read."
),
cmdkit
.
Int
64
Option
(
lengthOptionName
,
"l"
,
"Maximum number of bytes to read."
),
},
},
Run
:
func
(
req
*
cmds
.
Request
,
res
cmds
.
ResponseEmitter
,
env
cmds
.
Environment
)
error
{
Run
:
func
(
req
*
cmds
.
Request
,
res
cmds
.
ResponseEmitter
,
env
cmds
.
Environment
)
error
{
node
,
err
:=
cmdenv
.
GetNode
(
env
)
node
,
err
:=
cmdenv
.
GetNode
(
env
)
...
@@ -49,12 +49,12 @@ var CatCmd = &cmds.Command{
...
@@ -49,12 +49,12 @@ var CatCmd = &cmds.Command{
}
}
}
}
offset
,
_
:=
req
.
Options
[
offsetOptionName
]
.
(
int
)
offset
,
_
:=
req
.
Options
[
offsetOptionName
]
.
(
int
64
)
if
offset
<
0
{
if
offset
<
0
{
return
fmt
.
Errorf
(
"cannot specify negative offset"
)
return
fmt
.
Errorf
(
"cannot specify negative offset"
)
}
}
max
,
found
:=
req
.
Options
[
lengthOptionName
]
.
(
int
)
max
,
found
:=
req
.
Options
[
lengthOptionName
]
.
(
int
64
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
core/commands/files.go
浏览文件 @
ff6f16c9
...
@@ -564,8 +564,8 @@ Examples:
...
@@ -564,8 +564,8 @@ Examples:
cmdkit
.
StringArg
(
"path"
,
true
,
false
,
"Path to file to be read."
),
cmdkit
.
StringArg
(
"path"
,
true
,
false
,
"Path to file to be read."
),
},
},
Options
:
[]
cmdkit
.
Option
{
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
IntOption
(
filesOffsetOptionName
,
"o"
,
"Byte offset to begin reading from."
),
cmdkit
.
Int
64
Option
(
filesOffsetOptionName
,
"o"
,
"Byte offset to begin reading from."
),
cmdkit
.
IntOption
(
filesCountOptionName
,
"n"
,
"Maximum number of bytes to read."
),
cmdkit
.
Int
64
Option
(
filesCountOptionName
,
"n"
,
"Maximum number of bytes to read."
),
},
},
Run
:
func
(
req
oldcmds
.
Request
,
res
oldcmds
.
Response
)
{
Run
:
func
(
req
oldcmds
.
Request
,
res
oldcmds
.
Response
)
{
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
...
@@ -600,7 +600,7 @@ Examples:
...
@@ -600,7 +600,7 @@ Examples:
defer
rfd
.
Close
()
defer
rfd
.
Close
()
offset
,
_
,
err
:=
req
.
Option
(
offsetOptionName
)
.
Int
()
offset
,
_
,
err
:=
req
.
Option
(
offsetOptionName
)
.
Int
64
()
if
err
!=
nil
{
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
...
@@ -628,7 +628,7 @@ Examples:
...
@@ -628,7 +628,7 @@ Examples:
}
}
var
r
io
.
Reader
=
&
contextReaderWrapper
{
R
:
rfd
,
ctx
:
req
.
Context
()}
var
r
io
.
Reader
=
&
contextReaderWrapper
{
R
:
rfd
,
ctx
:
req
.
Context
()}
count
,
found
,
err
:=
req
.
Option
(
filesCountOptionName
)
.
Int
()
count
,
found
,
err
:=
req
.
Option
(
filesCountOptionName
)
.
Int
64
()
if
err
!=
nil
{
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
return
...
@@ -750,11 +750,11 @@ stat' on the file or any of its ancestors.
...
@@ -750,11 +750,11 @@ stat' on the file or any of its ancestors.
cmdkit
.
FileArg
(
"data"
,
true
,
false
,
"Data to write."
)
.
EnableStdin
(),
cmdkit
.
FileArg
(
"data"
,
true
,
false
,
"Data to write."
)
.
EnableStdin
(),
},
},
Options
:
[]
cmdkit
.
Option
{
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
IntOption
(
filesOffsetOptionName
,
"o"
,
"Byte offset to begin writing at."
),
cmdkit
.
Int
64
Option
(
filesOffsetOptionName
,
"o"
,
"Byte offset to begin writing at."
),
cmdkit
.
BoolOption
(
filesCreateOptionName
,
"e"
,
"Create the file if it does not exist."
),
cmdkit
.
BoolOption
(
filesCreateOptionName
,
"e"
,
"Create the file if it does not exist."
),
cmdkit
.
BoolOption
(
filesParentsOptionName
,
"p"
,
"Make parent directories as needed."
),
cmdkit
.
BoolOption
(
filesParentsOptionName
,
"p"
,
"Make parent directories as needed."
),
cmdkit
.
BoolOption
(
filesTruncateOptionName
,
"t"
,
"Truncate the file to size zero before writing."
),
cmdkit
.
BoolOption
(
filesTruncateOptionName
,
"t"
,
"Truncate the file to size zero before writing."
),
cmdkit
.
IntOption
(
filesCountOptionName
,
"n"
,
"Maximum number of bytes to read."
),
cmdkit
.
Int
64
Option
(
filesCountOptionName
,
"n"
,
"Maximum number of bytes to read."
),
cmdkit
.
BoolOption
(
filesRawLeavesOptionName
,
"Use raw blocks for newly created leaf nodes. (experimental)"
),
cmdkit
.
BoolOption
(
filesRawLeavesOptionName
,
"Use raw blocks for newly created leaf nodes. (experimental)"
),
cidVersionOption
,
cidVersionOption
,
hashOption
,
hashOption
,
...
@@ -781,7 +781,7 @@ stat' on the file or any of its ancestors.
...
@@ -781,7 +781,7 @@ stat' on the file or any of its ancestors.
return
err
return
err
}
}
offset
,
_
:=
req
.
Options
[
filesOffsetOptionName
]
.
(
int
)
offset
,
_
:=
req
.
Options
[
filesOffsetOptionName
]
.
(
int
64
)
if
offset
<
0
{
if
offset
<
0
{
return
fmt
.
Errorf
(
"cannot have negative write offset"
)
return
fmt
.
Errorf
(
"cannot have negative write offset"
)
}
}
...
@@ -823,7 +823,7 @@ stat' on the file or any of its ancestors.
...
@@ -823,7 +823,7 @@ stat' on the file or any of its ancestors.
}
}
}
}
count
,
countfound
:=
req
.
Options
[
filesCountOptionName
]
.
(
int
)
count
,
countfound
:=
req
.
Options
[
filesCountOptionName
]
.
(
int
64
)
if
countfound
&&
count
<
0
{
if
countfound
&&
count
<
0
{
return
fmt
.
Errorf
(
"cannot have negative byte count"
)
return
fmt
.
Errorf
(
"cannot have negative byte count"
)
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论