Skip to content

Commit 27e3219

Browse files
committed
Extract PosixModeBits.ts into a separate source file
1 parent 1a1efd9 commit 27e3219

8 files changed

Lines changed: 113 additions & 103 deletions

File tree

‎libraries/node-core-library/src/Executable.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as child_process from 'child_process';
55
import * as os from 'os';
66
import * as path from 'path';
77

8-
import { FileSystem, PosixModeBits } from './FileSystem';
8+
import { FileSystem } from './FileSystem';
9+
import { PosixModeBits } from './PosixModeBits';
910

1011
/**
1112
* Typings for one of the streams inside IExecutableSpawnSyncOptions.stdio.

‎libraries/node-core-library/src/FileDiffTest.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as path from 'path';
55

66
import { PackageJsonLookup } from './PackageJsonLookup';
77
import { Text } from './Text';
8-
import { FileSystem, PosixModeBits } from './FileSystem';
8+
import { FileSystem } from './FileSystem';
9+
import { PosixModeBits } from './PosixModeBits';
910

1011
/**
1112
* Implements a unit testing strategy that generates output files, and then

‎libraries/node-core-library/src/FileSystem.ts‎

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -5,108 +5,12 @@ import * as pathUtilities from 'path';
55
import * as fs from 'fs';
66
import * as fsx from 'fs-extra';
77

8-
import { Text, NewlineKind } from './Text';
8+
import { Text, NewlineKind, Encoding } from './Text';
9+
import { PosixModeBits } from './PosixModeBits';
910

1011
// The PosixModeBits are intended to be used with bitwise operations.
1112
// tslint:disable:no-bitwise
1213

13-
/**
14-
* The allowed types of encodings, as supported by Node.js
15-
* @public
16-
*/
17-
export const enum Encoding {
18-
Utf8 = 'utf8'
19-
}
20-
21-
/**
22-
* An integer value used to specify file permissions for POSIX-like operating systems.
23-
*
24-
* @remarks
25-
*
26-
* This bitfield corresponds to the "mode_t" structure described in this document:
27-
* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
28-
*
29-
* It is used with NodeJS APIs such as fs.Stat.mode and fs.chmodSync(). These values
30-
* represent a set of permissions and can be combined using bitwise arithmetic.
31-
*
32-
* POSIX is a registered trademark of the Institute of Electrical and Electronic Engineers, Inc.
33-
*
34-
* @public
35-
*/
36-
export const enum PosixModeBits {
37-
// The bits
38-
39-
/**
40-
* Indicates that the item's owner can read the item.
41-
*/
42-
UserRead = 1 << 8,
43-
44-
/**
45-
* Indicates that the item's owner can modify the item.
46-
*/
47-
UserWrite = 1 << 7,
48-
49-
/**
50-
* Indicates that the item's owner can execute the item (if it is a file)
51-
* or search the item (if it is a directory).
52-
*/
53-
UserExecute = 1 << 6,
54-
55-
/**
56-
* Indicates that users belonging to the item's group can read the item.
57-
*/
58-
GroupRead = 1 << 5,
59-
60-
/**
61-
* Indicates that users belonging to the item's group can modify the item.
62-
*/
63-
GroupWrite = 1 << 4,
64-
65-
/**
66-
* Indicates that users belonging to the item's group can execute the item (if it is a file)
67-
* or search the item (if it is a directory).
68-
*/
69-
GroupExecute = 1 << 3,
70-
71-
/**
72-
* Indicates that other users (besides the item's owner user or group) can read the item.
73-
*/
74-
OthersRead = 1 << 2,
75-
76-
/**
77-
* Indicates that other users (besides the item's owner user or group) can modify the item.
78-
*/
79-
OthersWrite = 1 << 1,
80-
81-
/**
82-
* Indicates that other users (besides the item's owner user or group) can execute the item (if it is a file)
83-
* or search the item (if it is a directory).
84-
*/
85-
OthersExecute = 1 << 0,
86-
87-
// Helpful aliases
88-
89-
/**
90-
* A zero value where no permissions bits are set.
91-
*/
92-
None = 0,
93-
94-
/**
95-
* An alias combining OthersRead, GroupRead, and UserRead permission bits.
96-
*/
97-
AllRead = OthersRead | GroupRead | UserRead,
98-
99-
/**
100-
* An alias combining OthersWrite, GroupWrite, and UserWrite permission bits.
101-
*/
102-
AllWrite = OthersWrite | GroupWrite | UserWrite,
103-
104-
/**
105-
* An alias combining OthersExecute, GroupExecute, and UserExecute permission bits.
106-
*/
107-
AllExecute = OthersExecute | GroupExecute | UserExecute
108-
}
109-
11014
/**
11115
* The options for FileSystem.readFolder()
11216
* @public
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
// The PosixModeBits are intended to be used with bitwise operations.
5+
// tslint:disable:no-bitwise
6+
7+
/**
8+
* An integer value used to specify file permissions for POSIX-like operating systems.
9+
*
10+
* @remarks
11+
*
12+
* This bitfield corresponds to the "mode_t" structure described in this document:
13+
* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
14+
*
15+
* It is used with NodeJS APIs such as fs.Stat.mode and fs.chmodSync(). These values
16+
* represent a set of permissions and can be combined using bitwise arithmetic.
17+
*
18+
* POSIX is a registered trademark of the Institute of Electrical and Electronic Engineers, Inc.
19+
*
20+
* @public
21+
*/
22+
export const enum PosixModeBits {
23+
// The bits
24+
25+
/**
26+
* Indicates that the item's owner can read the item.
27+
*/
28+
UserRead = 1 << 8,
29+
30+
/**
31+
* Indicates that the item's owner can modify the item.
32+
*/
33+
UserWrite = 1 << 7,
34+
35+
/**
36+
* Indicates that the item's owner can execute the item (if it is a file)
37+
* or search the item (if it is a directory).
38+
*/
39+
UserExecute = 1 << 6,
40+
41+
/**
42+
* Indicates that users belonging to the item's group can read the item.
43+
*/
44+
GroupRead = 1 << 5,
45+
46+
/**
47+
* Indicates that users belonging to the item's group can modify the item.
48+
*/
49+
GroupWrite = 1 << 4,
50+
51+
/**
52+
* Indicates that users belonging to the item's group can execute the item (if it is a file)
53+
* or search the item (if it is a directory).
54+
*/
55+
GroupExecute = 1 << 3,
56+
57+
/**
58+
* Indicates that other users (besides the item's owner user or group) can read the item.
59+
*/
60+
OthersRead = 1 << 2,
61+
62+
/**
63+
* Indicates that other users (besides the item's owner user or group) can modify the item.
64+
*/
65+
OthersWrite = 1 << 1,
66+
67+
/**
68+
* Indicates that other users (besides the item's owner user or group) can execute the item (if it is a file)
69+
* or search the item (if it is a directory).
70+
*/
71+
OthersExecute = 1 << 0,
72+
73+
// Helpful aliases
74+
75+
/**
76+
* A zero value where no permissions bits are set.
77+
*/
78+
None = 0,
79+
80+
/**
81+
* An alias combining OthersRead, GroupRead, and UserRead permission bits.
82+
*/
83+
AllRead = OthersRead | GroupRead | UserRead,
84+
85+
/**
86+
* An alias combining OthersWrite, GroupWrite, and UserWrite permission bits.
87+
*/
88+
AllWrite = OthersWrite | GroupWrite | UserWrite,
89+
90+
/**
91+
* An alias combining OthersExecute, GroupExecute, and UserExecute permission bits.
92+
*/
93+
AllExecute = OthersExecute | GroupExecute | UserExecute
94+
}

