diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-06-21 13:24:41 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-06-21 13:25:38 +0200 |
commit | f91865c8cf85c4c4309c64ded42c847a64872b1e (patch) | |
tree | febe04eedc1310ff4d5018b59d48bbad196cc832 | |
parent | 16d38498846b8e1ec87c9261caa7b90c6a8c32bd (diff) | |
download | cygnal-f91865c8cf85c4c4309c64ded42c847a64872b1e.tar.gz cygnal-f91865c8cf85c4c4309c64ded42c847a64872b1e.tar.bz2 cygnal-f91865c8cf85c4c4309c64ded42c847a64872b1e.zip |
Improve encapsulation of FS type behind path_conv cover
Rather than having to check for the FS type in the caller and having
to call different functions whether FS is NFS or not, encapsulate the
info in path_conv_handle/path_conv methods to allow FS type agnostic
calling from upper level functions.
This patch only implements the methods.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/path.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 23139a643..ad29590a9 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -90,6 +90,8 @@ enum path_types PATH_SOCKET = 0x40000000 }; +NTSTATUS file_get_fai (HANDLE, PFILE_ALL_INFORMATION); + class symlink_info; class path_conv_handle @@ -117,10 +119,25 @@ public: hdl = NULL; } inline HANDLE handle () const { return hdl; } - inline PFILE_ALL_INFORMATION fai () + inline PFILE_ALL_INFORMATION fai () const { return (PFILE_ALL_INFORMATION) &attribs._fai; } - inline struct fattr3 *nfsattr () + inline struct fattr3 *nfsattr () const { return (struct fattr3 *) &attribs._fattr3; } + inline NTSTATUS get_finfo (HANDLE h, bool nfs) + { + return nfs ? nfs_fetch_fattr3 (h, nfsattr ()) : file_get_fai (h, fai ()); + } + inline ino_t get_ino (bool nfs) const + { + return nfs ? nfsattr ()->fileid + : fai ()->InternalInformation.IndexNumber.QuadPart; + } + inline DWORD get_dosattr (bool nfs) const + { + if (nfs) + return (nfsattr ()->type & 7) == NF3DIR ? FILE_ATTRIBUTE_DIRECTORY : 0; + return fai ()->BasicInformation.FileAttributes; + } }; class path_conv @@ -380,6 +397,11 @@ class path_conv HANDLE handle () const { return conv_handle.handle (); } PFILE_ALL_INFORMATION fai () { return conv_handle.fai (); } struct fattr3 *nfsattr () { return conv_handle.nfsattr (); } + inline NTSTATUS get_finfo (HANDLE h) + { + return conv_handle.get_finfo (h, fs.is_nfs ()); + } + inline ino_t get_ino () const { return conv_handle.get_ino (fs.is_nfs ()); } void reset_conv_handle () { conv_handle.set (NULL); } void close_conv_handle () { conv_handle.close (); } @@ -432,7 +454,6 @@ bool __reg2 has_dot_last_component (const char *dir, bool test_dot_dot); int __reg3 path_prefix_p (const char *path1, const char *path2, int len1, bool caseinsensitive); -NTSTATUS file_get_fai (HANDLE, PFILE_ALL_INFORMATION); int normalize_win32_path (const char *, char *, char *&); int normalize_posix_path (const char *, char *, char *&); PUNICODE_STRING __reg3 get_nt_native_path (const char *, UNICODE_STRING&, bool); |