当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs.close函数代码示例

本文整理汇总了TypeScript中fs.close函数的典型用法代码示例。如果您正苦于以下问题:TypeScript close函数的具体用法?TypeScript close怎么用?TypeScript close使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了close函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: spawnChildren

	// called below
	function spawnChildren(): void {
		for (let i = 0; i < parsetree.length-1; i++) {
			let cmd = parsetree[i];
			let pout = pipes[i][1];
			let opts = {
				// pass our stdin, stdout, stderr to the child
				stdio: [pin, pout, stderr],
			};
			let child = execute_child(cmd, opts, pids, codes);
			fs.close(pipes[i][1]);
			pin = pipes[i][0];
		}
		// execute last command with our stdout
		let cmd = parsetree[parsetree.length-1];
		let opts = {
			// pass our stdin, stdout, stderr to the child
			stdio: [pin, 1, stderr],
		};
		if (cmd[cmd.length - 1] === '&') {
			cmd = cmd.slice(0, cmd.length - 1);
			bg = true;
		}
		let child = execute_child(cmd, opts, pids, codes);
		for (let i = 0; i < pipes.length; i++) {
			fs.close(pipes[i][0]);
		}
	}
开发者ID:anuragagarwal561994,项目名称:browsix,代码行数:28,代码来源:sh.ts

示例2: pipe2

	pipe2((perr: any, rfd: number, wfd: number) => {
		if (perr)
			throw new Error('pipe2 failed: ' + perr);

		let echo = child_process.spawn('/usr/bin/echo', ['hello world'], { stdio: [0, wfd, 2] });
		echo.on('error', (err: any) => {
			process.stderr.write('error: ' + err, () => {
				exit = 1;
				childFinished(err);
			});
		});
		echo.on('exit', (code: number) => {
			childFinished(null, code);
		});

		// XXX: we don't need the wfd at this point, and
		// keeping it open seems to prevent cat from getting
		// an EOF on the pipe?
		fs.close(wfd, () => {
			let cat = child_process.spawn('/usr/bin/cat', [], { stdio: [rfd, 1, 2] });
			cat.on('error', (err: any) => {
				process.stderr.write('error: ' + err, () => {
					childFinished(err);
				});
			});
			cat.on('exit', (code: number) => {
				childFinished(null, code);
			});
			fs.close(rfd);
		});

	});
开发者ID:19anand90,项目名称:browsix,代码行数:32,代码来源:pipeline-example.ts

示例3: function

 fs.read(fd, Buffer.alloc(length), 0, length, resourceOffset, function(
   error: Error,
   bytesRead: number,
   result: Buffer
 ) {
   if (error) {
     return fs.close(fd, function() {
       callback(error, null)
     })
   }
   fs.close(fd, function(err: Error) {
     if (err) {
       return callback(err, result)
     }
     callback(err, encoding ? result.toString(encoding) : result)
   })
 })
开发者ID:zavarat,项目名称:nexe,代码行数:17,代码来源:shim-fs.ts

示例4: async

 FS.write(info.fd, contents, async (err) => {
   if (err) {
     reject(err)
   } else {
     resolve(await gen(info.path))
     FS.close(info.fd, () => FS.unlink(info.path, () => { /*noop*/ }))
   }
 }))
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:8,代码来源:util.ts

示例5: reject

 return new Promise<any>((resolve, reject) => {
     fs.close(fd, (err: any) => {
         if (err) {
             reject(err);
         } else {
             resolve();
         }
     });
 });
开发者ID:eez-open,项目名称:studio,代码行数:9,代码来源:util-electron.ts

示例6: async

				fs.write(fd, buffer, 0, buffer.length, null, (err) => {
					if (err) throw 'Error writing file: ' + err;
					fs.close(fd, async () => {
						const objecthash = git.hashObject(dir, path.join('..', 'Temp', 'whatever'));
						git.addToIndex(dir, objecthash, 'Assets/' + filename);
						const treehash = git.writeTree(dir);
						const sha = git.commitTree(dir, treehash, parenthash);
						resolve(sha);
					});
				});
开发者ID:KTXSoftware,项目名称:KodeGarden,代码行数:10,代码来源:Project.ts

示例7: prependTextToFileSync

export function prependTextToFileSync(filePath: string, fileContent: string) {
    if (isFileExists(filePath)) {
        let data = fs.readFileSync(filePath); // read existing contents into data
        let fd = fs.openSync(filePath, "w+");
        let buffer = new Buffer(fileContent);
        fs.writeSync(fd, buffer, 0, buffer.length, 0); // write new data
        fs.writeSync(fd, data, 0, data.length, 0); // append old data
        fs.close(fd);
    }
}
开发者ID:HSAR,项目名称:vso-agent-tasks,代码行数:10,代码来源:utilities.ts

示例8: function

					fs.open(path, 'wx', function(oerr:  any, fd: number): void {
						if (oerr) {
							// now we're in trouble and
							// we should try other files instead.
							code = 1;
							let msg = pathToScript + ': ' + oerr + '\n';
							process.stderr.write(msg, finished);
						}
						// thats it - close the sucker.
						fs.close(fd, finished);
					});
开发者ID:anuragagarwal561994,项目名称:browsix,代码行数:11,代码来源:touch.ts

示例9: callback

			fs.fdatasync(fd, (syncError: Error) => {

				// In some exotic setups it is well possible that node fails to sync
				// In that case we disable flushing and warn to the console
				if (syncError) {
					console.warn('[node.js fs] fdatasync is now disabled for this session because it failed: ', syncError);
					canFlush = false;
				}

				return fs.close(fd, closeError => callback(closeError));
			});
开发者ID:PKRoma,项目名称:vscode,代码行数:11,代码来源:pfs.ts

示例10:

 inputStream.on('end', () => {
     fs.close(files[name].handler, () => {
         fs.unlink('server/temp/' + name, (err: Error) => {
             if (err) {
                 throw err;
             }
             console.log('File deleted!');
             // Emit a done event to alert the user 
             socket.emit('Done', { path: 'server/files/' + name, name: name });
         });
     });
 });
开发者ID:granuloeldar,项目名称:Zadatak2,代码行数:12,代码来源:app.ts


注:本文中的fs.close函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。