summaryrefslogtreecommitdiff
path: root/innobase/os/os0file.c
diff options
context:
space:
mode:
authorunknown <jan@hundin.mysql.fi>2004-10-21 14:57:43 +0300
committerunknown <jan@hundin.mysql.fi>2004-10-21 14:57:43 +0300
commit81b97c4887e2f4968449fd4cf38f94d4a0e55d10 (patch)
tree9cf709de255952b9392635277a38fc453b1596cf /innobase/os/os0file.c
parent433aec148f687712f324a2b9443d577c23d8c598 (diff)
downloadmariadb-git-81b97c4887e2f4968449fd4cf38f94d4a0e55d10.tar.gz
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.
Diffstat (limited to 'innobase/os/os0file.c')
-rw-r--r--innobase/os/os0file.c77
1 files changed, 77 insertions, 0 deletions
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 '\\'