2 Copyright © 2005-2009, The AROS Development Team. All rights reserved.
6 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <proto/dos.h>
11 #include <proto/muimaster.h>
20 STRPTR
GetENV(CONST_STRPTR name
)
25 /* Check that the variable exists, and get the length */
26 if (GetVar(name
, &dummy
, 1, GVF_GLOBAL_ONLY
) != -1)
28 ULONG length
= IoErr() + 1;
30 if ((value
= AllocVec(length
, MEMF_ANY
)) != NULL
)
32 if (GetVar(name
, value
, length
, GVF_GLOBAL_ONLY
) == -1)
43 BOOL
SetENV(CONST_STRPTR name
, CONST_STRPTR value
)
45 return SetVar(name
, value
, -1, GVF_GLOBAL_ONLY
);
48 VOID
ShowError(Object
*application
, Object
*window
, CONST_STRPTR message
, BOOL useIOError
)
51 STRPTR newline
= "\n",
55 /* Never use IO error if it is 0 */
56 if (IoErr() == 0) useIOError
= FALSE
;
60 Fault(IoErr(), NULL
, buffer
, sizeof(buffer
));
61 buffer
[0] = toupper(buffer
[0]);
72 application
, window
, 0, _(MSG_TITLE
), _(MSG_ERROR_OK
),
73 "%s:\n%s%s%s%s", _(MSG_ERROR_HEADER
), message
, newline
, extra
, period
77 ULONG
FormatSize(STRPTR buffer
, ULONG blocks
, ULONG totalblocks
, ULONG bytesperblock
, BOOL showPercentage
)
79 static STRPTR suffixes
[] = {" bytes", "K", "M", "G", "T", "P"};
80 DOUBLE internalsize
= (DOUBLE
)((UQUAD
)blocks
* bytesperblock
);
85 percentage
= 100 * blocks
/ totalblocks
;
89 while (internalsize
> 1024)
96 sprintf(buffer
, "%.1f%s (%d %s)", internalsize
, suffixes
[divcount
], (int)blocks
, _(MSG_BLOCKS
) );
98 sprintf(buffer
, "%.1f%s (%d %s, %d%%)", internalsize
, suffixes
[divcount
], (int)blocks
, _(MSG_BLOCKS
), (int)percentage
);