<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 25, 2016, at 7:51 PM, Rafael EspĂndola <<a href="mailto:rafael.espindola@gmail.com" class="">rafael.espindola@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><p dir="ltr" class=""><br class="">
On Mar 25, 2016 12:42 PM, "Mehdi Amini" <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>> wrote:<br class="">
><br class="">
> I thought about it but the rest of the file is using std::error_code as a return. Do we want to introduce a discrepancy here?<br class="">
></p><p dir="ltr" class="">I would prefer it, yes. Otherwise it is hard to migrate to newer APIs.</p></div></blockquote><div><br class=""></div><div>I'd convert the whole file in one single commit. But I see the point about not adding more interface to convert later. Will update.</div><div><br class=""></div><div>-- </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><p dir="ltr" class="">Cheers,<br class="">
Rafael<br class=""><br class=""></p><p dir="ltr" class="">>> On Mar 25, 2016, at 9:41 AM, Rafael EspĂndola <<a href="mailto:rafael.espindola@gmail.com" class="">rafael.espindola@gmail.com</a>> wrote:<br class="">
>><br class="">
>> Can you return an ErrorOr or Expected?<br class="">
>><br class="">
>> On Mar 24, 2016 8:17 PM, "Mehdi AMINI via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class="">
>>><br class="">
>>> joker.eph created this revision.<br class="">
>>> joker.eph added reviewers: bruno, silvas.<br class="">
>>> joker.eph added a subscriber: llvm-commits.<br class="">
>>> Herald added subscribers: srhines, danalbert, tberghammer.<br class="">
>>><br class="">
>>> Adapted from Boost::filesystem.<br class="">
>>><br class="">
>>> <a href="http://reviews.llvm.org/D18467" class="">http://reviews.llvm.org/D18467</a><br class="">
>>><br class="">
>>> Files:<br class="">
>>> include/llvm/Support/FileSystem.h<br class="">
>>> lib/Support/Unix/Path.inc<br class="">
>>> lib/Support/Windows/Path.inc<br class="">
>>><br class="">
>>> Index: lib/Support/Windows/Path.inc<br class="">
>>> ===================================================================<br class="">
>>> --- lib/Support/Windows/Path.inc<br class="">
>>> +++ lib/Support/Windows/Path.inc<br class="">
>>> @@ -151,6 +151,19 @@<br class="">
>>> return UniqueID(VolumeSerialNumber, FileID);<br class="">
>>> }<br class="">
>>><br class="">
>>> +std::error_code disk_space(const Twine Path, space_info &SpaceInfo) {<br class="">
>>> + PULARGE_INTEGER avail, total, free;<br class="">
>>> + if (!::GetDiskFreeSpaceExW(Path.str().c_str(), &avail, &total, &free))<br class="">
>>> + return mapWindowsError(::GetLastError());<br class="">
>>> + SpaceInfo.capacity = (static_cast<uint64_t>(total.HighPart) << 32)<br class="">
>>> + + total.LowPart;<br class="">
>>> + SpaceInfo.free = (static_cast<uint64_t>(free.HighPart) << 32)<br class="">
>>> + + free.LowPart;<br class="">
>>> + SpaceInfo.available = (static_cast<uint64_t>(avail.HighPart) << 32)<br class="">
>>> + + avail.LowPart;<br class="">
>>> + return std::error_code();<br class="">
>>> +}<br class="">
>>> +<br class="">
>>> TimeValue file_status::getLastAccessedTime() const {<br class="">
>>> ULARGE_INTEGER UI;<br class="">
>>> UI.LowPart = LastAccessedTimeLow;<br class="">
>>> Index: lib/Support/Unix/Path.inc<br class="">
>>> ===================================================================<br class="">
>>> --- lib/Support/Unix/Path.inc<br class="">
>>> +++ lib/Support/Unix/Path.inc<br class="">
>>> @@ -60,6 +60,24 @@<br class="">
>>> # define PATH_MAX 4096<br class="">
>>> #endif<br class="">
>>><br class="">
>>> +#include <sys/types.h><br class="">
>>> +#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__ANDROID__)<br class="">
>>> +# include <sys/statvfs.h><br class="">
>>> +# define STATVFS statvfs<br class="">
>>> +# define STATVFS_F_FRSIZE(vfs) vfs.f_frsize<br class="">
>>> +#else<br class="">
>>> +# ifdef __OpenBSD__<br class="">
>>> +# include <sys/param.h><br class="">
>>> +# elif defined(__ANDROID__)<br class="">
>>> +# include <sys/vfs.h><br class="">
>>> +# else<br class="">
>>> +# include <sys/mount.h><br class="">
>>> +# endif<br class="">
>>> +# define STATVFS statfs<br class="">
>>> +# define STATVFS_F_FRSIZE(vfs) static_cast<uint64_t>(vfs.f_bsize)<br class="">
>>> +#endif<br class="">
>>> +<br class="">
>>> +<br class="">
>>> using namespace llvm;<br class="">
>>><br class="">
>>> namespace llvm {<br class="">
>>> @@ -190,6 +208,18 @@<br class="">
>>> return UniqueID(fs_st_dev, fs_st_ino);<br class="">
>>> }<br class="">
>>><br class="">
>>> +std::error_code disk_space(const Twine Path, space_info &SpaceInfo) {<br class="">
>>> + struct STATVFS Vfs;<br class="">
>>> + if(::STATVFS(Path.str().c_str(), &Vfs))<br class="">
>>> + return std::error_code(errno, std::generic_category());<br class="">
>>> + SpaceInfo.capacity =<br class="">
>>> + static_cast<uint64_t>(Vfs.f_blocks)* STATVFS_F_FRSIZE(Vfs);<br class="">
>>> + SpaceInfo.free = static_cast<uint64_t>(Vfs.f_bfree)* STATVFS_F_FRSIZE(Vfs);<br class="">
>>> + SpaceInfo.available =<br class="">
>>> + static_cast<uint64_t>(Vfs.f_bavail)* STATVFS_F_FRSIZE(Vfs);<br class="">
>>> + return std::error_code();<br class="">
>>> +}<br class="">
>>> +<br class="">
>>> std::error_code current_path(SmallVectorImpl<char> &result) {<br class="">
>>> result.clear();<br class="">
>>><br class="">
>>> Index: include/llvm/Support/FileSystem.h<br class="">
>>> ===================================================================<br class="">
>>> --- include/llvm/Support/FileSystem.h<br class="">
>>> +++ include/llvm/Support/FileSystem.h<br class="">
>>> @@ -647,6 +647,15 @@<br class="">
>>><br class="">
>>> std::error_code getUniqueID(const Twine Path, UniqueID &Result);<br class="">
>>><br class="">
>>> +/// @brief Get disk space usage information.<br class="">
>>> +///<br class="">
>>> +/// @param Path Input path.<br class="">
>>> +/// @param SpaceInfo Set to the capacity, free, and available space on the<br class="">
>>> +/// device \a Path is on.<br class="">
>>> +/// @results errc::success if result has been successfully set, otherwise a<br class="">
>>> +/// platform specific error_code.<br class="">
>>> +std::error_code disk_space(const Twine Path, space_info &SpaceInfo);<br class="">
>>> +<br class="">
>>> /// This class represents a memory mapped file. It is based on<br class="">
>>> /// boost::iostreams::mapped_file.<br class="">
>>> class mapped_file_region {<br class="">
>>><br class="">
>>><br class="">
>>><br class="">
>>> _______________________________________________<br class="">
>>> llvm-commits mailing list<br class="">
>>> <a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
>>><br class="">
><br class="">
</p>
</div></blockquote></div><br class=""></body></html>