2
유닉스 기반 시스템에서 파일 수정을 감시해야하며 Boost에 액세스 할 수 없습니다. 다음 논리가 맞는지 궁금합니다. 나는 아마 비효율적이라고 생각합니다. while 회 돌이에서 잠을 자지 않아서 많은 양의 사이클을 낭비하고 있다는 것을 알았지 만, 파일이 수정 사이에 얼마나 오랫동안 들어갈 지 아무 견적도 없습니다. 그리고 나는 알아야합니다. 비교적 빨리 :파일 통계 시간 비교
std::time_t getTimeLastModified(const char* filename){
struct stat fileattrib;
stat(filename, &fileattrib);
return fileattrib.st_mtime;
}
int main(){
std::time_t file1_modified_time = getTimeLastModified(coor_file.c_str());
while(difftime(getTimeLastModified(coor_file.c_str()),file1_modified_time)==0){}
// If program execution gets here, file has been modified
}
커널에서 'inotify'를 사용할 수없는 이유는 무엇입니까? –
inotify는 현재 작업중인 프로덕션 시스템에서 사용할 수 없습니다. 이 시스템에서 커널을 다시 컴파일 할 수없고 시스템에 루트 액세스 권한도 없습니다. – cooper