1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * @brief Declaration file for file routines
10 * @brief File-operation return-statuses
11 * Note that FileLoadResult class has no instance data or methods.
12 * It is only a namespace for static methods & constants.
13 * Everything is public.
21 * @param [in] flr Return value to test.
22 * @return true if return value is an error value.
24 static bool IsError(DWORD flr) { return Main(flr) == FRESULT_ERROR; }
26 * Is result a success?
27 * @param [in] flr Return value to test.
28 * @return true if return value is an success value.
30 static bool IsOk(DWORD flr) { return Main(flr) == FRESULT_OK; }
32 * Is result OK but file is impure?
33 * @param [in] flr Return value to test.
34 * @return true if return value is success and file is impure.
36 static bool IsOkImpure(DWORD flr) { return Main(flr) == FRESULT_OK_IMPURE; }
38 * Is result binary file?
39 * @param [in] flr Return value to test.
40 * @return true if return value determines binary file.
42 static bool IsBinary(DWORD flr) { return Main(flr) == FRESULT_BINARY; }
44 * Is result unpack error?
45 * @param [in] flr Return value to test.
46 * @return true if return value determines unpacking error.
48 static bool IsErrorUnpack(DWORD flr) { return Main(flr) == FRESULT_ERROR_UNPACK; }
50 * Was there lossy conversion involved?
51 * @param [in] flr Return value to test.
52 * @return true if return value determines lossy conversion(s) were done.
54 static bool IsLossy(DWORD flr) { return IsModifier(flr, FRESULT_LOSSY); }
58 static void SetMainOk(DWORD & flr) { SetMain(flr, FRESULT_OK); }
60 static void AddModifier(DWORD & flr, DWORD modifier) { flr = (flr | modifier); }
63 static void SetMain(DWORD & flr, DWORD newmain) { flr = flr & ~FRESULT_MAIN_MASK; flr = flr | newmain; }
64 static DWORD Main(DWORD flr) { return flr & FRESULT_MAIN_MASK; }
65 static bool IsModifier(DWORD flr, DWORD modifier) { return (flr & modifier) != 0; }
67 /** @brief Return values for functions. */
71 * Mask for the main return values.
72 * This mask defines bits used for main return values, separated from
75 FRESULT_MAIN_MASK = 0xF,
79 * This defines general error return value.
84 * This defines general success return value.
88 * Success, but impure file.
89 * The file operation was successful. But the files was detected
90 * to be impure file. Impure file is a file with two or three
91 * different EOL styles.
93 FRESULT_OK_IMPURE = 0x2,
96 * The file was loaded OK, and was detected to be a binary file.
100 * Unpacking plugin failed.
101 * The file was loaded OK, but the unpacking plugin failed.
103 FRESULT_ERROR_UNPACK = 0x4,
106 * Lossy conversions done.
107 * Unicode / codepage conversions caused lossy conversions.
109 FRESULT_LOSSY = 0x10000,