當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。