提交 48daad51 编写于 作者: I isidor

pfs, extfs: add statLink

上级 e3a88e9f
......@@ -43,6 +43,26 @@ export function readdir(path: string, callback: (error: Error, files: string[])
return fs.readdir(path, callback);
}
export function statLink(path: string, callback: (error: Error, statAndIsLink: { stat: fs.Stats, isSymbolicLink: boolean }) => void): void {
fs.lstat(path, (error, stat) => {
if (error) {
return callback(error, null);
}
if (stat.isSymbolicLink()) {
fs.stat(path, (error, stat) => {
if (error) {
return callback(error, null);
}
callback(null, { stat, isSymbolicLink: true });
});
} else {
callback(null, { stat, isSymbolicLink: false });
}
});
}
export function copy(source: string, target: string, callback: (error: Error) => void, copiedSources?: { [path: string]: boolean }): void {
if (!copiedSources) {
copiedSources = Object.create(null);
......@@ -628,4 +648,4 @@ export function watch(path: string, onChange: (type: string, path: string) => vo
}
return void 0;
}
\ No newline at end of file
}
......@@ -54,6 +54,16 @@ export function stat(path: string): TPromise<fs.Stats> {
return nfcall(fs.stat, path);
}
export function statLink(path: string): TPromise<{ stat: fs.Stats, isSymbolicLink: boolean }> {
return nfcall(fs.lstat, path).then((stat: fs.Stats) => {
if (stat.isSymbolicLink()) {
return nfcall(fs.stat, path).then(stat => ({ stat, isSymbolicLink: true }));
}
return { stat, isSymbolicLink: false };
});
}
export function lstat(path: string): TPromise<fs.Stats> {
return nfcall(fs.lstat, path);
}
......
......@@ -411,7 +411,7 @@ export interface IFileStat extends IBaseStat {
isDirectory: boolean;
/**
* The resource is a simbolic link.
* The resource is a symbolic link.
*/
isSymbolicLink?: boolean;
......
......@@ -41,8 +41,8 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
}
if (fileStat && fileStat.isSymbolicLink) {
return {
tooltip: localize('symbolicLlink', "Symbolic link"),
letter: '\u21f2'
tooltip: localize('symbolicLlink', "Symbolic Link"),
letter: '\u2937'
};
}
......
......@@ -1233,13 +1233,9 @@ export class StatResolver {
},
function stat(this: any): void {
fs.lstat(fileResource.fsPath, (error, stat) => {
isSymbolicLink = stat.isSymbolicLink();
if (isSymbolicLink) {
fs.stat(fileResource.fsPath, this);
} else {
this(null, stat);
}
extfs.statLink(fileResource.fsPath, (error: Error, statAndIsLink) => {
isSymbolicLink = statAndIsLink.isSymbolicLink;
this(null, statAndIsLink.stat);
});
},
......@@ -1259,7 +1255,7 @@ export class StatResolver {
const childStat: IFileStat = {
resource: fileResource,
isDirectory: fileStat.isDirectory(),
isSymbolicLink: isSymbolicLink,
isSymbolicLink,
name: file,
mtime: fileStat.mtime.getTime(),
etag: etag(fileStat),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册