getParentFilePath
Requires a Node.js runtime ('qsu/node')Returns the parent path one level above the given path.
Trailing separators are ignored, so /home/user/ and /home/user share the parent /home. A path with only one segment resolves to the root.
Parameters
| Name | Type | Required | Default |
|---|---|---|---|
filePath | stringStringstr | ● | – |
isWindows named keyword | booleanbool | – | – |
| Whether the target operating system to be checked is Windows | |||
namedThese parameters are passed as named parameters.
keywordThese parameters are passed as keyword arguments, or as a single dict in their place.
Returns
string
String
str
Examples
javascript
getParentFilePath('C:\\Windows\\System32', true); // 'C:\Windows'
getParentFilePath('/home/user/text.txt'); // '/home/user'
getParentFilePath('relative/path'); // '/relative'
getParentFilePath('/home/user/'); // '/home'dart
getParentFilePath('C:\\Windows\\System32', isWindows: true); // 'C:\Windows'
getParentFilePath('/home/user/text.txt'); // '/home/user'
getParentFilePath('relative/path'); // '/relative'
getParentFilePath('/home/user/'); // '/home'python
getParentFilePath('C:\\Windows\\System32', True) # 'C:\Windows'
getParentFilePath('/home/user/text.txt') # '/home/user'
getParentFilePath('relative/path') # '/relative'
getParentFilePath('/home/user/') # '/home'