Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6b75b71a
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6b75b71a
编写于
8月 23, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22445 新增fileuri相关接口
Merge pull request !22445 from zhuhongtao666/mr
上级
ed944cf1
82dc919d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
101 addition
and
0 deletion
+101
-0
zh-cn/application-dev/reference/apis/js-apis-file-fileuri.md
zh-cn/application-dev/reference/apis/js-apis-file-fileuri.md
+64
-0
zh-cn/application-dev/reference/apis/js-apis-file-fs.md
zh-cn/application-dev/reference/apis/js-apis-file-fs.md
+37
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-file-fileuri.md
浏览文件 @
6b75b71a
...
...
@@ -40,6 +40,70 @@ export default class EntryAbility extends UIAbility {
FA模型context的具体获取方法参见
[
FA模型
](
js-apis-inner-app-context.md#Context模块
)
。
## FileUri<sup>10+</sup>
### 属性
**系统能力**
:SystemCapability.FileManagement.AppFileService
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| path
<sup>
10+
</sup>
| string | 是 | 否 | 获取FileUri对应路径名 |
| name
<sup>
10+
</sup>
| string | 是 | 否 | 获取FileUri对应文件名 |
### constructor<sup>10+</sup>
constructor(uriOrPath: string)
constructor是FileUri的构造函数。
**系统能力:**
SystemCapability.FileManagement.AppFileService
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uriOrPath | string | 是 | uri或路径。uri类型:
<br/>
-
应用沙箱URI:file://
\<
bundleName>/
\<
sandboxPath>
<br/>
-
公共目录文件类URI:file://docs/storage/Users/currentUser/
\<
publicPath>
<br/>
-
公共目录媒体类URI:file://media/
\<
mediaType>/IMG_DATATIME_ID/
\<
displayName> |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 13900005 | I/O error |
| 13900042 | Unknown error |
**示例:**
```
js
let
path
=
pathDir
+
'
/test
'
;
let
uri
=
fileuri
.
getUriFromPath
(
filePath
);
// file://<packageName>/data/storage/el2/base/haps/entry/files/test
let
fileUriObject
=
new
fileuri
.
FileUri
(
uri
);
console
.
info
(
"
The name of FileUri is
"
+
fileUriObject
.
name
);
```
### toString<sup>10+</sup>
toString(): string
**系统能力:**
SystemCapability.FileManagement.AppFileService
返回字符串类型uri。
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| string | 返回字符串类型uri |
**示例:**
```
js
let
path
=
pathDir
+
'
/test
'
;
let
fileUriObject
=
new
fileuri
.
FileUri
(
path
);
console
.
info
(
"
The uri of FileUri is
"
+
fileUriObject
.
toString
());
```
## fileUri.getUriFromPath
getUriFromPath(path: string): string
...
...
zh-cn/application-dev/reference/apis/js-apis-file-fs.md
浏览文件 @
6b75b71a
...
...
@@ -533,6 +533,41 @@ copyDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>
});
```
## fs.dup<sup>10+</sup>
dup(fd: number): File
将文件描述符转化为File。
**系统能力**
:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| fd | number | 是 | 文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
|
[
File
](
#file
)
| 打开的File对象。 |
**错误码:**
接口抛出错误码的详细介绍请参见
[
基础文件IO错误码
](
../errorcodes/errorcode-filemanagement.md#基础文件io错误码
)
。
**示例:**
```
js
// convert fd to file
let
fd
=
0
;
// fd comes from other modules
let
file
=
fs
.
dup
(
fd
);
console
.
info
(
"
The name of the file is
"
+
file
.
name
);
fs
.
closeSync
(
file
);
```
## fs.mkdir
mkdir(path: string): Promise
<
void
>
...
...
@@ -3263,6 +3298,8 @@ readSync(buffer: ArrayBuffer, options?: { offset?: number; length?: number; }):
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---- | ------ | ---- | ---- | ------- |
| fd | number | 是 | 否 | 打开的文件描述符。 |
| path
<sup>
10+
</sup>
| string | 是 | 否 | 文件路径。 |
| name
<sup>
10+
</sup>
| string | 是 | 否 | 文件名。 |
### lock
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录