~ubuntu-branches/ubuntu/maverick/speech-tools/maverick

1 by David Huggins-Daines
Import upstream version 1.2.2
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
 /*                 Author: Richard Caley (rjc@cstr.ed.ac.uk)            */
34
 /*                   Date: Tue Apr 29 1997                              */
35
 /************************************************************************/
36
 /*                                                                      */
37
 /* Test of EST_Pathname class.                                          */
38
 /*                                                                      */
39
 /************************************************************************/
40
1.1.2 by Kartik Mistry
Import upstream version 1.2.96~beta
41
#include <cstdlib>
1 by David Huggins-Daines
Import upstream version 1.2.2
42
#include "EST_Pathname.h"
43
44
#if defined(DATAC)
45
#    define __STRINGIZE(X) #X
46
#    define DATA __STRINGIZE(DATAC)
47
#endif
48
49
int main(void)
50
{
51
52
  // a relative pathname
53
54
  EST_Pathname f;
55
56
  f= "baz/ptooie";
57
58
  // can be used as a file or a directory
59
60
  cout << "file f = " << f.as_file() << "\n";
61
  cout << "dir f  = " << f.as_directory() << "\n";
62
63
  // and absolute one
64
  
65
  EST_Pathname d;
66
67
  d = "/foo/bar/";
68
69
  // we can combine paths as expected
70
71
  cout << "combine = " << d+f << "\n";
72
  cout << "combine = " << f+f << "\n";
73
74
  // and can build up paths from components
75
76
  EST_Pathname built(EST_Pathname::construct(d,f,"test"));
77
78
  cout << "    build = " << built << "\n";
79
  cout << " filename = " << built.filename() << "\n";
80
  cout << "extension = " << built.extension() << "\n";
81
  cout << " basename = " << built.basename() << "\n";
82
  cout << "basename1 = " << built.basename(1) << "\n";
83
84
  EST_Pathname data(DATA);
85
86
  // getting the contents of a directory...
87
  EST_TList<EST_String> contents(data.entries());
88
89
  sort(contents);
90
91
  cout << "listing " << data.filename() << ":\n";
92
93
  EST_Litem *item;
94
  for(item=contents.head(); item; item=next(item))
95
    if (EST_Pathname(contents(item)).is_filename())
96
      cout << "    " << contents(item) << "\n";
97
98
  cout << "done.\n";
99
100
  return (0);
101
}
102