Mercurial > vim
comparison src/memline.c @ 14599:72d6f6f7ead7 v8.1.0313
patch 8.1.0313: information about a swap file is unavailable
commit https://github.com/vim/vim/commit/00f123a56585363cd13f062fd3bb123efcfaa664
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 21 20:28:54 2018 +0200
patch 8.1.0313: information about a swap file is unavailable
Problem: Information about a swap file is unavailable.
Solution: Add swapinfo(). (Enzo Ferber)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 21 Aug 2018 20:30:05 +0200 |
parents | b6b2f7d69c7f |
children | d0ff19a55579 |
comparison
equal
deleted
inserted
replaced
14598:f480648bd376 | 14599:72d6f6f7ead7 |
---|---|
2038 #endif | 2038 #endif |
2039 | 2039 |
2040 #if (defined(UNIX) || defined(VMS)) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)) | 2040 #if (defined(UNIX) || defined(VMS)) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)) |
2041 static int process_still_running; | 2041 static int process_still_running; |
2042 #endif | 2042 #endif |
2043 | |
2044 /* | |
2045 * Return information found in swapfile "fname" in dictionary "d". | |
2046 * This is used by the swapinfo() function. | |
2047 */ | |
2048 void | |
2049 get_b0_dict(char_u *fname, dict_T *d) | |
2050 { | |
2051 int fd; | |
2052 struct block0 b0; | |
2053 | |
2054 if ((fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0)) >= 0) | |
2055 { | |
2056 if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) | |
2057 { | |
2058 if (b0_magic_wrong(&b0)) | |
2059 { | |
2060 dict_add_string(d, "error", | |
2061 vim_strsave((char_u *)"magic number mismatch")); | |
2062 } | |
2063 else | |
2064 { | |
2065 /* we have swap information */ | |
2066 dict_add_string(d, "version", vim_strsave(b0.b0_version)); | |
2067 dict_add_string(d, "user", vim_strsave(b0.b0_uname)); | |
2068 dict_add_string(d, "host", vim_strsave(b0.b0_hname)); | |
2069 dict_add_string(d, "fname", vim_strsave(b0.b0_fname)); | |
2070 | |
2071 dict_add_number(d, "pid", char_to_long(b0.b0_pid)); | |
2072 dict_add_number(d, "mtime", char_to_long(b0.b0_mtime)); | |
2073 #ifdef CHECK_INODE | |
2074 dict_add_number(d, "inode", char_to_long(b0.b0_ino)); | |
2075 #endif | |
2076 } | |
2077 } | |
2078 else | |
2079 dict_add_string(d, "error", | |
2080 vim_strsave((char_u *)"Cannot read file")); | |
2081 close(fd); | |
2082 } | |
2083 else | |
2084 dict_add_string(d, "error", vim_strsave((char_u *)"Cannot open file")); | |
2085 } | |
2043 | 2086 |
2044 /* | 2087 /* |
2045 * Give information about an existing swap file. | 2088 * Give information about an existing swap file. |
2046 * Returns timestamp (0 when unknown). | 2089 * Returns timestamp (0 when unknown). |
2047 */ | 2090 */ |