Skip to content

Commit b0acf49

Browse files
author
Benjamin Pasero
committed
paths - move path to extpath
1 parent ac56ab6 commit b0acf49

74 files changed

Lines changed: 257 additions & 257 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/vs/base/common/glob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as arrays from 'vs/base/common/arrays';
77
import * as strings from 'vs/base/common/strings';
8-
import * as extpath from 'vs/base/common/paths';
8+
import * as extpath from 'vs/base/common/extpath';
99
import * as paths from 'vs/base/common/paths.node';
1010
import { LRUCache } from 'vs/base/common/map';
1111
import { CharCode } from 'vs/base/common/charCode';

src/vs/base/common/labels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { URI } from 'vs/base/common/uri';
7-
import { normalize } from 'vs/base/common/paths';
7+
import { normalize } from 'vs/base/common/extpath';
88
import { sep, posix } from 'vs/base/common/paths.node';
99
import { endsWith, ltrim, startsWithIgnoreCase, rtrim, startsWith } from 'vs/base/common/strings';
1010
import { Schemas } from 'vs/base/common/network';

src/vs/base/common/resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as extpath from 'vs/base/common/paths';
6+
import * as extpath from 'vs/base/common/extpath';
77
import * as paths from 'vs/base/common/paths.node';
88
import { URI } from 'vs/base/common/uri';
99
import { equalsIgnoreCase } from 'vs/base/common/strings';

src/vs/base/node/processes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as nls from 'vs/nls';
1010
import * as Types from 'vs/base/common/types';
1111
import { IStringDictionary } from 'vs/base/common/collections';
1212
import * as Objects from 'vs/base/common/objects';
13-
import * as TPath from 'vs/base/common/paths';
13+
import * as extpath from 'vs/base/common/extpath';
1414
import * as Platform from 'vs/base/common/platform';
1515
import { LineDecoder } from 'vs/base/node/decoder';
1616
import { CommandOptions, ForkOptions, SuccessData, Source, TerminateResponse, TerminateResponseCode, Executable } from 'vs/base/common/processes';
@@ -168,7 +168,7 @@ export abstract class AbstractProcess<TProgressData> {
168168
}
169169

