
C++의 `is_executable` 함수는 파일의 실행 권한을 확인하는 데 사용됩니다. 이 함수는 파일이 실행 가능하거나 실행 불가능한지 여부를 boolean 값으로 반환합니다.
#hostingforum.kr
cpp
#include
#include
int main() {
std::ifstream file("example.txt");
if (file.is_open()) {
if (std::filesystem::is_executable(file.path())) {
std::cout << "파일은 실행 가능합니다." << std::endl;
} else {
std::cout << "파일은 실행 불가능합니다." << std::endl;
}
file.close();
} else {
std::cout << "파일을 열 수 없습니다." << std::endl;
}
return 0;
}
위 예제에서 `std::filesystem::is_executable` 함수를 사용하여 파일의 실행 권한을 확인했습니다. `file.path()` 함수를 사용하여 파일의 경로를 얻은 후, `std::filesystem::is_executable` 함수를 호출하여 실행 권한을 확인했습니다.
이러한 방법으로 `is_executable` 함수를 사용하여 파일의 실행 권한을 확인할 수 있습니다.
2025-06-01 13:40