add error checking

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11482 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2009-01-24 18:11:42 +00:00
1 parent f956cff861
commit 6984e63340
2 files changed
+26

No files matched your search

+13
View File
@@ -45,6 +45,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
char stream_name[128] = "";
char *rhs = NULL;
if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open\n");
return SWITCH_STATUS_FALSE;
}
if (switch_strlen_zero(file_path)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename\n");
return SWITCH_STATUS_FALSE;
@@ -140,6 +145,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
if (!switch_test_flag(fh, SWITCH_FILE_OPEN)) {
return SWITCH_STATUS_FALSE;
}
top:
if (fh->buffer && switch_buffer_inuse(fh->buffer) >= *len * 2) {
@@ -253,6 +262,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
if (!switch_test_flag(fh, SWITCH_FILE_OPEN)) {
return SWITCH_STATUS_FALSE;
}
if (!fh->file_interface->file_write) {
return SWITCH_STATUS_FALSE;
}