| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4b3cc3c commit 0225fce
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6578,6 +6578,19 @@ The file name that this {fs.Dirent} object refers to. The type of this | |||
| 6578 | 6578 | value is determined by the `options.encoding` passed to [`fs.readdir()`][] or | |
| 6579 | 6579 | [`fs.readdirSync()`][]. | |
| 6580 | 6580 | ||
| 6581 | + #### `dirent.parentPath` | ||
| 6582 | + | ||
| 6583 | + <!-- YAML | ||
| 6584 | + added: | ||
| 6585 | + - REPLACEME | ||
| 6586 | + --> | ||
| 6587 | + | ||
| 6588 | + > Stability: 1 – Experimental | ||
| 6589 | + | ||
| 6590 | + * {string} | ||
| 6591 | + | ||
| 6592 | + The path to the parent directory of the file this {fs.Dirent} object refers to. | ||
| 6593 | + | ||
| 6581 | 6594 | #### `dirent.path` | |
| 6582 | 6595 | ||
| 6583 | 6596 | <!-- YAML | |
@@ -6586,7 +6599,7 @@ added: v20.1.0 | |||
| 6586 | 6599 | ||
| 6587 | 6600 | * {string} | |
| 6588 | 6601 | ||
| 6589 | - The base path that this {fs.Dirent} object refers to. | ||
| 6602 | + Alias for `dirent.parentPath`. | ||
| 6590 | 6603 | ||
| 6591 | 6604 | ### Class: `fs.FSWatcher` | |
| 6592 | 6605 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1426,7 +1426,7 @@ function readdirSyncRecursive(basePath, options) { | |||
| 1426 | 1426 | const dirent = getDirent(path, readdirResult[0][i], readdirResult[1][i]); | |
| 1427 | 1427 | ArrayPrototypePush(readdirResults, dirent); | |
| 1428 | 1428 | if (dirent.isDirectory()) { | |
| 1429 | - ArrayPrototypePush(pathsQueue, pathModule.join(dirent.path, dirent.name)); | ||
| 1429 | + ArrayPrototypePush(pathsQueue, pathModule.join(dirent.parentPath, dirent.name)); | ||
| 1430 | 1430 | } | |
| 1431 | 1431 | } | |
| 1432 | 1432 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,7 +161,7 @@ class Dir { | |||
| 161 | 161 | } | |
| 162 | 162 | ||
| 163 | 163 | readSyncRecursive(dirent) { | |
| 164 | - const path = pathModule.join(dirent.path, dirent.name); | ||
| 164 | + const path = pathModule.join(dirent.parentPath, dirent.name); | ||
| 165 | 165 | const ctx = { path }; | |
| 166 | 166 | const handle = dirBinding.opendir( | |
| 167 | 167 | pathModule.toNamespacedPath(path), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,6 +167,7 @@ function assertEncoding(encoding) { | |||
| 167 | 167 | class Dirent { | |
| 168 | 168 | constructor(name, type, path) { | |
| 169 | 169 | this.name = name; | |
| 170 | + this.parentPath = path; | ||
| 170 | 171 | this.path = path; | |
| 171 | 172 | this[kType] = type; | |
| 172 | 173 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,9 +48,11 @@ const invalidCallbackObj = { | |||
| 48 | 48 | const entries = files.map(() => { | |
| 49 | 49 | const dirent = dir.readSync(); | |
| 50 | 50 | assertDirent(dirent); | |
| 51 | - return dirent.name; | ||
| 52 | - }); | ||
| 53 | - assert.deepStrictEqual(files, entries.sort()); | ||
| 51 | + return { name: dirent.name, path: dirent.path, parentPath: dirent.parentPath, toString() { return dirent.name; } }; | ||
| 52 | + }).sort(); | ||
| 53 | + assert.deepStrictEqual(entries.map((d) => d.name), files); | ||
| 54 | + assert.deepStrictEqual(entries.map((d) => d.path), Array(entries.length).fill(testDir)); | ||
| 55 | + assert.deepStrictEqual(entries.map((d) => d.parentPath), Array(entries.length).fill(testDir)); | ||
| 54 | 56 | ||
| 55 | 57 | // dir.read should return null when no more entries exist | |
| 56 | 58 | assert.strictEqual(dir.readSync(), null); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments