File: fluid_file.cpp

package info (click to toggle)
fluidsynth 2.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,636 kB
  • sloc: ansic: 45,266; cpp: 4,718; xml: 853; sh: 205; makefile: 74
file content (51 lines) | stat: -rw-r--r-- 1,514 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* FluidSynth - A Software Synthesizer
 *
 * Copyright (C) 2003  Peter Hanappe and others.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "fluid_file.h"

#if HAVE_CXX_FILESYSTEM
#include <filesystem>
#endif

#if OSAL_glib || OSAL_cpp11
bool fluid_file_test(const char *path, int flags)
{
#if OSAL_glib
    return g_file_test(path, static_cast<GFileTest>(flags));
#elif OSAL_cpp11 && HAVE_CXX_FILESYSTEM
    try
    {
        std::filesystem::path _path = std::filesystem::u8path(path);
        if ((flags & FLUID_FILE_TEST_EXISTS) != 0)
            return std::filesystem::exists(_path);
        if ((flags & FLUID_FILE_TEST_IS_REGULAR) != 0)
            return std::filesystem::is_regular_file(_path);
    }
    catch (...)
    {
    }

    return false;
#else
    FLUID_LOG(FLUID_ERR, "fluid_file_test is unavailable, returning true");
    return true;
#endif
}
#endif