mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
parent
b817232f16
commit
7f11a9bf5c
6 changed files with 42 additions and 33 deletions
|
@ -99,13 +99,7 @@ int fluid_is_midifile(const char *filename)
|
|||
|
||||
do
|
||||
{
|
||||
if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
return retcode;
|
||||
}
|
||||
|
||||
// file seems to exist and is a regular file or a symlink to such
|
||||
if((fp = FLUID_FOPEN(filename, "rb")) == NULL)
|
||||
if((fp = fluid_file_open(filename, NULL)) == NULL)
|
||||
{
|
||||
return retcode;
|
||||
}
|
||||
|
|
|
@ -436,7 +436,7 @@ int fluid_defsfont_load(fluid_defsfont_t *defsfont, const fluid_file_callbacks_t
|
|||
|
||||
if(sfdata == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Couldn't load soundfont file");
|
||||
/* error message already printed */
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -340,13 +340,7 @@ int fluid_is_soundfont(const char *filename)
|
|||
|
||||
do
|
||||
{
|
||||
if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
return retcode;
|
||||
}
|
||||
|
||||
// file seems to exist and is a regular file or a symlink to such
|
||||
if((fp = FLUID_FOPEN(filename, "rb")) == NULL)
|
||||
if((fp = fluid_file_open(filename, NULL)) == NULL)
|
||||
{
|
||||
return retcode;
|
||||
}
|
||||
|
|
|
@ -24,26 +24,14 @@
|
|||
|
||||
void *default_fopen(const char *path)
|
||||
{
|
||||
FILE* handle;
|
||||
const char* msg;
|
||||
FILE* handle = fluid_file_open(path, &msg);
|
||||
|
||||
if(!fluid_file_test(path, G_FILE_TEST_EXISTS))
|
||||
if(handle == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Unable to load non-existent file. ('%s')", path);
|
||||
return NULL;
|
||||
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Failed to open '%s': %s", path, msg);
|
||||
}
|
||||
|
||||
if(!fluid_file_test(path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Refusing to load non-regular file! ('%s')", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((handle = FLUID_FOPEN(path, "rb")) == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Specified file does not exists or insufficient permissions to open it! ('%s')", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
|
|
@ -1610,3 +1610,36 @@ void delete_fluid_server_socket(fluid_server_socket_t *server_socket)
|
|||
}
|
||||
|
||||
#endif // NETWORK_SUPPORT
|
||||
|
||||
FILE* fluid_file_open(const char* path, const char** errMsg)
|
||||
{
|
||||
static const char ErrExist[] = "File does not exist.";
|
||||
static const char ErrRegular[] = "File is not regular, refusing to open it.";
|
||||
static const char ErrNull[] = "File does not exists or insufficient permissions to open it.";
|
||||
|
||||
FILE* handle = NULL;
|
||||
|
||||
if(!g_file_test(path, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
if(errMsg != NULL)
|
||||
{
|
||||
*errMsg = ErrExist;
|
||||
}
|
||||
}
|
||||
else if(!g_file_test(path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
if(errMsg != NULL)
|
||||
{
|
||||
*errMsg = ErrRegular;
|
||||
}
|
||||
}
|
||||
else if((handle = FLUID_FOPEN(path, "rb")) == NULL)
|
||||
{
|
||||
if(errMsg != NULL)
|
||||
{
|
||||
*errMsg = ErrNull;
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
|
|
@ -485,7 +485,7 @@ fluid_ostream_t fluid_socket_get_ostream(fluid_socket_t sock);
|
|||
typedef GStatBuf fluid_stat_buf_t;
|
||||
#endif
|
||||
|
||||
#define fluid_file_test g_file_test
|
||||
FILE* fluid_file_open(const char* filename, const char** errMsg);
|
||||
|
||||
/* Profiling */
|
||||
#if WITH_PROFILING
|
||||
|
|
Loading…
Reference in a new issue