本文整理汇总了TypeScript中fs-extra.lstat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lstat函数的具体用法?TypeScript lstat怎么用?TypeScript lstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lstat函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: verifyWorkspaceContainsDirectory
// Verifies that the test workspace contains the given directory
export default async function verifyWorkspaceContainsDirectory(
args: ActionArgs
) {
const directory = args.nodes.text()
const fullPath = path.join(args.configuration.workspace, directory)
args.formatter.name(
`verifying the ${chalk.bold(
chalk.cyan(directory)
)} directory exists in the test workspace`
)
args.formatter.log(`ls ${fullPath}`)
let stats
try {
stats = await fs.lstat(fullPath)
} catch (err) {
throw new Error(
`directory ${chalk.cyan(
chalk.bold(directory)
)} does not exist in the test workspace`
)
}
if (!stats.isDirectory()) {
throw new Error(
`${chalk.cyan(chalk.bold(directory))} exists but is not a directory`
)
}
}
示例2: checkWorkspaceInformationMatchesWorkspaceFolder
/**
* TODO: Remove function when https://github.com/OmniSharp/omnisharp-roslyn/issues/909 is resolved.
*
* Note: serverUtils.requestWorkspaceInformation only retrieves one folder for multi-root workspaces. Therefore, generator will be incorrect for all folders
* except the first in a workspace. Currently, this only works if the requested folder is the same as the server's solution path or folder.
*/
private async checkWorkspaceInformationMatchesWorkspaceFolder(folder: vscode.WorkspaceFolder | undefined): Promise<boolean> {
const solutionPathOrFolder: string = this.server.getSolutionPathOrFolder();
// Make sure folder, folder.uri, and solutionPathOrFolder are defined.
if (!folder || !folder.uri || !solutionPathOrFolder)
{
return Promise.resolve(false);
}
let serverFolder = solutionPathOrFolder;
// If its a .sln file, get the folder of the solution.
return fs.lstat(solutionPathOrFolder).then(stat => {
return stat.isFile();
}).then(isFile => {
if (isFile)
{
serverFolder = path.dirname(solutionPathOrFolder);
}
// Get absolute paths of current folder and server folder.
const currentFolder = path.resolve(folder.uri.fsPath);
serverFolder = path.resolve(serverFolder);
return currentFolder && folder.uri && isSubfolderOf(serverFolder, currentFolder);
});
}
示例3: catch
async.each(files, (filepath, fileRead) => {
let strPath;
try {
strPath = path.join(folderPath, filepath);
} catch (e) {
return fileRead(null);
}
fs.lstat(strPath, (err, stat) => {
if (err || !stat) {
return fileRead(null);
}
const relevance = getRelevance(strPath);
if (relevance > threshold) {
results.push({
path: strPath,
relevance
});
}
if (stat.isDirectory()) {
recurseFolder(strPath, (err) => {
return fileRead(null);
})
} else {
return fileRead(null);
}
});
}, (err) => {
示例4: readdirRecursive
export default async function* readdirRecursive(
dir: Path
): AsyncIterableIterator<Path> {
for (const file of await fs.readdir(dir)) {
const fullPath = path.join(dir, file);
const stats = await fs.lstat(fullPath);
if (stats.isDirectory()) {
for await (const pth of readdirRecursive(fullPath)) {
yield pth;
}
} else {
yield fullPath;
}
}
}
示例5: readFiles
/** 列举出文件夹内的所有文件 */
async function readFiles(input: string) {
const ans: string[] = [];
const dirs = await fs.readdir(input);
for (let i = 0; i < dirs.length; i++) {
const folder = join(input, dirs[i]);
const stat = await fs.lstat(folder);
if (stat.isDirectory()) {
ans.push(...(await readFiles(folder)));
}
else {
ans.push(folder);
}
}
return ans;
}
示例6: getFileOutputInfo
function getFileOutputInfo(filePath, callback) {
fs.lstat(filePath, (err, stats) => {
if (err) return callback(err);
getPotentialCWLClassFromFile(filePath, (err, cwlClass) => {
if (err) return callback(err);
let isReadable = true;
let isWritable = true;
fs.access(filePath, fs.constants.R_OK, (err) => {
if (err) isReadable = false;
fs.access(filePath, fs.constants.W_OK, (err) => {
if (err) isWritable = false;
callback(null, {
type: cwlClass,
path: filePath,
name: path.basename(filePath),
isDir: stats.isDirectory(),
isFile: stats.isFile(),
dirname: path.dirname(filePath),
language: stats.isFile() ? filePath.split(".").pop() : "",
isWritable,
isReadable
});
});
});
});
});
}