본문으로 건너뛰기

getParentFilePath

Node.js 런타임 필요 ('qsu/node')

지정된 경로보다 한 단계 위의 상위 경로를 반환합니다.

후행 구분자는 무시되므로 /home/user//home/user의 상위 경로는 모두 /home입니다. 세그먼트가 하나뿐인 경로는 루트로 해석됩니다.

Parameters

이름타입필수기본값
filePathstringStringstr
isWindowsnamedkeywordbooleanbool
Whether the target operating system to be checked is Windows

named이 파라미터는 named 파라미터로 전달합니다.

keyword이 파라미터는 키워드 인자로 전달하거나, 대신 dict 하나로 전달합니다.

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'

Released under the MIT License