summaryrefslogblamecommitdiffstats
path: root/cpukit/libmisc/shell/write_file.c
blob: 1cceb0c6ea59580e3f0de59abe7e0d0c0c5d894f (plain) (tree)
1
2
3
4
5
6
7
8





                                
  
                                                                


                                                           
                                         









                    

                        
                            

                     




                       



                                                    






                                         
/**
 * @file
 * 
 * @brief Write buffer to a file
 */

/*
 * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com>
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h>
#include <unistd.h>
#include <string.h>

#include <rtems/shell.h>

void rtems_shell_write_file(
  const char *name,
  const char *content
)
{
  FILE * fd;

  fd = fopen(name,"w");
  if ( !fd ) {
    fprintf( stderr, "Unable to write %s\n", name );
  }

  if (fd) {
    fwrite(content,1,strlen(content),fd);
    fclose(fd);
  }
}