‎libraries/node-core-library/src/Text.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
/**
5+
* The allowed types of encodings, as supported by Node.js
6+
* @public
7+
*/
8+
export const enum Encoding {
9+
Utf8 = 'utf8'
10+
}
11+
412
/**
513
* Enumeration controlling conversion of newline characters.
614
* @public

‎libraries/node-core-library/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export {
4242
export {
4343
MapExtensions
4444
} from './MapExtensions';
45+
export { PosixModeBits } from './PosixModeBits';
4546
export {
4647
ProtectableMap,
4748
IProtectableMapParameters
@@ -60,7 +61,6 @@ export {
6061
IReadFileOptions,
6162
IFileSystemMoveOptions,
6263
IDeleteFileOptions,
63-
PosixModeBits,
6464
IUpdateTimeParameters
6565
} from './FileSystem';
6666
export {

‎libraries/node-core-library/src/test/Executable.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import * as path from 'path';
66
import * as child_process from 'child_process';
77

88
import { Executable, IExecutableSpawnSyncOptions } from '../Executable';
9-
import { FileSystem, PosixModeBits } from '../FileSystem';
9+
import { FileSystem } from '../FileSystem';
10+
import { PosixModeBits } from '../PosixModeBits';
1011
import { Text } from '../Text';
1112

1213
// The PosixModeBits are intended to be used with bitwise operations.

‎libraries/node-core-library/src/test/FileSystem.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import { FileSystem, PosixModeBits } from '../FileSystem';
4+
import { FileSystem } from '../FileSystem';
5+
import { PosixModeBits } from '../PosixModeBits';
56

67
// The PosixModeBits are intended to be used with bitwise operations.
78
// tslint:disable:no-bitwise

0 commit comments

Comments
 (0)