170170
public start(pp: ProgressCallback<TProgressData>): Promise<SuccessData> {
171-
if (Platform.isWindows && ((this.options && this.options.cwd && TPath.isUNC(this.options.cwd)) || !this.options && TPath.isUNC(process.cwd()))) {
171+
if (Platform.isWindows && ((this.options && this.options.cwd && extpath.isUNC(this.options.cwd)) || !this.options && extpath.isUNC(process.cwd()))) {
172172
return Promise.reject(new Error(nls.localize('TaskRunner.UNC', 'Can\'t execute a shell command on a UNC drive.')));
173173
}
174174
return this.useExec().then((useExec) => {
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
import * as assert from 'assert';
6+
import * as extpath from 'vs/base/common/extpath';
7+
import * as platform from 'vs/base/common/platform';
8+
9+
suite('Paths', () => {
10+
11+
test('normalize', () => {
12+
assert.equal(extpath.normalize(''), '.');
13+
assert.equal(extpath.normalize('.'), '.');
14+
assert.equal(extpath.normalize('.'), '.');
15+
assert.equal(extpath.normalize('../../far'), '../../far');
16+
assert.equal(extpath.normalize('../bar'), '../bar');
17+
assert.equal(extpath.normalize('../far'), '../far');
18+
assert.equal(extpath.normalize('./'), './');
19+
assert.equal(extpath.normalize('./././'), './');
20+
assert.equal(extpath.normalize('./ff/./'), 'ff/');
21+
assert.equal(extpath.normalize('./foo'), 'foo');
22+
assert.equal(extpath.normalize('/'), '/');
23+
assert.equal(extpath.normalize('/..'), '/');
24+
assert.equal(extpath.normalize('///'), '/');
25+
assert.equal(extpath.normalize('//foo'), '/foo');
26+
assert.equal(extpath.normalize('//foo//'), '/foo/');
27+
assert.equal(extpath.normalize('/foo'), '/foo');
28+
assert.equal(extpath.normalize('/foo/bar.test'), '/foo/bar.test');
29+
assert.equal(extpath.normalize('\\\\\\'), '/');
30+
assert.equal(extpath.normalize('c:/../ff'), 'c:/ff');
31+
assert.equal(extpath.normalize('c:\\./'), 'c:/');
32+
assert.equal(extpath.normalize('foo/'), 'foo/');
33+
assert.equal(extpath.normalize('foo/../../bar'), '../bar');
34+
assert.equal(extpath.normalize('foo/./'), 'foo/');
35+
assert.equal(extpath.normalize('foo/./bar'), 'foo/bar');
36+
assert.equal(extpath.normalize('foo//'), 'foo/');
37+
assert.equal(extpath.normalize('foo//'), 'foo/');
38+
assert.equal(extpath.normalize('foo//bar'), 'foo/bar');
39+
assert.equal(extpath.normalize('foo//bar/far'), 'foo/bar/far');
40+
assert.equal(extpath.normalize('foo/bar/../../far'), 'far');
41+
assert.equal(extpath.normalize('foo/bar/../far'), 'foo/far');
42+
assert.equal(extpath.normalize('foo/far/../../bar'), 'bar');
43+
assert.equal(extpath.normalize('foo/far/../../bar'), 'bar');
44+
assert.equal(extpath.normalize('foo/xxx/..'), 'foo');
45+
assert.equal(extpath.normalize('foo/xxx/../bar'), 'foo/bar');
46+
assert.equal(extpath.normalize('foo/xxx/./..'), 'foo');
47+
assert.equal(extpath.normalize('foo/xxx/./../bar'), 'foo/bar');
48+
assert.equal(extpath.normalize('foo/xxx/./bar'), 'foo/xxx/bar');
49+
assert.equal(extpath.normalize('foo\\bar'), 'foo/bar');
50+
assert.equal(extpath.normalize(null), null);
51+
assert.equal(extpath.normalize(undefined), undefined);
52+
53+
// https://github.com/Microsoft/vscode/issues/7234
54+
assert.equal(extpath.join('/home/aeschli/workspaces/vscode/extensions/css', './syntaxes/css.plist'), '/home/aeschli/workspaces/vscode/extensions/css/syntaxes/css.plist');
55+
});
56+
57+
test('getRootLength', () => {
58+
59+
assert.equal(extpath.getRoot('/user/far'), '/');
60+
assert.equal(extpath.getRoot('\\\\server\\share\\some\\path'), '//server/share/');
61+
assert.equal(extpath.getRoot('//server/share/some/path'), '//server/share/');
62+
assert.equal(extpath.getRoot('//server/share'), '/');
63+
assert.equal(extpath.getRoot('//server'), '/');
64+
assert.equal(extpath.getRoot('//server//'), '/');
65+
assert.equal(extpath.getRoot('c:/user/far'), 'c:/');
66+
assert.equal(extpath.getRoot('c:user/far'), 'c:');
67+
assert.equal(extpath.getRoot('http://www'), '');
68+
assert.equal(extpath.getRoot('http://www/'), 'http://www/');
69+
assert.equal(extpath.getRoot('file:///foo'), 'file:///');
70+
assert.equal(extpath.getRoot('file://foo'), '');
71+
72+
});
73+
74+
test('join', () => {
75+
assert.equal(extpath.join('.', 'bar'), 'bar');
76+
assert.equal(extpath.join('../../foo/bar', '../../foo'), '../../foo');
77+
assert.equal(extpath.join('../../foo/bar', '../bar/foo'), '../../foo/bar/foo');
78+
assert.equal(extpath.join('../foo/bar', '../bar/foo'), '../foo/bar/foo');
79+
assert.equal(extpath.join('/', 'bar'), '/bar');
80+
assert.equal(extpath.join('//server/far/boo', '../file.txt'), '//server/far/file.txt');
81+
assert.equal(extpath.join('/foo/', '/bar'), '/foo/bar');
82+
assert.equal(extpath.join('\\\\server\\far\\boo', '../file.txt'), '//server/far/file.txt');
83+
assert.equal(extpath.join('\\\\server\\far\\boo', './file.txt'), '//server/far/boo/file.txt');
84+
assert.equal(extpath.join('\\\\server\\far\\boo', '.\\file.txt'), '//server/far/boo/file.txt');
85+
assert.equal(extpath.join('\\\\server\\far\\boo', 'file.txt'), '//server/far/boo/file.txt');
86+
assert.equal(extpath.join('file:///c/users/test', 'test'), 'file:///c/users/test/test');
87+
assert.equal(extpath.join('file://localhost/c$/GitDevelopment/express', './settings'), 'file://localhost/c$/GitDevelopment/express/settings'); // unc
88+
assert.equal(extpath.join('file://localhost/c$/GitDevelopment/express', '.settings'), 'file://localhost/c$/GitDevelopment/express/.settings'); // unc
89+
assert.equal(extpath.join('foo', '/bar'), 'foo/bar');
90+
assert.equal(extpath.join('foo', 'bar'), 'foo/bar');
91+
assert.equal(extpath.join('foo', 'bar/'), 'foo/bar/');
92+
assert.equal(extpath.join('foo/', '/bar'), 'foo/bar');
93+
assert.equal(extpath.join('foo/', '/bar/'), 'foo/bar/');
94+
assert.equal(extpath.join('foo/', 'bar'), 'foo/bar');
95+
assert.equal(extpath.join('foo/bar', '../bar/foo'), 'foo/bar/foo');
96+
assert.equal(extpath.join('foo/bar', './bar/foo'), 'foo/bar/bar/foo');
97+
assert.equal(extpath.join('http://localhost/test', '../next'), 'http://localhost/next');
98+
assert.equal(extpath.join('http://localhost/test', 'test'), 'http://localhost/test/test');
99+
});
100+
101+
test('isUNC', () => {
102+
if (platform.isWindows) {
103+
assert.ok(!extpath.isUNC('foo'));
104+
assert.ok(!extpath.isUNC('/foo'));
105+
assert.ok(!extpath.isUNC('\\foo'));
106+
assert.ok(!extpath.isUNC('\\\\foo'));
107+
assert.ok(extpath.isUNC('\\\\a\\b'));
108+
assert.ok(!extpath.isUNC('//a/b'));
109+
assert.ok(extpath.isUNC('\\\\server\\share'));
110+
assert.ok(extpath.isUNC('\\\\server\\share\\'));
111+
assert.ok(extpath.isUNC('\\\\server\\share\\path'));
112+
}
113+
});
114+
115+
test('isValidBasename', () => {
116+
assert.ok(!extpath.isValidBasename(null));
117+
assert.ok(!extpath.isValidBasename(''));
118+
assert.ok(extpath.isValidBasename('test.txt'));
119+
assert.ok(!extpath.isValidBasename('/test.txt'));
120+
assert.ok(!extpath.isValidBasename('\\test.txt'));
121+
122+
if (platform.isWindows) {
123+
assert.ok(!extpath.isValidBasename('aux'));
124+
assert.ok(!extpath.isValidBasename('Aux'));
125+
assert.ok(!extpath.isValidBasename('LPT0'));
126+
assert.ok(!extpath.isValidBasename('test.txt.'));
127+
assert.ok(!extpath.isValidBasename('test.txt..'));
128+
assert.ok(!extpath.isValidBasename('test.txt '));
129+
assert.ok(!extpath.isValidBasename('test.txt\t'));
130+
assert.ok(!extpath.isValidBasename('tes:t.txt'));
131+
assert.ok(!extpath.isValidBasename('tes"t.txt'));
132+
}
133+
});
134+
});

src/vs/base/test/common/paths.test.ts

Lines changed: 0 additions & 134 deletions
This file was deleted.

src/vs/base/test/common/uri.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55
import * as assert from 'assert';
66
import { URI } from 'vs/base/common/uri';
7-
import { normalize } from 'vs/base/common/paths';
7+
import { normalize } from 'vs/base/common/extpath';
88
import { isWindows } from 'vs/base/common/platform';
99

1010

src/vs/base/test/common/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as paths from 'vs/base/common/paths';
6+
import * as extpath from 'vs/base/common/extpath';
77
import { URI } from 'vs/base/common/uri';
88
import { canceled } from 'vs/base/common/errors';
99

@@ -49,7 +49,7 @@ export class DeferredPromise<T> {
4949
}
5050

5151
export function toResource(this: any, path: string) {
52-
return URI.file(paths.join('C:\\', Buffer.from(this.test.fullTitle()).toString('base64'), path));
52+
return URI.file(extpath.join('C:\\', Buffer.from(this.test.fullTitle()).toString('base64'), path));
5353
}
5454

5555
export function suiteRepeat(n: number, description: string, callback: (this: any) => void): void {

src/vs/code/electron-main/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import { hasArgs } from 'vs/platform/environment/node/argv';
6363
import { RunOnceScheduler } from 'vs/base/common/async';
6464
import { registerContextMenuListener } from 'vs/base/parts/contextmenu/electron-main/contextmenu';
6565
import { storeBackgroundColor } from 'vs/code/electron-main/theme';
66-
import { join } from 'vs/base/common/paths';
66+
import { join } from 'vs/base/common/extpath';
6767
import { homedir } from 'os';
6868
import { sep } from 'vs/base/common/paths.node';
6969
import { localize } from 'vs/nls';

0 commit comments

Comments
 (0)