mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Implement GetLastModificationTime for linux
This commit is contained in:
parent
7326b861ac
commit
f25a603708
@ -21,14 +21,13 @@
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h> // required for stat.h
|
||||
#include <sys/stat.h> // no clue why required -- man pages say so
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
#include <fcntl.h> /* For O_* constants */
|
||||
#include <sys/stat.h> /* For mode constants */
|
||||
#include <semaphore.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h> /* For mode constants */
|
||||
#include <fcntl.h> /* For O_* constants */
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <sys/prctl.h>
|
||||
@ -163,6 +162,26 @@ void SetCurrentThreadName(const std::string& thread_name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t GetLastModificationTime(const std::string& absolute_path) {
|
||||
struct stat buf;
|
||||
if (stat(absolute_path.c_str(), &buf) != 0) {
|
||||
switch (errno) {
|
||||
case ENOENT:
|
||||
std::cerr << "GetLastModificationTime: unable to find file " << absolute_path << std::endl;
|
||||
break;
|
||||
case EINVAL:
|
||||
std::cerr << "GetLastModificationTime: invalid param to _stat for file file " << absolute_path << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "GetLastModificationTime: unhandled for " << absolute_path << std::endl;
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetPlatformClangArguments() {
|
||||
// TODO: use install config variable for path?
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user