Lines Matching refs:fs
1 # @ohos.file.fs (文件管理)
12 import { fileIo as fs } from '@kit.CoreFileKit';
33 ## fs.stat
64 fs.stat(filePath).then((stat: fs.Stat) => {
71 ## fs.stat
96 fs.stat(pathDir, (err: BusinessError, stat: fs.Stat) => {
105 ## fs.statSync
134 let stat = fs.statSync(pathDir);
138 ## fs.access
175 fs.access(filePath).then((res: boolean) => {
186 ## fs.access
222 fs.access(filePath, fs.AccessModeFlag.EXIST, fs.AccessFlagType.LOCAL).then((res: boolean) => {
233 ## fs.access
264 fs.access(filePath, (err: BusinessError, res: boolean) => {
277 ## fs.accessSync
315 let res = fs.accessSync(filePath);
327 ## fs.accessSync
364 let res = fs.accessSync(filePath, fs.AccessModeFlag.EXIST, fs.AccessFlagType.LOCAL);
376 ## fs.close
407 let file = fs.openSync(filePath);
408 fs.close(file).then(() => {
415 ## fs.close
441 let file = fs.openSync(filePath);
442 fs.close(file, (err: BusinessError) => {
451 ## fs.closeSync
475 let file = fs.openSync(filePath);
476 fs.closeSync(file);
479 ## fs.copy<sup>11+</sup>
511 import { fileIo as fs } from '@kit.CoreFileKit';
521 let progressListener: fs.ProgressListener = (progress: fs.Progress) => {
524 let copyoption: fs.CopyOptions = {
528 fs.copy(srcDirUriLocal, dstDirUriLocal, copyoption).then(()=>{
538 ## fs.copy<sup>11+</sup>
574 fs.copy(srcDirUriLocal, dstDirUriLocal, (err: BusinessError) => {
586 ## fs.copy<sup>11+</sup>
613 import { fileIo as fs } from '@kit.CoreFileKit';
624 let progressListener: fs.ProgressListener = (progress: fs.Progress) => {
627 let copyoption: fs.CopyOptions = {
630 fs.copy(srcDirUriLocal, dstDirUriLocal, copyoption, (err: BusinessError) => {
642 ## fs.copyFile
676 fs.copyFile(srcPath, dstPath, 0).then(() => {
683 ## fs.copyFile
712 fs.copyFile(srcPath, dstPath, 0, (err: BusinessError) => {
721 ## fs.copyFile
749 fs.copyFile(srcPath, dstPath, (err: BusinessError) => {
759 ## fs.copyFileSync
786 fs.copyFileSync(srcPath, dstPath);
789 ## fs.copyDir<sup>10+</sup>
822 fs.copyDir(srcPath, destPath, 0).then(() => {
829 ## fs.copyDir<sup>10+</sup>
854 import { fileIo as fs, ConflictFiles } from '@kit.CoreFileKit';
858 fs.copyDir(srcPath, destPath, 0, (err: BusinessError<Array<ConflictFiles>>) => {
871 ## fs.copyDir<sup>10+</sup>
897 import { fileIo as fs, ConflictFiles } from '@kit.CoreFileKit';
901 fs.copyDir(srcPath, destPath, (err: BusinessError<Array<ConflictFiles>>) => {
914 ## fs.copyDirSync<sup>10+</sup>
942 fs.copyDirSync(srcPath, destPath, 0);
950 ## fs.dup<sup>10+</sup>
978 let file1 = fs.openSync(filePath, fs.OpenMode.READ_WRITE);
980 let file2 = fs.dup(fd);
982 fs.closeSync(file1);
983 fs.closeSync(file2);
986 ## fs.connectDfs<sup>12+</sup>
1017 import { fileIo as fs } from '@kit.CoreFileKit';
1022 let listeners: fs.DfsListeners = {
1027 fs.connectDfs(networkId, listeners).then(() => {
1034 ## fs.disconnectDfs<sup>12+</sup>
1064 import { fileIo as fs } from '@kit.CoreFileKit';
1069 fs.disconnectDfs(networkId).then(() => {
1076 ## fs.setxattr<sup>12+</sup>
1111 fs.setxattr(filePath, attrKey, attrValue).then(() => {
1118 ## fs.setxattrSync<sup>12+</sup>
1148 fs.setxattrSync(filePath, attrKey, attrValue);
1156 ## fs.getxattr<sup>12+</sup>
1189 fs.getxattr(filePath, attrKey).then((attrValue: string) => {
1197 ## fs.getxattrSync<sup>12+</sup>
1231 let attrValue = fs.getxattrSync(filePath, attrKey);
1239 ## fs.mkdir
1270 fs.mkdir(dirPath).then(() => {
1277 ## fs.mkdir<sup>11+</sup>
1309 fs.mkdir(dirPath, true).then(() => {
1316 ## fs.mkdir
1342 fs.mkdir(dirPath, (err: BusinessError) => {
1351 ## fs.mkdir<sup>11+</sup>
1378 fs.mkdir(dirPath, true, (err: BusinessError) => {
1387 ## fs.mkdirSync
1411 fs.mkdirSync(dirPath);
1414 ## fs.mkdirSync<sup>11+</sup>
1439 fs.mkdirSync(dirPath, true);
1442 ## fs.open
1474 fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE).then((file: fs.File) => {
1476 fs.closeSync(file);
1483 ## fs.open
1512 …fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE, (err: BusinessError, file: fs.File)…
1518 fs.closeSync(file);
1522 ## fs.open
1548 fs.open(filePath, (err: BusinessError, file: fs.File) => {
1554 fs.closeSync(file);
1558 ## fs.openSync
1589 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
1591 fs.closeSync(file);
1594 ## fs.read
1628 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE);
1630 fs.read(file.fd, arrayBuffer).then((readLen: number) => {
1637 fs.closeSync(file);
1641 ## fs.read
1670 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE);
1672 fs.read(file.fd, arrayBuffer, (err: BusinessError, readLen: number) => {
1680 fs.closeSync(file);
1684 ## fs.readSync
1716 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE);
1718 fs.readSync(file.fd, buf);
1719 fs.closeSync(file);
1722 ## fs.rmdir
1753 fs.rmdir(dirPath).then(() => {
1760 ## fs.rmdir
1786 fs.rmdir(dirPath, (err: BusinessError) => {
1795 ## fs.rmdirSync
1819 fs.rmdirSync(dirPath);
1822 ## fs.unlink
1853 fs.unlink(filePath).then(() => {
1860 ## fs.unlink
1886 fs.unlink(filePath, (err: BusinessError) => {
1895 ## fs.unlinkSync
1919 fs.unlinkSync(filePath);
1923 ## fs.write
1956 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
1958 fs.write(file.fd, str).then((writeLen: number) => {
1963 fs.closeSync(file);
1967 ## fs.write
1995 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
1997 fs.write(file.fd, str, (err: BusinessError, writeLen: number) => {
2003 fs.closeSync(file);
2007 ## fs.writeSync
2039 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
2041 let writeLen = fs.writeSync(file.fd, str);
2043 fs.closeSync(file);
2046 ## fs.truncate
2079 fs.truncate(filePath, len).then(() => {
2086 ## fs.truncate
2114 fs.truncate(filePath, len, (err: BusinessError) => {
2123 ## fs.truncateSync
2149 fs.truncateSync(filePath, len);
2152 ## fs.readLines<sup>11+</sup>
2181 import { fileIo as fs, Options } from '@kit.CoreFileKit';
2186 fs.readLines(filePath, options).then((readerIterator: fs.ReaderIterator) => {
2195 ## fs.readLines<sup>11+</sup>
2219 import { fileIo as fs, Options } from '@kit.CoreFileKit';
2224 fs.readLines(filePath, options, (err: BusinessError, readerIterator: fs.ReaderIterator) => {
2235 ## fs.readLinesSync<sup>11+</sup>
2263 import { fileIo as fs, Options } from '@kit.CoreFileKit';
2268 let readerIterator = fs.readLinesSync(filePath, options);
2304 import { fileIo as fs, Options } from '@kit.CoreFileKit';
2309 fs.readLines(filePath, options).then((readerIterator: fs.ReaderIterator) => {
2329 ## fs.readText
2361 fs.readText(filePath).then((str: string) => {
2368 ## fs.readText
2394 import { fileIo as fs, ReadTextOptions } from '@kit.CoreFileKit';
2401 let stat = fs.statSync(filePath);
2403 fs.readText(filePath, readTextOption, (err: BusinessError, str: string) => {
2412 ## fs.readTextSync
2442 import { fileIo as fs, ReadTextOptions } from '@kit.CoreFileKit';
2449 let stat = fs.statSync(filePath);
2451 let str = fs.readTextSync(filePath, readTextOptions);
2455 ## fs.lstat
2484 fs.lstat(filePath).then((stat: fs.Stat) => {
2491 ## fs.lstat
2515 fs.lstat(filePath, (err: BusinessError, stat: fs.Stat) => {
2524 ## fs.lstatSync
2552 let fileStat = fs.lstatSync(filePath);
2556 ## fs.rename
2592 fs.rename(srcFile, dstFile).then(() => {
2599 ## fs.rename
2630 fs.rename(srcFile, dstFile, (err: BusinessError) => {
2639 ## fs.renameSync
2668 fs.renameSync(srcFile, dstFile);
2671 ## fs.fsync
2700 let file = fs.openSync(filePath);
2701 fs.fsync(file.fd).then(() => {
2706 fs.closeSync(file);
2710 ## fs.fsync
2734 let file = fs.openSync(filePath);
2735 fs.fsync(file.fd, (err: BusinessError) => {
2741 fs.closeSync(file);
2746 ## fs.fsyncSync
2768 let file = fs.openSync(filePath);
2769 fs.fsyncSync(file.fd);
2770 fs.closeSync(file);
2773 ## fs.fdatasync
2802 let file = fs.openSync(filePath);
2803 fs.fdatasync(file.fd).then(() => {
2808 fs.closeSync(file);
2812 ## fs.fdatasync
2836 let file = fs.openSync(filePath);
2837 fs.fdatasync (file.fd, (err: BusinessError) => {
2843 fs.closeSync(file);
2847 ## fs.fdatasyncSync
2869 let file = fs.openSync(filePath);
2870 fs.fdatasyncSync(file.fd);
2871 fs.closeSync(file);
2874 ## fs.symlink
2905 fs.symlink(srcFile, dstFile).then(() => {
2913 ## fs.symlink
2938 fs.symlink(srcFile, dstFile, (err: BusinessError) => {
2947 ## fs.symlinkSync
2971 fs.symlinkSync(srcFile, dstFile);
2974 ## fs.listFile
3005 import { fileIo as fs, Filter, ListFileOptions } from '@kit.CoreFileKit';
3015 fs.listFile(pathDir, listFileOption).then((filenames: Array<string>) => {
3025 ## fs.listFile
3051 import { fileIo as fs, Filter, ListFileOptions } from '@kit.CoreFileKit';
3061 fs.listFile(pathDir, listFileOption, (err: BusinessError, filenames: Array<string>) => {
3073 ## fs.listFileSync
3104 import { fileIo as fs, Filter, ListFileOptions} from '@kit.CoreFileKit';
3114 let filenames = fs.listFileSync(pathDir, listFileOption);
3121 ## fs.lseek<sup>11+</sup>
3151 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3152 console.info('The current offset is at ' + fs.lseek(file.fd, 5, fs.WhenceType.SEEK_SET));
3153 fs.closeSync(file);
3156 ## fs.moveDir<sup>10+</sup>
3192 fs.moveDir(srcPath, destPath, 1).then(() => {
3199 ## fs.moveDir<sup>10+</sup>
3227 import { fileIo as fs, ConflictFiles } from '@kit.CoreFileKit';
3231 fs.moveDir(srcPath, destPath, 1, (err: BusinessError<Array<ConflictFiles>>) => {
3244 ## fs.moveDir<sup>10+</sup>
3273 import { fileIo as fs, ConflictFiles } from '@kit.CoreFileKit';
3277 fs.moveDir(srcPath, destPath, (err: BusinessError<Array<ConflictFiles>>) => {
3290 ## fs.moveDirSync<sup>10+</sup>
3317 import { fileIo as fs, ConflictFiles } from '@kit.CoreFileKit';
3322 fs.moveDirSync(srcPath, destPath, 1);
3336 ## fs.moveFile
3371 fs.moveFile(srcPath, destPath, 0).then(() => {
3378 ## fs.moveFile
3408 fs.moveFile(srcPath, destPath, 0, (err: BusinessError) => {
3417 ## fs.moveFile
3446 fs.moveFile(srcPath, destPath, (err: BusinessError) => {
3455 ## fs.moveFileSync
3483 fs.moveFileSync(srcPath, destPath, 0);
3487 ## fs.mkdtemp
3515 fs.mkdtemp(pathDir + "/XXXXXX").then((dir: string) => {
3522 ## fs.mkdtemp
3545 fs.mkdtemp(pathDir + "/XXXXXX", (err: BusinessError, res: string) => {
3554 ## fs.mkdtempSync
3581 let res = fs.mkdtempSync(pathDir + "/XXXXXX");
3584 ## fs.utimes<sup>11+</sup>
3606 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3607 fs.writeSync(file.fd, 'test data');
3608 fs.closeSync(file);
3609 fs.utimes(filePath, new Date().getTime());
3612 ## fs.createRandomAccessFile<sup>10+</sup>
3641 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3642 fs.createRandomAccessFile(file).then((randomAccessFile: fs.RandomAccessFile) => {
3648 fs.closeSync(file);
3652 ## fs.createRandomAccessFile<sup>10+</sup>
3675 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3676 fs.createRandomAccessFile(file, (err: BusinessError, randomAccessFile: fs.RandomAccessFile) => {
3683 fs.closeSync(file);
3687 ## fs.createRandomAccessFile<sup>10+</sup>
3711 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3712 …fs.createRandomAccessFile(file, fs.OpenMode.READ_ONLY, (err: BusinessError, randomAccessFile: fs.R…
3719 fs.closeSync(file);
3723 ## fs.createRandomAccessFile<sup>12+</sup>
3752 fs.createRandomAccessFile(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE, { start: 10, end: …
3753 .then((randomAccessFile: fs.RandomAccessFile) => {
3763 ## fs.createRandomAccessFileSync<sup>10+</sup>
3792 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3793 let randomAccessFile = fs.createRandomAccessFileSync(file);
3797 ## fs.createRandomAccessFileSync<sup>12+</sup>
3828 …let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.RE…
3833 ## fs.createStream
3863 fs.createStream(filePath, "a+").then((stream: fs.Stream) => {
3872 ## fs.createStream
3897 fs.createStream(filePath, "r+", (err: BusinessError, stream: fs.Stream) => {
3907 ## fs.createStreamSync
3936 let stream = fs.createStreamSync(filePath, "r+");
3942 ## fs.fdopenStream
3972 let file = fs.openSync(filePath);
3973 fs.fdopenStream(file.fd, "r+").then((stream: fs.Stream) => {
3979 fs.closeSync(file);
3987 ## fs.fdopenStream
4012 let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
4013 fs.fdopenStream(file.fd, "r+", (err: BusinessError, stream: fs.Stream) => {
4020 fs.closeSync(file);
4029 ## fs.fdopenStreamSync
4058 let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE);
4059 let stream = fs.fdopenStreamSync(file.fd, "r+");
4067 ## fs.createReadStream<sup>12+</sup>
4096 const rs = fs.createReadStream(`${pathDir}/read.txt`);
4098 const ws = fs.createWriteStream(`${pathDir}/write.txt`);
4109 ## fs.createWriteStream<sup>12+</sup>
4138 const rs = fs.createReadStream(`${pathDir}/read.txt`);
4140 const ws = fs.createWriteStream(`${pathDir}/write.txt`);
4151 ## fs.createWatcher<sup>10+</sup>
4180 import { fileIo as fs, WatchEvent } from '@kit.CoreFileKit';
4182 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
4183 let watcher = fs.createWatcher(filePath, 0x2 | 0x10, (watchEvent: WatchEvent) => {
4191 fs.writeSync(file.fd, 'test');
4192 fs.closeSync(file);
4257 import { fileIo as fs } from '@kit.CoreFileKit';
4266 let copySignal = new fs.TaskSignal;
4267 let progressListener: fs.ProgressListener = (progress: fs.Progress) => {
4273 let options: fs.CopyOptions = {
4275 "copySignal" : new fs.TaskSignal,
4279 fs.copy(srcDirPathLocal, dstDirUriLocal, options, (err: BusinessError) => {
4313 import { fileIo as fs } from '@kit.CoreFileKit';
4314 import { TaskSignal } from '@ohos.file.fs';
4315 let copySignal: fs.TaskSignal = new TaskSignal();
4345 let copySignal: fs.TaskSignal = new TaskSignal();
4346 let progressListener: fs.ProgressListener = (progress: fs.Progress) => {
4349 let copyOption: fs.CopyOptions = {
4397 let isBLockDevice = fs.statSync(filePath).isBlockDevice();
4422 let isCharacterDevice = fs.statSync(filePath).isCharacterDevice();
4449 let isDirectory = fs.statSync(dirPath).isDirectory();
4474 let isFIFO = fs.statSync(filePath).isFIFO();
4501 let isFile = fs.statSync(filePath).isFile();
4526 let isSocket = fs.statSync(filePath).isSocket();
4551 let isSymbolicLink = fs.statSync(filePath).isSymbolicLink();
4556 文件流,在调用Stream的方法前,需要先通过[fs.createStream](#fscreatestream)方法或者[fs.fdopenStream](#fsfdopenstream)(同步或…
4581 let stream = fs.createStreamSync(filePath, "r+");
4612 let stream = fs.createStreamSync(filePath, "r+");
4638 let stream = fs.createStreamSync(filePath, "r+");
4665 let stream = fs.createStreamSync(filePath, "r+");
4697 let stream = fs.createStreamSync(filePath, "r+");
4724 let stream = fs.createStreamSync(filePath, "r+");
4758 import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
4760 let stream = fs.createStreamSync(filePath, "r+");
4798 import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
4800 let stream = fs.createStreamSync(filePath, "r+");
4846 import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
4848 let stream = fs.createStreamSync(filePath,"r+");
4888 import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
4890 let stream = fs.createStreamSync(filePath, "r+");
4931 import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
4933 let stream = fs.createStreamSync(filePath, "r+");
4979 import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
4981 let stream = fs.createStreamSync(filePath, "r+");
5028 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
5030 fs.closeSync(file);
5062 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
5068 fs.closeSync(file);
5096 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
5103 fs.closeSync(file);
5129 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
5132 fs.closeSync(file);
5151 let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
5155 fs.closeSync(file);
5158 ## fs.DfsListeners<sup>12+</sup>
5212 …let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMod…
5234 …let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMod…
5267 import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
5269 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5270 let randomAccessFile = fs.createRandomAccessFileSync(file);
5284 fs.closeSync(file);
5313 import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
5315 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5316 let randomAccessFile = fs.createRandomAccessFileSync(file);
5333 fs.closeSync(file);
5365 import { fileIo as fs, WriteOptions } from '@kit.CoreFileKit';
5367 …let randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.RE…
5406 import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
5408 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5409 let randomAccessFile = fs.createRandomAccessFileSync(file);
5422 fs.closeSync(file);
5450 import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
5452 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5453 let randomAccessFile = fs.createRandomAccessFileSync(file);
5469 fs.closeSync(file);
5502 let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5503 let randomAccessFile = fs.createRandomAccessFileSync(file);
5508 fs.closeSync(file);
5529 …const randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.…
5553 …const randomAccessFile = fs.createRandomAccessFileSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.…
5580 let watcher = fs.createWatcher(filePath, 0xfff, () => {});
5601 let watcher = fs.createWatcher(filePath, 0xfff, () => {});
5764 文件可读流,需要先通过[fs.createReadStream](#fscreatereadstream12)方法来构建一个ReadStream实例。ReadStream继承自数据流基类[strea…
5805 const rs = fs.createReadStream(filePath);
5806 const curOff = rs.seek(5, fs.WhenceType.SEEK_SET);
5827 const rs = fs.createReadStream(filePath);
5833 文件可写流,需要先通过[fs.createWriteStream](#fscreatewritestream12)方法来构建一个WriteStream实例。WriteStream继承自数据流基类[s…
5871 const ws = fs.createWriteStream(filePath);
5872 const curOff = ws.seek(5, fs.WhenceType.SEEK_SET);
5893 const ws = fs.createWriteStream(filePath);