diff options
-rw-r--r-- | src/nvim/diff.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 6 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/fileio.c | 30 | ||||
-rw-r--r-- | src/nvim/if_cscope.c | 4 | ||||
-rw-r--r-- | src/nvim/main.c | 4 | ||||
-rw-r--r-- | src/nvim/memfile.c | 5 | ||||
-rw-r--r-- | src/nvim/memline.c | 18 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 6 | ||||
-rw-r--r-- | src/nvim/os_unix.c | 4 | ||||
-rw-r--r-- | src/nvim/path.c | 8 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 2 | ||||
-rw-r--r-- | src/nvim/undo.c | 8 | ||||
-rw-r--r-- | test/unit/os/fs_spec.lua | 50 |
14 files changed, 74 insertions, 75 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index e5fa277671..8b0bf4e997 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -948,7 +948,7 @@ void ex_diffpatch(exarg_T *eap) // Only continue if the output file was created. FileInfo file_info; - bool info_ok = os_get_file_info((char *)tmp_new, &file_info); + bool info_ok = os_fileinfo((char *)tmp_new, &file_info); off_t filesize = os_fileinfo_size(&file_info); if (!info_ok || filesize == 0) { EMSG(_("E816: Cannot read patch output")); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ff436a5d75..b1943bae86 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9166,7 +9166,7 @@ static void f_getfsize(typval_T *argvars, typval_T *rettv) rettv->v_type = VAR_NUMBER; FileInfo file_info; - if (os_get_file_info(fname, &file_info)) { + if (os_fileinfo(fname, &file_info)) { off_t filesize = os_fileinfo_size(&file_info); if (os_isdir((char_u *)fname)) rettv->vval.v_number = 0; @@ -9191,7 +9191,7 @@ static void f_getftime(typval_T *argvars, typval_T *rettv) char *fname = (char *)get_tv_string(&argvars[0]); FileInfo file_info; - if (os_get_file_info(fname, &file_info)) { + if (os_fileinfo(fname, &file_info)) { rettv->vval.v_number = (varnumber_T)file_info.stat.st_mtim.tv_sec; } else { rettv->vval.v_number = -1; @@ -9211,7 +9211,7 @@ static void f_getftype(typval_T *argvars, typval_T *rettv) rettv->v_type = VAR_STRING; FileInfo file_info; - if (os_get_file_info_link((char *)fname, &file_info)) { + if (os_fileinfo_link((char *)fname, &file_info)) { uint64_t mode = file_info.stat.st_mode; #ifdef S_ISREG if (S_ISREG(mode)) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 5b6604fc93..18216f6924 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1533,7 +1533,7 @@ void write_viminfo(char_u *file, int forceit) */ FileInfo old_info; // FileInfo of existing viminfo file - if (os_get_file_info((char *)fname, &old_info) + if (os_fileinfo((char *)fname, &old_info) && getuid() != ROOT_UID && !(old_info.stat.st_uid == getuid() ? (old_info.stat.st_mode & 0200) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index b2d27bd0d1..daff9aa4c6 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -472,7 +472,7 @@ readfile ( if (newfile && !read_stdin && !read_buffer) { /* Remember time of file. */ FileInfo file_info; - if (os_get_file_info((char *)fname, &file_info)) { + if (os_fileinfo((char *)fname, &file_info)) { buf_store_file_info(curbuf, &file_info); curbuf->b_mtime_read = curbuf->b_mtime; #ifdef UNIX @@ -2583,7 +2583,7 @@ buf_write ( #if defined(UNIX) perm = -1; FileInfo file_info_old; - if (!os_get_file_info((char *)fname, &file_info_old)) { + if (!os_fileinfo((char *)fname, &file_info_old)) { newfile = TRUE; } else { perm = file_info_old.stat.st_mode; @@ -2629,7 +2629,7 @@ buf_write ( goto fail; } if (overwriting) { - os_get_file_info((char *)fname, &file_info_old); + os_fileinfo((char *)fname, &file_info_old); } } @@ -2713,7 +2713,7 @@ buf_write ( * - we don't have write permission in the directory */ if (os_fileinfo_hardlinks(&file_info_old) > 1 - || !os_get_file_info_link((char *)fname, &file_info) + || !os_fileinfo_link((char *)fname, &file_info) || !os_file_info_id_equal(&file_info, &file_info_old)) { backup_copy = TRUE; } else @@ -2728,7 +2728,7 @@ buf_write ( STRCPY(IObuff, fname); for (i = 4913;; i += 123) { sprintf((char *)path_tail(IObuff), "%d", i); - if (!os_get_file_info_link((char *)IObuff, &file_info)) { + if (!os_fileinfo_link((char *)IObuff, &file_info)) { break; } } @@ -2739,7 +2739,7 @@ buf_write ( else { # ifdef UNIX os_fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); - if (!os_get_file_info((char *)IObuff, &file_info) + if (!os_fileinfo((char *)IObuff, &file_info) || file_info.stat.st_uid != file_info_old.stat.st_uid || file_info.stat.st_gid != file_info_old.stat.st_gid || (long)file_info.stat.st_mode != perm) { @@ -2759,7 +2759,7 @@ buf_write ( */ if ((bkc_flags & BKC_BREAKSYMLINK) || (bkc_flags & BKC_BREAKHARDLINK)) { # ifdef UNIX - bool file_info_link_ok = os_get_file_info_link((char *)fname, &file_info); + bool file_info_link_ok = os_fileinfo_link((char *)fname, &file_info); /* Symlinks. */ if ((bkc_flags & BKC_BREAKSYMLINK) @@ -2837,7 +2837,7 @@ buf_write ( /* * Check if backup file already exists. */ - if (os_get_file_info((char *)backup, &file_info_new)) { + if (os_fileinfo((char *)backup, &file_info_new)) { /* * Check if backup file is same as original file. * May happen when modname() gave the same file back (e.g. silly @@ -2861,7 +2861,7 @@ buf_write ( wp = backup; *wp = 'z'; while (*wp > 'a' - && os_get_file_info((char *)backup, &file_info_new)) { + && os_fileinfo((char *)backup, &file_info_new)) { --*wp; } /* They all exist??? Must be something wrong. */ @@ -3202,7 +3202,7 @@ nobackup: /* Don't delete the file when it's a hard or symbolic link. */ if ((!newfile && os_fileinfo_hardlinks(&file_info) > 1) - || (os_get_file_info_link((char *)fname, &file_info) + || (os_fileinfo_link((char *)fname, &file_info) && !os_file_info_id_equal(&file_info, &file_info_old))) { errmsg = (char_u *)_("E166: Can't open linked file for writing"); } else @@ -3416,7 +3416,7 @@ restore_backup: /* don't change the owner when it's already OK, some systems remove * permission or ACL stuff */ FileInfo file_info; - if (!os_get_file_info((char *)wfname, &file_info) + if (!os_fileinfo((char *)wfname, &file_info) || file_info.stat.st_uid != file_info_old.stat.st_uid || file_info.stat.st_gid != file_info_old.stat.st_gid) { os_fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); @@ -3713,7 +3713,7 @@ nofail: /* Update the timestamp to avoid an "overwrite changed file" * prompt when writing again. */ - if (os_get_file_info((char *)fname, &file_info_old)) { + if (os_fileinfo((char *)fname, &file_info_old)) { buf_store_file_info(buf, &file_info_old); buf->b_mtime_read = buf->b_mtime; } @@ -4536,7 +4536,7 @@ int vim_rename(char_u *from, char_u *to) // Fail if the "from" file doesn't exist. Avoids that "to" is deleted. FileInfo from_info; - if (!os_get_file_info((char *)from, &from_info)) { + if (!os_fileinfo((char *)from, &from_info)) { return -1; } @@ -4544,7 +4544,7 @@ int vim_rename(char_u *from, char_u *to) // This happens when "from" and "to" differ in case and are on a FAT32 // filesystem. In that case go through a temp file name. FileInfo to_info; - if (os_get_file_info((char *)to, &to_info) + if (os_fileinfo((char *)to, &to_info) && os_file_info_id_equal(&from_info, &to_info)) { use_tmp_file = true; } @@ -4812,7 +4812,7 @@ buf_check_timestamp ( bool file_info_ok; if (!(buf->b_flags & BF_NOTEDITED) && buf->b_mtime != 0 - && (!(file_info_ok = os_get_file_info((char *)buf->b_ffname, &file_info)) + && (!(file_info_ok = os_fileinfo((char *)buf->b_ffname, &file_info)) || time_differs((long)file_info.stat.st_mtim.tv_sec, buf->b_mtime) || (int)file_info.stat.st_mode != buf->b_orig_mode )) { diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 9e07a60ee1..691b83011d 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -473,7 +473,7 @@ cs_add_common ( fname = (char *)vim_strnsave((char_u *)fname, len); free(fbuf); FileInfo file_info; - bool file_info_ok = os_get_file_info(fname, &file_info); + bool file_info_ok = os_fileinfo(fname, &file_info); if (!file_info_ok) { staterr: if (p_csverbose) @@ -504,7 +504,7 @@ staterr: else (void)sprintf(fname2, "%s/%s", fname, CSCOPE_DBFILE); - file_info_ok = os_get_file_info(fname2, &file_info); + file_info_ok = os_fileinfo(fname2, &file_info); if (!file_info_ok) { if (p_csverbose) cs_stat_emsg(fname2); diff --git a/src/nvim/main.c b/src/nvim/main.c index 2f06a2cbf2..9ab46b1ce2 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2094,9 +2094,9 @@ static int file_owned(char *fname) { uid_t uid = getuid(); FileInfo file_info; - bool file_owned = os_get_file_info(fname, &file_info) + bool file_owned = os_fileinfo(fname, &file_info) && file_info.stat.st_uid == uid; - bool link_owned = os_get_file_info_link(fname, &file_info) + bool link_owned = os_fileinfo_link(fname, &file_info) && file_info.stat.st_uid == uid; return file_owned && link_owned; } diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index be8148c28d..827cff2299 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -122,8 +122,7 @@ memfile_T *mf_open(char_u *fname, int flags) * mf_blocknr_max must be rounded up. */ FileInfo file_info; - if (mfp->mf_fd >= 0 - && os_get_file_info_fd(mfp->mf_fd, &file_info)) { + if (mfp->mf_fd >= 0 && os_fileinfo_fd(mfp->mf_fd, &file_info)) { uint64_t blocksize = os_fileinfo_blocksize(&file_info); if (blocksize >= MIN_SWAP_PAGE_SIZE && blocksize <= MAX_SWAP_PAGE_SIZE) { mfp->mf_page_size = blocksize; @@ -1018,7 +1017,7 @@ mf_do_open ( */ FileInfo file_info; if ((flags & O_CREAT) - && os_get_file_info_link((char *)mfp->mf_fname, &file_info)) { + && os_fileinfo_link((char *)mfp->mf_fname, &file_info)) { mfp->mf_fd = -1; EMSG(_("E300: Swap file already exists (symlink attack?)")); } else { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index c19d08a396..c6e119562c 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -686,7 +686,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) } } FileInfo file_info; - if (os_get_file_info((char *)buf->b_ffname, &file_info)) { + if (os_fileinfo((char *)buf->b_ffname, &file_info)) { long_to_char((long)file_info.stat.st_mtim.tv_sec, b0p->b0_mtime); long_to_char((long)os_file_info_get_inode(&file_info), b0p->b0_ino); buf_store_file_info(buf, &file_info); @@ -961,8 +961,8 @@ void ml_recover(void) FileInfo swp_file_info; mtime = char_to_long(b0p->b0_mtime); if (curbuf->b_ffname != NULL - && os_get_file_info((char *)curbuf->b_ffname, &org_file_info) - && ((os_get_file_info((char *)mfp->mf_fname, &swp_file_info) + && os_fileinfo((char *)curbuf->b_ffname, &org_file_info) + && ((os_fileinfo((char *)mfp->mf_fname, &swp_file_info) && org_file_info.stat.st_mtim.tv_sec > swp_file_info.stat.st_mtim.tv_sec) || org_file_info.stat.st_mtim.tv_sec != mtime)) { @@ -1494,7 +1494,7 @@ static time_t swapfile_info(char_u *fname) /* print the swap file date */ FileInfo file_info; - if (os_get_file_info((char *)fname, &file_info)) { + if (os_fileinfo((char *)fname, &file_info)) { #ifdef UNIX /* print name of owner of the file */ if (os_get_uname(file_info.stat.st_uid, uname, B0_UNAME_SIZE) == OK) { @@ -1630,7 +1630,7 @@ void ml_sync_all(int check_file, int check_char) * call ml_preserve() to get rid of all negative numbered blocks. */ FileInfo file_info; - if (!os_get_file_info((char *)buf->b_ffname, &file_info) + if (!os_fileinfo((char *)buf->b_ffname, &file_info) || file_info.stat.st_mtim.tv_sec != buf->b_mtime_read || os_fileinfo_size(&file_info) != buf->b_orig_size) { ml_preserve(buf, FALSE); @@ -3180,7 +3180,7 @@ attention_message ( msg_outtrans(buf->b_fname); MSG_PUTS("\"\n"); FileInfo file_info; - if (os_get_file_info((char *)buf->b_fname, &file_info)) { + if (os_fileinfo((char *)buf->b_fname, &file_info)) { MSG_PUTS(_(" dated: ")); x = file_info.stat.st_mtim.tv_sec; p = ctime(&x); // includes '\n' @@ -3294,7 +3294,7 @@ findswapname ( // Extra security check: When a swap file is a symbolic link, this // is most likely a symlink attack. FileInfo file_info; - bool file_or_link_found = os_get_file_info_link((char *)fname, &file_info); + bool file_or_link_found = os_fileinfo_link((char *)fname, &file_info); if (!file_or_link_found) { break; } @@ -3558,7 +3558,7 @@ fnamecmp_ino ( int retval_s; /* flag: buf_s valid */ FileInfo file_info; - if (os_get_file_info((char *)fname_c, &file_info)) { + if (os_fileinfo((char *)fname_c, &file_info)) { ino_c = os_file_info_get_inode(&file_info); } @@ -3567,7 +3567,7 @@ fnamecmp_ino ( * the swap file may be outdated. If that fails (e.g. this path is not * valid on this machine), use the inode from block 0. */ - if (os_get_file_info((char *)fname_s, &file_info)) { + if (os_fileinfo((char *)fname_s, &file_info)) { ino_s = os_file_info_get_inode(&file_info); } else { ino_s = (uint64_t)ino_block0; diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 71e8a55c0e..217d0a78ac 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -331,7 +331,7 @@ int os_remove(const char *path) /// @param path Path to the file. /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. -bool os_get_file_info(const char *path, FileInfo *file_info) +bool os_fileinfo(const char *path, FileInfo *file_info) { return os_stat(path, &(file_info->stat)); } @@ -341,7 +341,7 @@ bool os_get_file_info(const char *path, FileInfo *file_info) /// @param path Path to the file. /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. -bool os_get_file_info_link(const char *path, FileInfo *file_info) +bool os_fileinfo_link(const char *path, FileInfo *file_info) { uv_fs_t request; int result = uv_fs_lstat(uv_default_loop(), &request, path, NULL); @@ -355,7 +355,7 @@ bool os_get_file_info_link(const char *path, FileInfo *file_info) /// @param file_descriptor File descriptor of the file. /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. -bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info) +bool os_fileinfo_fd(int file_descriptor, FileInfo *file_info) { uv_fs_t request; int result = uv_fs_fstat(uv_default_loop(), &request, file_descriptor, NULL); diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 33b08d7df6..e6a1ecb796 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -328,7 +328,7 @@ int len /* buffer size, only used when name gets longer */ struct dirent *dp; FileInfo file_info; - if (os_get_file_info_link((char *)name, &file_info)) { + if (os_fileinfo_link((char *)name, &file_info)) { /* Open the directory where the file is located. */ slash = vim_strrchr(name, '/'); if (slash == NULL) { @@ -354,7 +354,7 @@ int len /* buffer size, only used when name gets longer */ STRLCPY(newname + (tail - name), dp->d_name, MAXPATHL - (tail - name) + 1); FileInfo file_info_new; - if (os_get_file_info_link((char *)newname, &file_info_new) + if (os_fileinfo_link((char *)newname, &file_info_new) && os_file_info_id_equal(&file_info, &file_info_new)) { STRCPY(tail, dp->d_name); break; diff --git a/src/nvim/path.c b/src/nvim/path.c index 0c18ab7bd4..8b4a63a6ae 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1304,7 +1304,7 @@ void simplify_filename(char_u *filename) saved_char = p[-1]; p[-1] = NUL; FileInfo file_info; - if (!os_get_file_info_link((char *)filename, &file_info)) { + if (!os_fileinfo_link((char *)filename, &file_info)) { do_strip = TRUE; } p[-1] = saved_char; @@ -1327,7 +1327,7 @@ void simplify_filename(char_u *filename) * components. */ saved_char = *tail; *tail = NUL; - if (os_get_file_info((char *)filename, &file_info)) { + if (os_fileinfo((char *)filename, &file_info)) { do_strip = TRUE; } else @@ -1343,11 +1343,11 @@ void simplify_filename(char_u *filename) * component's parent directory.) */ FileInfo new_file_info; if (p == start && relative) { - os_get_file_info(".", &new_file_info); + os_fileinfo(".", &new_file_info); } else { saved_char = *p; *p = NUL; - os_get_file_info((char *)filename, &new_file_info); + os_fileinfo((char *)filename, &new_file_info); *p = saved_char; } diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 2415858e0f..876d4e73d1 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2564,7 +2564,7 @@ static char_u *get_mef_name(void) STRCAT(name, p + 2); // Don't accept a symbolic link, its a security risk. FileInfo file_info; - bool file_or_link_found = os_get_file_info_link((char *)name, &file_info); + bool file_or_link_found = os_fileinfo_link((char *)name, &file_info); if (!file_or_link_found) { break; } diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 8c7b5b38e9..d7a691aa83 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1116,8 +1116,8 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash) */ FileInfo file_info_old; FileInfo file_info_new; - if (os_get_file_info((char *)buf->b_ffname, &file_info_old) - && os_get_file_info((char *)file_name, &file_info_new) + if (os_fileinfo((char *)buf->b_ffname, &file_info_old) + && os_fileinfo((char *)file_name, &file_info_new) && file_info_old.stat.st_gid != file_info_new.stat.st_gid && os_fchown(fd, -1, file_info_old.stat.st_gid) != 0) { os_setperm(file_name, (perm & 0707) | ((perm & 07) << 3)); @@ -1249,8 +1249,8 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name) * owner of the text file or equal to the current user. */ FileInfo file_info_orig; FileInfo file_info_undo; - if (os_get_file_info((char *)orig_name, &file_info_orig) - && os_get_file_info((char *)file_name, &file_info_undo) + if (os_fileinfo((char *)orig_name, &file_info_orig) + && os_fileinfo((char *)file_name, &file_info_undo) && file_info_orig.stat.st_uid != file_info_undo.stat.st_uid && file_info_undo.stat.st_uid != getuid()) { if (p_verbose > 0) { diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 696e6f15cc..f11137b1ed 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -483,63 +483,63 @@ describe('fs function', function() return file_info end - describe('os_get_file_info', function() + describe('os_fileinfo', function() it('returns false if given a non-existing file', function() local file_info = file_info_new() - assert.is_false((fs.os_get_file_info('/non-existent', file_info))) + assert.is_false((fs.os_fileinfo('/non-existent', file_info))) end) it('returns true if given an existing file and fills file_info', function() local file_info = file_info_new() local path = 'unit-test-directory/test.file' - assert.is_true((fs.os_get_file_info(path, file_info))) + assert.is_true((fs.os_fileinfo(path, file_info))) assert.is_true((is_file_info_filled(file_info))) end) it('returns the file info of the linked file, not the link', function() local file_info = file_info_new() local path = 'unit-test-directory/test_link.file' - assert.is_true((fs.os_get_file_info(path, file_info))) + assert.is_true((fs.os_fileinfo(path, file_info))) assert.is_true((is_file_info_filled(file_info))) local mode = tonumber(file_info[0].stat.st_mode) return eq(ffi.C.kS_IFREG, (bit.band(mode, ffi.C.kS_IFMT))) end) end) - describe('os_get_file_info_link', function() + describe('os_fileinfo_link', function() it('returns false if given a non-existing file', function() local file_info = file_info_new() - assert.is_false((fs.os_get_file_info_link('/non-existent', file_info))) + assert.is_false((fs.os_fileinfo_link('/non-existent', file_info))) end) it('returns true if given an existing file and fills file_info', function() local file_info = file_info_new() local path = 'unit-test-directory/test.file' - assert.is_true((fs.os_get_file_info_link(path, file_info))) + assert.is_true((fs.os_fileinfo_link(path, file_info))) assert.is_true((is_file_info_filled(file_info))) end) it('returns the file info of the link, not the linked file', function() local file_info = file_info_new() local path = 'unit-test-directory/test_link.file' - assert.is_true((fs.os_get_file_info_link(path, file_info))) + assert.is_true((fs.os_fileinfo_link(path, file_info))) assert.is_true((is_file_info_filled(file_info))) local mode = tonumber(file_info[0].stat.st_mode) eq(ffi.C.kS_IFLNK, (bit.band(mode, ffi.C.kS_IFMT))) end) end) - describe('os_get_file_info_fd', function() + describe('os_fileinfo_fd', function() it('returns false if given an invalid file descriptor', function() local file_info = file_info_new() - assert.is_false((fs.os_get_file_info_fd(-1, file_info))) + assert.is_false((fs.os_fileinfo_fd(-1, file_info))) end) it('returns true if given a file descriptor and fills file_info', function() local file_info = file_info_new() local path = 'unit-test-directory/test.file' local fd = ffi.C.open(path, 0) - assert.is_true((fs.os_get_file_info_fd(fd, file_info))) + assert.is_true((fs.os_fileinfo_fd(fd, file_info))) assert.is_true((is_file_info_filled(file_info))) ffi.C.close(fd) end) @@ -551,8 +551,8 @@ describe('fs function', function() local file_info_2 = file_info_new() local path_1 = 'unit-test-directory/test.file' local path_2 = 'unit-test-directory/test_2.file' - assert.is_true((fs.os_get_file_info(path_1, file_info_1))) - assert.is_true((fs.os_get_file_info(path_2, file_info_2))) + assert.is_true((fs.os_fileinfo(path_1, file_info_1))) + assert.is_true((fs.os_fileinfo(path_2, file_info_2))) assert.is_false((fs.os_file_info_id_equal(file_info_1, file_info_2))) end) @@ -560,8 +560,8 @@ describe('fs function', function() local file_info_1 = file_info_new() local file_info_2 = file_info_new() local path = 'unit-test-directory/test.file' - assert.is_true((fs.os_get_file_info(path, file_info_1))) - assert.is_true((fs.os_get_file_info(path, file_info_2))) + assert.is_true((fs.os_fileinfo(path, file_info_1))) + assert.is_true((fs.os_fileinfo(path, file_info_2))) assert.is_true((fs.os_file_info_id_equal(file_info_1, file_info_2))) end) @@ -570,8 +570,8 @@ describe('fs function', function() local file_info_2 = file_info_new() local path_1 = 'unit-test-directory/test.file' local path_2 = 'unit-test-directory/test_link.file' - assert.is_true((fs.os_get_file_info(path_1, file_info_1))) - assert.is_true((fs.os_get_file_info(path_2, file_info_2))) + assert.is_true((fs.os_fileinfo(path_1, file_info_1))) + assert.is_true((fs.os_fileinfo(path_2, file_info_2))) assert.is_true((fs.os_file_info_id_equal(file_info_1, file_info_2))) end) end) @@ -581,7 +581,7 @@ describe('fs function', function() local file_info = file_info_new() local file_id = file_id_new() local path = 'unit-test-directory/test.file' - assert.is_true((fs.os_get_file_info(path, file_info))) + assert.is_true((fs.os_fileinfo(path, file_info))) fs.os_file_info_get_id(file_info, file_id) eq(file_info[0].stat.st_ino, file_id[0].inode) eq(file_info[0].stat.st_dev, file_id[0].device_id) @@ -592,7 +592,7 @@ describe('fs function', function() it('returns the inode from file_info', function() local file_info = file_info_new() local path = 'unit-test-directory/test.file' - assert.is_true((fs.os_get_file_info(path, file_info))) + assert.is_true((fs.os_fileinfo(path, file_info))) local inode = fs.os_file_info_get_inode(file_info) eq(file_info[0].stat.st_ino, inode) end) @@ -607,7 +607,7 @@ describe('fs function', function() file:close() local size = lfs.attributes(path, 'size') local file_info = file_info_new() - assert.is_true(fs.os_get_file_info(path, file_info)) + assert.is_true(fs.os_fileinfo(path, file_info)) eq(size, fs.os_fileinfo_size(file_info)) end) end) @@ -617,10 +617,10 @@ describe('fs function', function() local path = 'unit-test-directory/test.file' local path_link = 'unit-test-directory/test_hlink.file' local file_info = file_info_new() - assert.is_true(fs.os_get_file_info(path, file_info)) + assert.is_true(fs.os_fileinfo(path, file_info)) eq(1, fs.os_fileinfo_hardlinks(file_info)) lfs.link(path, path_link) - assert.is_true(fs.os_get_file_info(path, file_info)) + assert.is_true(fs.os_fileinfo(path, file_info)) eq(2, fs.os_fileinfo_hardlinks(file_info)) end) end) @@ -634,7 +634,7 @@ describe('fs function', function() -- using this workaround for now: local blksize = lfs.attributes(path).blksize local file_info = file_info_new() - assert.is_true(fs.os_get_file_info(path, file_info)) + assert.is_true(fs.os_fileinfo(path, file_info)) if blksize then eq(blksize, fs.os_fileinfo_blocksize(file_info)) else @@ -686,7 +686,7 @@ describe('fs function', function() local file_info = file_info_new() local path = 'unit-test-directory/test.file' assert.is_true((fs.os_get_file_id(path, file_id))) - assert.is_true((fs.os_get_file_info(path, file_info))) + assert.is_true((fs.os_fileinfo(path, file_info))) assert.is_true((fs.os_file_id_equal_file_info(file_id, file_info))) end) @@ -696,7 +696,7 @@ describe('fs function', function() local path_1 = 'unit-test-directory/test.file' local path_2 = 'unit-test-directory/test_2.file' assert.is_true((fs.os_get_file_id(path_1, file_id))) - assert.is_true((fs.os_get_file_info(path_2, file_info))) + assert.is_true((fs.os_fileinfo(path_2, file_info))) assert.is_false((fs.os_file_id_equal_file_info(file_id, file_info))) end) end) |