(path: string)
| 409 | private async getNodeByName(parentNode: NodeEntity, name: string) { |
| 410 | for await (const maybeChild of this.publicLinkSdk.iterateFolderChildren(parentNode)) { |
| 411 | if (getName(maybeChild) === name) { |
| 412 | return maybeChild; |
| 413 | } |
| 414 | } |
| 415 | throw new ValidationError(`Node not found: ${name}`); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | export function pathDirname(fullPath: string): string { |
| 420 | const segments = splitPathSegments(fullPath); |
| 421 | return joinPathSegments(segments.slice(0, -1)); |
| 422 | } |
| 423 | |
| 424 | export function pathBasename(fullPath: string): string { |
| 425 | const segments = splitPathSegments(fullPath); |
| 426 | return segments[segments.length - 1] ?? ''; |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Split a remote path into segments. Unescaped `/` separates segments; `\/` is literal `/`. |
| 431 | */ |
| 432 | export function splitPathSegments(path: string): string[] { |
| 433 | const segments: string[] = []; |
| 434 | let current = ''; |
| 435 | |
| 436 | for (let i = 0; i < path.length; i++) { |
| 437 | const char = path[i]; |
| 438 | if (char === '\\' && i + 1 < path.length) { |
no outgoing calls
no test coverage detected