From 81b97c4887e2f4968449fd4cf38f94d4a0e55d10 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Oct 2004 14:57:43 +0300 Subject: SHOW TABLE STATUS now prints create_time, update_time and check_time for InnoDB tables. Note that these times may always be correct ones, because for example ALTER TABLE creates a table again. innobase/include/os0file.h: Added information of file timestamps and a function os_file_get_status to get that information using stat(). innobase/os/os0file.c: Added function that return information obout the specified file. sql/ha_innodb.cc: Get timestamps for the file where the table is stored. --- innobase/os/os0file.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'innobase/os') diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 6b734bba965..3276aaddca2 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -2359,6 +2359,83 @@ os_file_status( #endif } +/*********************************************************************** +This function returns information about the specified file */ + +ibool +os_file_get_status( +/*===========*/ + /* out: TRUE if stat information found */ + const char* path, /* in: pathname of the file */ + os_file_stat_t* stat_info) /* information of a file in a directory */ +{ +#ifdef __WIN__ + int ret; + struct _stat statinfo; + + ret = _stat(path, &statinfo); + if (ret && (errno == ENOENT || errno == ENOTDIR)) { + /* file does not exist */ + + return(FALSE); + } else if (ret) { + /* file exists, but stat call failed */ + + os_file_handle_error_no_exit(0, path, "stat"); + + return(FALSE); + } + if (_S_IFDIR & statinfo.st_mode) { + stat_info->type = OS_FILE_TYPE_DIR; + } else if (_S_IFREG & statinfo.st_mode) { + stat_info->type = OS_FILE_TYPE_FILE; + } else { + stat_info_>type = OS_FILE_TYPE_UNKNOWN; + } + + stat_info->ctime = statinfo.st_ctime; + stat_info->atime = statinfo.st_atime; + stat_info->mtime = statinfo.st_mtime; + stat_info->size = statinfo.st_size; + + return(TRUE); +#else + int ret; + struct stat statinfo; + + ret = stat(path, &statinfo); + + if (ret && (errno == ENOENT || errno == ENOTDIR)) { + /* file does not exist */ + + return(FALSE); + } else if (ret) { + /* file exists, but stat call failed */ + + os_file_handle_error_no_exit(0, path, "stat"); + + return(FALSE); + } + + if (S_ISDIR(statinfo.st_mode)) { + stat_info->type = OS_FILE_TYPE_DIR; + } else if (S_ISLNK(statinfo.st_mode)) { + stat_info->type = OS_FILE_TYPE_LINK; + } else if (S_ISREG(statinfo.st_mode)) { + stat_info->type = OS_FILE_TYPE_FILE; + } else { + stat_info->type = OS_FILE_TYPE_UNKNOWN; + } + + stat_info->ctime = statinfo.st_ctime; + stat_info->atime = statinfo.st_atime; + stat_info->mtime = statinfo.st_mtime; + stat_info->size = statinfo.st_size; + + return(TRUE); +#endif +} + /* path name separator character */ #ifdef __WIN__ # define OS_FILE_PATH_SEPARATOR '\\' -- cgit v1.2.1