diff options
| author | Stefan Hoffmann <stefan991@gmail.com> | 2014-03-16 16:06:55 +0100 |
|---|---|---|
| committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-03 10:30:03 -0300 |
| commit | f762a9e195cdd1db3d57561a5e82a1ea6799d8ba (patch) | |
| tree | f34516c296e1aadb06e7fcda3096f107dc1df45a /src/os | |
| parent | 071d28076f4ee057764359999cf2fabc75e99314 (diff) | |
| download | rneovim-f762a9e195cdd1db3d57561a5e82a1ea6799d8ba.tar.gz rneovim-f762a9e195cdd1db3d57561a5e82a1ea6799d8ba.tar.bz2 rneovim-f762a9e195cdd1db3d57561a5e82a1ea6799d8ba.zip | |
move filewritable() into /src/os/fs.c and rename it
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/fs.c | 13 | ||||
| -rw-r--r-- | src/os/os.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/os/fs.c b/src/os/fs.c index 71dee4dd3d..db366769b2 100644 --- a/src/os/fs.c +++ b/src/os/fs.c @@ -288,3 +288,16 @@ int os_file_is_readonly(const char *name) } } +// return 0 for not writable, 1 for writable file, 2 for a dir which we have +// rights to write into. +int os_file_is_writable(const char *name) +{ + if (mch_access(name, W_OK) == 0) { + if (os_isdir((char_u *)name)) { + return 2; + } + return 1; + } + return 0; +} + diff --git a/src/os/os.h b/src/os/os.h index e4f5af5057..8999d1480b 100644 --- a/src/os/os.h +++ b/src/os/os.h @@ -69,5 +69,6 @@ int os_get_user_name(char *s, size_t len); int os_get_uname(uid_t uid, char *s, size_t len); char *os_get_user_directory(const char *name); int os_file_is_readonly(const char *name); +int os_file_is_writable(const char *name); #endif // NEOVIM_OS_OS_H |