1 | /* $Id: vfsmsg.cpp 76452 2018-12-25 01:41:25Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Virtual File System, Error Messaging for Chains.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include <iprt/vfs.h>
|
---|
32 |
|
---|
33 | #include <iprt/errcore.h>
|
---|
34 | #include <iprt/message.h>
|
---|
35 |
|
---|
36 |
|
---|
37 | RTDECL(void) RTVfsChainMsgError(const char *pszFunction, const char *pszSpec, int rc, uint32_t offError, PRTERRINFO pErrInfo)
|
---|
38 | {
|
---|
39 | if (RTErrInfoIsSet(pErrInfo))
|
---|
40 | {
|
---|
41 | if (offError > 0)
|
---|
42 | RTMsgError("%s failed with rc=%Rrc: %s\n"
|
---|
43 | " '%s'\n"
|
---|
44 | " %*s^\n",
|
---|
45 | pszFunction, rc, pErrInfo->pszMsg, pszSpec, offError, "");
|
---|
46 | else
|
---|
47 | RTMsgError("%s failed to open '%s': %Rrc: %s\n", pszFunction, pszSpec, rc, pErrInfo->pszMsg);
|
---|
48 | }
|
---|
49 | else
|
---|
50 | {
|
---|
51 | if (offError > 0)
|
---|
52 | RTMsgError("%s failed with rc=%Rrc:\n"
|
---|
53 | " '%s'\n"
|
---|
54 | " %*s^\n",
|
---|
55 | pszFunction, rc, pszSpec, offError, "");
|
---|
56 | else
|
---|
57 | RTMsgError("%s failed to open '%s': %Rrc\n", pszFunction, pszSpec, rc);
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | RTDECL(RTEXITCODE) RTVfsChainMsgErrorExitFailure(const char *pszFunction, const char *pszSpec,
|
---|
63 | int rc, uint32_t offError, PRTERRINFO pErrInfo)
|
---|
64 | {
|
---|
65 | RTVfsChainMsgError(pszFunction, pszSpec, rc, offError, pErrInfo);
|
---|
66 | return RTEXITCODE_FAILURE;
|
---|
67 | }
|
---|
68 |
|
---|