本文整理汇总了TypeScript中kissfs.FileSystemReadSync类的典型用法代码示例。如果您正苦于以下问题:TypeScript FileSystemReadSync类的具体用法?TypeScript FileSystemReadSync怎么用?TypeScript FileSystemReadSync使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileSystemReadSync类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createFs
export function createFs(fileSystem: FileSystemReadSync): any {
return {
readFileSync(path: string) {
path = !legacyBehvior && isWindows ? `/${path.slice(path.lastIndexOf(':') + 1).replace(/\\/g, '/')}` : path;
return fileSystem.loadTextFileSync(path).toString();
},
statSync(path: string) {
path = !legacyBehvior && isWindows ? `/${path.slice(path.lastIndexOf(':') + 1).replace(/\\/g, '/')}` : path;
const s = fileSystem.statSync(path);
const stat = {
type: s.type,
isDirectory() {
return s.type === 'dir';
},
isFile() {
return s.type === 'file';
},
mtime: new Date(Date.now())
};
return stat;
},
readlinkSync(_path: string) {
return null; // require('fs').readlinkSync(_path);
}
};
}
示例2: createDocFs
export function createDocFs(fileSystem: FileSystemReadSync, docs: MinimalDocs): ExtendedFSReadSync {
return {
__proto__: fileSystem,
async loadTextFile(path: string) {
return this.loadTextFileSync(path);
},
loadTextFileSync(path: string) {
const vscodePath: string = toVscodePath(path);
const fromDocs = docs.get(vscodePath);
return fromDocs ? fromDocs.getText() : fileSystem.loadTextFileSync(fromVscodePath(path));
},
loadDirectoryTreeSync(path: string) {
return fileSystem.loadDirectoryTreeSync(path);
},
get(path: string) {
return (
docs.get(path) || TextDocument.create(path, 'stylable', 0, this.loadTextFileSync(fromVscodePath(path)))
);
},
getOpenedFiles() {
return docs.keys();
}
} as any;
}
示例3: readFile
function readFile(filePath: string): string | undefined {
try {
return syncFs.loadTextFileSync(filePath);
} catch {
return;
}
}
示例4: fileExists
function fileExists(fullPath: string) {
try {
syncFs.loadTextFileSync(fullPath);
return true;
} catch (error) {
return false;
}
}
示例5: getFileSystemEntries
function getFileSystemEntries(path: string): ts.FileSystemEntries {
const files: string[] = [];
const directories: string[] = [];
const entries = syncFs.loadDirectoryChildrenSync(path);
for (const entry of entries) {
if (entry.type === 'file') {
files.push(entry.name);
} else {
directories.push(entry.name);
}
}
return { files, directories };
}