Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
IO/FileSystem/Exception.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ***************************** FileSystem::Exception ****************************
10 ********************************************************************************
11 */
12 inline Exception::Exception (error_code errCode, const path& p1, const path& p2)
13 : inherited{mkMsg_ (errCode, p1, p2), mkMsg_ (errCode, p1, p2).AsNarrowSDKString (Characters::eIgnoreErrors), p1, p2, errCode}
14 {
15 Require (not p1.empty () or p2.empty ()); // if only one path provided, provide it first
16 }
17 inline Exception::Exception (error_code errCode, const Characters::String& message, const path& p1, const path& p2)
18 : inherited{mkMsg_ (errCode, message, p1, p2), mkMsg_ (errCode, message, p1, p2).AsNarrowSDKString (Characters::eIgnoreErrors), p1, p2, errCode}
19 {
20 Require (not p1.empty () or p2.empty ()); // if only one path provided, provide it first
21 }
22#if qStroika_Foundation_Common_Platform_Windows
23 template <typename WINDOWS_API_RESULT>
24 inline static void Exception::ThrowIfZeroGetLastError (WINDOWS_API_RESULT test, const path& p1, const path& p2)
25 {
26 if (test == 0) {
27 ThrowSystemErrNo (::GetLastError (), p1, p2);
28 }
29 }
30#endif
31 template <typename INT_TYPE>
32 inline INT_TYPE Exception::ThrowPOSIXErrNoIfNegative (INT_TYPE returnCode, const path& p1, const path& p2)
33 {
34 if (returnCode < 0) [[unlikely]] {
35 ThrowPOSIXErrNo (errno, p1, p2);
36 }
37 return returnCode;
38 }
39
40}