mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
Implement GetLastModificationTime for linux
This commit is contained in:
parent
7326b861ac
commit
f25a603708
@ -21,14 +21,13 @@
|
|||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/types.h> // required for stat.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 <fcntl.h> /* For O_* constants */
|
||||||
#include <sys/stat.h> /* For mode constants */
|
#include <sys/stat.h> /* For mode constants */
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h> /* For mode constants */
|
|
||||||
#include <fcntl.h> /* For O_* constants */
|
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
@ -163,6 +162,26 @@ void SetCurrentThreadName(const std::string& thread_name) {
|
|||||||
#endif
|
#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() {
|
std::vector<std::string> GetPlatformClangArguments() {
|
||||||
// TODO: use install config variable for path?
|
// TODO: use install config variable for path?
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user