本文整理匯總了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
});
});
});
});
});
}