提交 ba066625 编写于 作者: B Benjamin Pasero

💄

上级 b0bd70e6
......@@ -6,7 +6,7 @@
import { isWindows } from 'vs/base/common/platform';
import { startsWithIgnoreCase, equalsIgnoreCase } from 'vs/base/common/strings';
import { CharCode } from 'vs/base/common/charCode';
import { sep } from 'vs/base/common/path';
import { sep, posix } from 'vs/base/common/path';
function isPathSeparator(code: number) {
return code === CharCode.Slash || code === CharCode.Backslash;
......@@ -18,7 +18,7 @@ function isPathSeparator(code: number) {
* Using it on a Linux or MaxOS path might change it.
*/
export function toSlashes(osPath: string) {
return osPath.replace(/[\\/]/g, '/');
return osPath.replace(/[\\/]/g, posix.sep);
}
/**
......@@ -26,7 +26,7 @@ export function toSlashes(osPath: string) {
* `getRoot('files:///files/path') === files:///`,
* or `getRoot('\\server\shares\path') === \\server\shares\`
*/
export function getRoot(path: string, sep: string = '/'): string {
export function getRoot(path: string, sep: string = posix.sep): string {
if (!path) {
return '';
......
......@@ -219,7 +219,7 @@ export function del(path: string, tmpFolder: string, callback: (error: Error | n
}
function rmRecursive(path: string, callback: (error: Error | null) => void): void {
if (path === '\\' || path === '/') {
if (path === paths.win32.sep || path === paths.posix.sep) {
return callback(new Error('Will not delete root!'));
}
......@@ -277,6 +277,10 @@ function rmRecursive(path: string, callback: (error: Error | null) => void): voi
}
export function delSync(path: string): void {
if (path === paths.win32.sep || path === paths.posix.sep) {
throw new Error('Will not delete root!');
}
try {
const stat = fs.lstatSync(path);
if (stat.isDirectory() && !stat.isSymbolicLink()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册