如何用c 監控windows和linux資料夾中檔案的變化,有沒有什麼api可以讓系統在儲存檔案的時候通知程式?

時間 2021-06-02 11:12:29

1樓:wjhbb

參考這個Quora答案:What does Dropbox use to monitor file changes in the Dropbox folder?

Dropbox的Linux版是開源的:https://linux.dropbox.com/packages/

從中應能看出他們是怎麼實現的。

在Mac上,參考這個stackoverflow問題osx - How does the DropBox Mac client work?

還可參考:osx - Is there a command like "watch" or "inotifywait" on the Mac?

2樓:楚天樂

linux和mac我不清楚, 只做過windows

windows下面監控檔案變動就那麼幾個函式,樓上已經有人提過了。重點是在R3層處理這種變動訊息的時候一定不能有阻塞,否則會丟失通知訊息的。配合IO完成埠來使用是乙個辦法。

3樓:黎欣健

win下面明顯有

FindFirstChangeNotification和 ReadDirectoryChanges

這兩個api可以用來監控檔案變化

相關工具參考 FileMon

如何用c 編寫串列埠監控軟體? 監控某個串列埠的資料接受和傳送

When you select a port to monitor,Portmon sends a request to its device driver that includes the NT name e.g.device serial0 that you are interested in...

Windows 的 PowerShell 和 Linux 的 terminal 有啥區別?

powershell是個shell,terminal是個terminal.微軟自己有乙個terminal產品叫windows terminal,linux裡面的shell也有很多種,常見的比如bash,zsh,fish 今天也要加油鴨 長得像的兩個功能類似的玩意。但是用法多不一樣。不過windows...

如何用C 告白?

負一的平方根 class MyHeart switch You request try catch Failuree while You Love Me true true 養不熟的狼 第一次寫,你猜我輸出的是什麼呢 include include include using namespace s...