-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track file versions accurately. (#2735)
- Loading branch information
Showing
14 changed files
with
196 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{-# LANGUAGE CPP #-} | ||
|
||
module Development.IDE.Core.FileUtils( | ||
getModTime, | ||
) where | ||
|
||
|
||
import Data.Time.Clock.POSIX | ||
#ifdef mingw32_HOST_OS | ||
import qualified System.Directory as Dir | ||
#else | ||
import System.Posix.Files (getFileStatus, | ||
modificationTimeHiRes) | ||
#endif | ||
|
||
-- Dir.getModificationTime is surprisingly slow since it performs | ||
-- a ton of conversions. Since we do not actually care about | ||
-- the format of the time, we can get away with something cheaper. | ||
-- For now, we only try to do this on Unix systems where it seems to get the | ||
-- time spent checking file modifications (which happens on every change) | ||
-- from > 0.5s to ~0.15s. | ||
-- We might also want to try speeding this up on Windows at some point. | ||
-- TODO leverage DidChangeWatchedFile lsp notifications on clients that | ||
-- support them, as done for GetFileExists | ||
getModTime :: FilePath -> IO POSIXTime | ||
getModTime f = | ||
#ifdef mingw32_HOST_OS | ||
utcTimeToPOSIXSeconds <$> Dir.getModificationTime f | ||
#else | ||
modificationTimeHiRes <$> getFileStatus f | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.