Edinburgh Speech Tools  2.1-release
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bcat_main.cc
1  /************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1996,1997 */
6  /* All Rights Reserved. */
7  /* */
8  /* Permission is hereby granted, free of charge, to use and distribute */
9  /* this software and its documentation without restriction, including */
10  /* without limitation the rights to use, copy, modify, merge, publish, */
11  /* distribute, sublicense, and/or sell copies of this work, and to */
12  /* permit persons to whom this work is furnished to do so, subject to */
13  /* the following conditions: */
14  /* 1. The code must retain the above copyright notice, this list of */
15  /* conditions and the following disclaimer. */
16  /* 2. Any modifications must be clearly marked as such. */
17  /* 3. Original authors' names are not deleted. */
18  /* 4. The authors' names are not used to endorse or promote products */
19  /* derived from this software without specific prior written */
20  /* permission. */
21  /* */
22  /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23  /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24  /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25  /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26  /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27  /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28  /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29  /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30  /* THIS SOFTWARE. */
31  /* */
32  /*************************************************************************/
33  /* */
34  /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
35  /* Date: Thu Aug 14 1997 */
36  /* -------------------------------------------------------------------- */
37  /* A simple file concatenator which does everything in binary */
38  /* mode. For use in the tests on Windows etc. */
39  /* */
40  /*************************************************************************/
41 
42 
43 #include <cstdio>
44 #include "EST.h"
45 #include "EST_String.h"
46 #include "EST_error.h"
47 
48 #define BUFFER_SIZE (1024)
49 
50 int main(int argc, char *argv[])
51 {
52  EST_StrList files;
53  EST_Option settings, cmd_line;
54 
55  parse_command_line
56  (argc, argv,
57  EST_String("-o [ofile] [files...]\n")+
58  "Summary; concatenate files in binary mode\n"+
59  "-o <ofile> Ouptut file of binary data\n",
60  files, cmd_line);
61 
62  EST_String out_file;
63 
64  if (cmd_line.present("-o"))
65  out_file = cmd_line.val("-o");
66  else
67  EST_error("No output file specified");
68 
69  FILE *dest;
70 
71  if ((dest=fopen(out_file, "wb")) == NULL)
72  EST_sys_error("Can't create '%s'", (const char *)out_file);
73 
74  EST_Litem *item;
75 
76  for(item=files.head(); item; item = item->next())
77  {
78  FILE *src;
79 
80  if ((src=fopen(files(item), "rb"))==NULL)
81  EST_sys_error("can't read '%s'", (const char *)files(item));
82 
83  unsigned int n;
84  char buf[BUFFER_SIZE];
85 
86  while((n=fread(buf, sizeof(char), BUFFER_SIZE, src)) >0)
87  if (fwrite(buf, sizeof(char), n, dest) < n)
88  EST_sys_error("write error");
89 
90  fclose(src);
91  }
92 
93  fclose(dest);
94 
95  return 0;
96 }
97 
98 
99 
100 
const int present(const K &rkey) const
Returns true if key is present.
Definition: EST_TKVL.cc:222
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
Definition: EST_TKVL.cc:145