提交 862de5b9 编写于 作者: O onexiaomin

fix some sample code errors

Signed-off-by: Nonexiaomin <wangminmin4@huawei.com>
上级 ec763c8e
...@@ -77,10 +77,12 @@ createFileAccessHelper(context: Context, wants: Array&lt;Want&gt;) : FileAccessH ...@@ -77,10 +77,12 @@ createFileAccessHelper(context: Context, wants: Array&lt;Want&gt;) : FileAccessH
let fileAccesssHelper = null; let fileAccesssHelper = null;
// wantInfo 从getFileAccessAbilityInfo()获取 // wantInfo 从getFileAccessAbilityInfo()获取
// 创建只连接媒体库服务的helper对象 // 创建只连接媒体库服务的helper对象
let wantInfo = { let wantInfos = [
"bundleName": "com.ohos.medialibrary.medialibrarydata", {
"abilityName": "FileExtensionAbility", "bundleName": "com.ohos.medialibrary.medialibrarydata",
} "abilityName": "FileExtensionAbility",
},
]
try { try {
fileAccesssHelper = fileAccess.createFileAccessHelper(this.context, wantInfos); fileAccesssHelper = fileAccess.createFileAccessHelper(this.context, wantInfos);
if (!fileAccesssHelper) if (!fileAccesssHelper)
...@@ -211,7 +213,7 @@ listFile(filter?: Filter) : FileIterator ...@@ -211,7 +213,7 @@ listFile(filter?: Filter) : FileIterator
let fileIterator = rootInfo.listFile(); let fileIterator = rootInfo.listFile();
// 含过滤器实现的listFile // 含过滤器实现的listFile
// let fileIterator = rootInfo.listFile(filter); // let fileIterator = rootInfo.listFile(filter);
if (fileIterator) { if (!fileIterator) {
console.error("listFile interface returns an undefined object"); console.error("listFile interface returns an undefined object");
return; return;
} }
...@@ -261,7 +263,7 @@ scanFile(filter?: Filter) : FileIterator ...@@ -261,7 +263,7 @@ scanFile(filter?: Filter) : FileIterator
let fileIterator = rootInfo.scanFile(); let fileIterator = rootInfo.scanFile();
// 含过滤器实现的scanFile // 含过滤器实现的scanFile
// let fileIterator = rootInfo.scanFile(filter); // let fileIterator = rootInfo.scanFile(filter);
if (fileIterator) { if (!fileIterator) {
console.error("scanFile interface returns undefined object"); console.error("scanFile interface returns undefined object");
return; return;
} }
...@@ -311,7 +313,7 @@ listFile(filter?: Filter) : FileIterator ...@@ -311,7 +313,7 @@ listFile(filter?: Filter) : FileIterator
let fileIterator = fileInfoDir.listFile(); let fileIterator = fileInfoDir.listFile();
// 含过滤器实现的listFile // 含过滤器实现的listFile
// let fileIterator = rootInfo.listFile(filter); // let fileIterator = rootInfo.listFile(filter);
if (fileIterator) { if (!fileIterator) {
console.error("listFile interface returns an undefined object"); console.error("listFile interface returns an undefined object");
return; return;
} }
...@@ -362,7 +364,7 @@ scanFile(filter?: Filter) : FileIterator; ...@@ -362,7 +364,7 @@ scanFile(filter?: Filter) : FileIterator;
let fileIterator = fileInfoDir.scanFile(); let fileIterator = fileInfoDir.scanFile();
// 含过滤器实现的scanFile // 含过滤器实现的scanFile
// let fileIterator = rootInfo.scanFile(filter); // let fileIterator = rootInfo.scanFile(filter);
if (fileIterator) { if (!fileIterator) {
console.error("scanFile interface returns an undefined object"); console.error("scanFile interface returns an undefined object");
return; return;
} }
...@@ -451,12 +453,12 @@ mkDir(parentUri: string, displayName: string) : Promise&lt;string&gt; ...@@ -451,12 +453,12 @@ mkDir(parentUri: string, displayName: string) : Promise&lt;string&gt;
let dirName = "dirTest" let dirName = "dirTest"
let dirUri = null; let dirUri = null;
try { try {
dirUri = await fileAccessHelper.mkDir(sourceUri, displayName) dirUri = await fileAccessHelper.mkDir(sourceUri, dirName)
if (!dirUri) { if (!dirUri) {
console.error("mkDir return undefined object"); console.error("mkDir return undefined object");
return; return;
} }
console.log("mkDir sucess, fileUri: " + JSON.stringify(fileUri)); console.log("mkDir sucess, dirUri: " + JSON.stringify(dirUri));
} catch (error) { } catch (error) {
console.error("mkDir failed, error " + error); console.error("mkDir failed, error " + error);
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册