source stringlengths 14 113 | code stringlengths 10 21.3k |
|---|---|
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
fs.mkdtemp(pathDir + "/XXXXXX", (err: BusinessError, res: string) => {
if (err) {
console.error("mkdtemp failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("mkdtemp succeed");
}
}); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let res = fs.mkdtempSync(pathDir + "/XXXXXX"); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
fs.writeSync(file.fd, 'test data');
fs.closeSync(file);
fs.utimes(filePath, new Date().getTime()); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
fs.createRandomAccessFile(file).then((randomAccessFile: fs.RandomAccessFile) => {
console.info("randomAccessFile fd: " + randomAccessFile.... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
fs.createRandomAccessFile(file, (err: BusinessError, randomAccessFile: fs.RandomAccessFile) => {
if (err) {
console.error("create ra... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
fs.createRandomAccessFile(file, fs.OpenMode.READ_ONLY, (err: BusinessError, randomAccessFile: fs.RandomAccessFile) => {
if (err) {
c... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
fs.createRandomAccessFile(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE, { start: 10, end: 100 })
.then((randomAccessFile: fs.RandomAccessFile) => {
console.info("randomAccessFile fd: " + randomAccessFile.fd);
... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let randomAccessFile = fs.createRandomAccessFileSync(file);
randomAccessFile.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE,
{ start: 10, end: 100 });
randomAccessFile.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
fs.createStream(filePath, "a+").then((stream: fs.Stream) => {
stream.closeSync();
console.info("Stream created");
}).catch((err: BusinessError) => {
console.error("createStream failed with error message: " + e... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
fs.createStream(filePath, "r+", (err: BusinessError, stream: fs.Stream) => {
if (err) {
console.error("create stream failed with error message: " + err.message + ", error code: " + err.code);
} else {
co... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
console.info("Stream created");
stream.closeSync(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath);
fs.fdopenStream(file.fd, "r+").then((stream: fs.Stream) => {
console.info("Stream opened");
stream.closeSync();
}).catch((err: BusinessError) => {
console.error("openStream ... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
fs.fdopenStream(file.fd, "r+", (err: BusinessError, stream: fs.Stream) => {
if (err) {
console.error("fdopen stream failed with error message: " + err.mes... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE);
let stream = fs.fdopenStreamSync(file.fd, "r+");
stream.closeSync(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | // Create a readable stream.
const rs = fs.createReadStream(`${pathDir}/read.txt`);
// Create a writeable stream.
const ws = fs.createWriteStream(`${pathDir}/write.txt`);
// Copy files in paused mode.
rs.on('readable', () => {
const data = rs.read();
if (!data) {
return;
}
ws.write(data)... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | // Create a readable stream.
const rs = fs.createReadStream(`${pathDir}/read.txt`);
// Create a writeable stream.
const ws = fs.createWriteStream(`${pathDir}/write.txt`);
// Copy files in paused mode.
rs.on('readable', () => {
const data = rs.read();
if (!data) {
return;
}
ws.write(data)... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext.
let context = this.getUIContext().getHost... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
import { BusinessError } from '@kit.BasicServicesKit';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAb... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
import { util, buffer } from '@kit.ArkTS';
import { BusinessError } from '@kit.BasicServicesKit';
// Obtain the context from the component and ensure that the return value of t... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext.
let context = this.getUIContext().getHost... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext.
let context = this.getUIContext().getHost... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
import { util, buffer } from '@kit.ArkTS';
import { BusinessError } from '@kit.BasicServicesKit';
// Obtain the context from the component and ensure that the return value of t... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { common } from '@kit.AbilityKit';
import { fileIo as fs} from '@kit.CoreFileKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { util } from '@kit.ArkTS';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext.
let co... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { common } from '@kit.AbilityKit';
import { fileIo as fs, WatchEvent } from '@kit.CoreFileKit';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext.
let context = this.getUIContext().getHostContext() as common.UIAbilityConte... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs } from '@kit.CoreFileKit';
import { fileUri } from '@kit.CoreFileKit';
import common from '@ohos.app.ability.common';
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbili... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { fileIo as fs } from '@kit.CoreFileKit';
import { TaskSignal } from '@ohos.file.fs';
let copySignal: fs.TaskSignal = new TaskSignal();
copySignal.onCancel().then(() => {
console.info("copyFileWithCancel success.");
}); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { TaskSignal } from '@kit.CoreFileKit';
let copySignal: fs.TaskSignal = new TaskSignal();
let progressListener: fs.ProgressListener = (progress: fs.Progress) => {
console.info(`processedSize: ${progress.processedSize}, totalSize: ${progress.totalSize}`);
};
let copyOption: fs.CopyOptions = {
"pro... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let isBLockDevice = fs.statSync(filePath).isBlockDevice(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let isCharacterDevice = fs.statSync(filePath).isCharacterDevice(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let dirPath = pathDir + "/test";
let isDirectory = fs.statSync(dirPath).isDirectory(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let isFIFO = fs.statSync(filePath).isFIFO(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let isFile = fs.statSync(filePath).isFile(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let isSocket = fs.statSync(filePath).isSocket(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test";
let isSymbolicLink = fs.statSync(filePath).isSymbolicLink(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
stream.close().then(() => {
console.info("File stream closed");
}).catch((err: BusinessError) => {
console.error("close fileStream failed with error message: " ... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
stream.close((err: BusinessError) => {
if (err) {
console.error("close stream failed with error message: " + err.message + ", error code: " + err.code);
} el... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
stream.closeSync(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
stream.flush().then(() => {
console.info("Stream flushed");
stream.close();
}).catch((err: BusinessError) => {
console.error("flush failed with error message... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
stream.flush((err: BusinessError) => {
if (err) {
console.error("flush stream failed with error message: " + err.message + ", error code: " + err.code);
} el... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
stream.flushSync();
stream.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
let writeOption: WriteOptions = {
offset: 5,
length: 5,
encoding: 'utf-8'
};
stream.write(... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
let writeOption: WriteOptions = {
offset: 5,
length: 5,
encoding: 'utf-8'
};
stream.write(... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath,"r+");
let writeOption: WriteOptions = {
offset: 5,
length: 5,
encoding: 'utf-8'
};
let num = stream.writeSync("hello, world", writeOption);
stream.close... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { buffer } from '@kit.ArkTS';
import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
let arrayBuffer = new ArrayBuffer(4096);
let readOption: ReadOptio... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { buffer } from '@kit.ArkTS';
import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
let arrayBuffer = new ArrayBuffer(4096);
let readOption: ReadOptio... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let stream = fs.createStreamSync(filePath, "r+");
let readOption: ReadOptions = {
offset: 5,
length: 5
};
let buf = new ArrayBuffer(4096);
let num = stream.readSync(buf, readOption);
stream.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
console.info('The parent path is: ' + file.getParent());
fs.closeSync(file); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.lock(true).then(() => {
console.log("lock file succeed");
}).catch((err: BusinessError) => {
console.error("lock file failed wi... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.lock(true, (err: BusinessError) => {
if (err) {
console.error("lock file failed with error message: " + err.message + ", error ... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.tryLock(true);
console.log("lock file succeed");
fs.closeSync(file); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.tryLock(true);
file.unlock();
console.log("unlock file succeed");
fs.closeSync(file); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
randomAccessFile.setFilePointer(1);
randomAccessFile.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
randomAccessFile.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let randomAccessFile = fs.createRandomAccessFileSync(file);
let bufferLengt... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let randomAccessFile = fs.createRandomAccessFileSync(file);
let bufferLengt... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let writeOption: WriteOptions = {
offset: 5,
length: 5,
encoding: 'utf-8'
};
let bytesWr... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let randomAccessFile = fs.createRandomAccessFileSync(file);
let bufferLength... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let randomAccessFile = fs.createRandomAccessFileSync(file);
let length: numb... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
let randomAccessFile = fs.createRandomAccessFileSync(file);
let length: number = 4096;
let arrayBuffer = new ArrayBuffer(length);
let readLength = randomAccessFile.readSync(arrayBuffer);
rand... |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | const filePath = pathDir + "/test.txt";
const randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
const rs = randomAccessFile.getReadStream();
rs.close();
randomAccessFile.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | const filePath = pathDir + "/test.txt";
const randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
const ws = randomAccessFile.getWriteStream();
ws.close();
randomAccessFile.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let watcher = fs.createWatcher(filePath, 0xfff, () => {});
watcher.start();
watcher.stop(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | let filePath = pathDir + "/test.txt";
let watcher = fs.createWatcher(filePath, 0xfff, () => {});
watcher.start();
watcher.stop(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | const filePath = pathDir + "/test.txt";
const rs = fs.createReadStream(filePath);
const curOff = rs.seek(5, fs.WhenceType.SEEK_SET);
console.info(`current offset is ${curOff}`);
rs.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | const filePath = pathDir + "/test.txt";
const rs = fs.createReadStream(filePath);
rs.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | const filePath = pathDir + "/test.txt";
const ws = fs.createWriteStream(filePath);
const curOff = ws.seek(5, fs.WhenceType.SEEK_SET);
console.info(`current offset is ${curOff}`);
ws.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-fs.md | const filePath = pathDir + "/test.txt";
const ws = fs.createWriteStream(filePath);
ws.close(); |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | import { hash } from '@kit.CoreFileKit'; |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | import { UIAbility } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
let context = this.context;
let pathDir = context.filesDir;
}
} |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
hash.hash(filePath, "sha256").then((str: string) => {
console.info("calculate file hash succeed:" + str);
}).catch((err: BusinessError) => {
console.error("calculate file hash failed with error message: " + err.me... |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | import { BusinessError } from '@kit.BasicServicesKit';
let filePath = pathDir + "/test.txt";
hash.hash(filePath, "sha256", (err: BusinessError, str: string) => {
if (err) {
console.error("calculate file hash failed with error message: " + err.message + ", error code: " + err.code);
} else {
cons... |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | // pages/xxx.ets
import { fileIo as fs } from '@kit.CoreFileKit';
function hashFileWithStream() {
const filePath = pathDir + "/test.txt";
// Create a readable stream.
const rs = fs.createReadStream(filePath);
// Create a hash stream.
const hs = hash.createHash('sha256');
rs.on('data', (emit... |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | // Create a hash stream.
const hs = hash.createHash('sha256');
hs.update(new Uint8Array('1234567890'?.split('').map((x: string) => x.charCodeAt(0))).buffer);
hs.update(new Uint8Array('abcdefg'?.split('').map((x: string) => x.charCodeAt(0))).buffer);
const hashResult = hs.digest();
// 88A00F46836CD629D0B79DE98... |
application-dev\reference\apis-core-file-kit\js-apis-file-hash.md | // Create a hash stream.
const hs = hash.createHash('sha256');
hs.update(new Uint8Array('1234567890'?.split('').map((x: string) => x.charCodeAt(0))).buffer);
hs.update(new Uint8Array('abcdefg'?.split('').map((x: string) => x.charCodeAt(0))).buffer);
const hashResult = hs.digest();
// 88A00F46836CD629D0B79DE98... |
application-dev\reference\apis-core-file-kit\js-apis-file-keymanager-sys.md | import { keyManager } from "@kit.CoreFileKit"; |
application-dev\reference\apis-core-file-kit\js-apis-file-keymanager-sys.md | import { keyManager } from "@kit.CoreFileKit";
import { BusinessError } from '@ohos.base';
let userId: number = 100;
try {
keyManager.deactivateUserKey(userId);
console.info("deactivateUserKey success");
} catch (err) {
let error: BusinessError = err as BusinessError;
console.error("deactivateUs... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker-sys.md | import { picker } from '@kit.CoreFileKit'; |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { picker } from '@kit.CoreFileKit'; |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
@Entry
@Component
struct Index {
@State message: string = 'hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=>{
... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | let documentPicker = new picker.DocumentViewPicker(); // Construction without parameter is not recommended. There is a possibility that the DocumentViewPicker instance fails to start. |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
import { window } from '@kit.ArkUI';
@Entry
@Component
struct Index {
@State message: string = 'hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeig... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example07(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentSelectOptions = new picker.Document... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example08(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentSelectOptions = new picker.Document... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example09(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentPicker = new picker.DocumentViewPic... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example10(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentSaveOptions = new picker.DocumentSa... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example11(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentSaveOptions = new picker.DocumentSa... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example12(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentPicker = new picker.DocumentViewPic... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function exampleIndex(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let documentSaveOptions = new picker.Documen... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
@Entry
@Component
struct Index {
@State message: string = 'hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=>{
... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | let audioPicker = new picker.AudioViewPicker(); // Construction without parameter is not recommended. There is a possibility that the AudioViewPicker instance fails to start. |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example13(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let audioSelectOptions = new picker.AudioSelect... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example14(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let audioSelectOptions = new picker.AudioSelect... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example15(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let audioPicker = new picker.AudioViewPicker(co... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example16(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let audioSaveOptions = new picker.AudioSaveOpti... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example17(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let audioSaveOptions = new picker.AudioSaveOpti... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example18(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let audioPicker = new picker.AudioViewPicker(co... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
@Entry
@Component
struct Index {
@State message: string = 'hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=>{
... |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | let photoPicker = new picker.PhotoViewPicker(); // Construction without parameter is not recommended. There is a possibility that the PhotoViewPicker instance fails to start. |
application-dev\reference\apis-core-file-kit\js-apis-file-picker.md | import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
async function example01(context: common.UIAbilityContext) { // Ensure that context is converted from UIAbilityContext.
try {
let photoSelectOptions = new picker.PhotoSelect... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.