diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-16 02:55:33 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-16 02:55:33 +0000 |
commit | 77e31bca0321c6b470a844e3d5468fd998eef44e (patch) | |
tree | b404ccbdb6602651bea6c624b4eebf57b562b273 /lib/Support | |
parent | 334f8b9b37aef9e650af2007f9f3f7169f284425 (diff) | |
download | external_llvm-77e31bca0321c6b470a844e3d5468fd998eef44e.zip external_llvm-77e31bca0321c6b470a844e3d5468fd998eef44e.tar.gz external_llvm-77e31bca0321c6b470a844e3d5468fd998eef44e.tar.bz2 |
Instead friending status, provide windows and posix constructors to file_status.
This opens the way of having static helpers in the .inc files that can
construct a file_status.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Unix/Path.inc | 28 | ||||
-rw-r--r-- | lib/Support/Windows/Path.inc | 15 |
2 files changed, 18 insertions, 25 deletions
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc index 83879ff..484296c 100644 --- a/lib/Support/Unix/Path.inc +++ b/lib/Support/Unix/Path.inc @@ -556,28 +556,24 @@ error_code status(const Twine &path, file_status &result) { } perms prms = static_cast<perms>(status.st_mode); - + file_type Type = file_type::type_unknown; + if (S_ISDIR(status.st_mode)) - result = file_status(file_type::directory_file, prms); + Type = file_type::directory_file; else if (S_ISREG(status.st_mode)) - result = file_status(file_type::regular_file, prms); + Type = file_type::regular_file; else if (S_ISBLK(status.st_mode)) - result = file_status(file_type::block_file, prms); + Type = file_type::block_file; else if (S_ISCHR(status.st_mode)) - result = file_status(file_type::character_file, prms); + Type = file_type::character_file; else if (S_ISFIFO(status.st_mode)) - result = file_status(file_type::fifo_file, prms); + Type = file_type::fifo_file; else if (S_ISSOCK(status.st_mode)) - result = file_status(file_type::socket_file, prms); - else - result = file_status(file_type::type_unknown, prms); - - result.fs_st_dev = status.st_dev; - result.fs_st_ino = status.st_ino; - result.fs_st_mtime = status.st_mtime; - result.fs_st_uid = status.st_uid; - result.fs_st_gid = status.st_gid; - result.fs_st_size = status.st_size; + Type = file_type::socket_file; + + result = + file_status(Type, prms, status.st_dev, status.st_ino, status.st_mtime, + status.st_uid, status.st_gid, status.st_size); return error_code::success(); } diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index b023593..1ecd803 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -632,7 +632,6 @@ error_code status(const Twine &path, file_status &result) { if (attr & FILE_ATTRIBUTE_DIRECTORY) result = file_status(file_type::directory_file); else { - result = file_status(file_type::regular_file); ScopedFileHandle h( ::CreateFileW(path_utf16.begin(), 0, // Attributes only. @@ -646,15 +645,13 @@ error_code status(const Twine &path, file_status &result) { BY_HANDLE_FILE_INFORMATION Info; if (!::GetFileInformationByHandle(h, &Info)) goto handle_status_error; - result.FileIndexHigh = Info.nFileIndexHigh; - result.FileIndexLow = Info.nFileIndexLow; - result.FileSizeHigh = Info.nFileSizeHigh; - result.FileSizeLow = Info.nFileSizeLow; - result.LastWriteTimeHigh = Info.ftLastWriteTime.dwHighDateTime; - result.LastWriteTimeLow = Info.ftLastWriteTime.dwLowDateTime; - result.VolumeSerialNumber = Info.dwVolumeSerialNumber; - } + result = file_status( + file_type::regular_file, Info.ftLastWriteTime.dwHighDateTime, + Info.ftLastWriteTime.dwLowDateTime, Info.dwVolumeSerialNumber, + Info.nFileSizeHigh, Info.nFileSizeLow, Info.nFileIndexHigh, + Info.nFileIndexLow); + } return error_code::success(); handle_status_error: |