+ SILC_LOG_DEBUG(("Creating new fd stream for reading `%s' and writing `%s'",
+ read_file ? read_file : "(none)",
+ write_file ? write_file : "(none)"));
+
+ if (write_file) {
+ fd2 = silc_file_open(write_file, O_CREAT | O_WRONLY);
+ if (fd2 < 0) {
+ silc_file_close(fd1);
+ return NULL;
+ }
+ }
+
+ if (read_file) {
+ fd1 = silc_file_open(read_file, O_RDONLY);
+ if (fd1 < 0)
+ return NULL;
+ }
+
+ stream = silc_fd_stream_create2(fd1, fd2, stack);
+ if (!stream) {
+ silc_file_close(fd1);
+ silc_file_close(fd2);
+ }