1
>
/*---------------------------------------------------------------------------------------------
environmentService.ts
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
>
6
>
import { toLocalISOString } from '../../../base/common/date.js';
7
>
import { memoize } from '../../../base/common/decorators.js';
8
>
import { FileAccess, Schemas } from '../../../base/common/network.js';
9
>
import { dirname, join, normalize, resolve } from '../../../base/common/path.js';
10
>
import { env } from '../../../base/common/process.js';
11
>
import { joinPath } from '../../../base/common/resources.js';
12
>
import { URI } from '../../../base/common/uri.js';
13
>
import { NativeParsedArgs } from './argv.js';
14
>
import { ExtensionKind, IExtensionHostDebugParams, INativeEnvironmentService } from './environment.js';
15
>
import { IProductService } from '../../product/common/productService.js';
16
>
17
>
export const EXTENSION_IDENTIFIER_WITH_LOG_REGEX = /^([^.]+\..+)[:=](.+)$/;
18
>
19
>
export interface INativeEnvironmentPaths {
20
>
21
>
/**
22
>
* The user data directory to use for anything that should be
23
>
* persisted except for the content that is meant for the `homeDir`.
24
>
*
25
>
* Only one instance of VSCode can use the same `userDataDir`.
26
>
*/
27
>
userDataDir: string;
28
>
29
>
/**
30
>
* The user home directory mainly used for persisting extensions
31
>
* and global configuration that should be shared across all
32
>
* versions.
33
>
*/
34
>
homeDir: string;
35
>
36
>
/**
37
>
* OS tmp dir.
38
>
*/
39
>
tmpDir: string;
40
>
}
41
>
42
>
export abstract class AbstractNativeEnvironmentService implements INativeEnvironmentService {
43
>
44
>
declare readonly _serviceBrand: undefined;
45
>
46
>
@memoize
47
>
get appRoot(): string { return dirname(FileAccess.asFileUri('').fsPath); }
48
>
49
>
@memoize
50
>
get userHome(): URI { return URI.file(this.paths.homeDir); }
51
>
52
>
@memoize
53
>
get userDataPath(): string { return this.paths.userDataDir; }
54
>
55
>
@memoize
56
>
get appSettingsHome(): URI { return URI.file(join(this.userDataPath, 'User')); }
57
>
58
>
@memoize
59
>
get tmpDir(): URI { return URI.file(this.paths.tmpDir); }
60
>
61
>
@memoize
62
>
get cacheHome(): URI { return URI.file(this.userDataPath); }
63
>
64
>
@memoize
65
>
get stateResource(): URI { return joinPath(this.appSettingsHome, 'globalStorage', 'storage.json'); }
66
>
67
>
@memoize
68
>
get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.vscodeUserData }); }
69
>
70
>
@memoize
71
>
get userDataSyncHome(): URI { return joinPath(this.appSettingsHome, 'sync'); }
72
>
73
>
get logsHome(): URI {
74
if (!this.args.logsPath) {
75
const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '');