view src/testdir/test_file_perm.vim @ 18014:82543df649ba v8.1.2003

patch 8.1.2003: MS-Windows: code page 65001 is not recognized Commit: https://github.com/vim/vim/commit/fa90d70884ee208966b84052080a7d5eeb8ac2d5 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 7 16:07:47 2019 +0200 patch 8.1.2003: MS-Windows: code page 65001 is not recognized Problem: MS-Windows: code page 65001 is not recognized. Solution: Use utf-8 for code page 65001. (Dan Thompson, closes https://github.com/vim/vim/issues/4902)
author Bram Moolenaar <Bram@vim.org>
date Sat, 07 Sep 2019 16:15:03 +0200
parents 4935244c1128
children 546bdeef35f1
line wrap: on
line source

" Test getting and setting file permissions.

func Test_file_perm()
  call assert_equal('', getfperm('Xtest'))
  call assert_equal(0, 'Xtest'->setfperm('r--------'))

  call writefile(['one'], 'Xtest')
  call assert_true(len('Xtest'->getfperm()) == 9)

  call assert_equal(1, setfperm('Xtest', 'rwx------'))
  if has('win32')
    call assert_equal('rw-rw-rw-', getfperm('Xtest'))
  else
    call assert_equal('rwx------', getfperm('Xtest'))
  endif

  call assert_equal(1, setfperm('Xtest', 'r--r--r--'))
  call assert_equal('r--r--r--', getfperm('Xtest'))

  call assert_fails("setfperm('Xtest', '---')")

  call assert_equal(1, setfperm('Xtest', 'rwx------'))
  call delete('Xtest')
endfunc