Fawkes API  Fawkes Development Version
filetype.h
1 
2 /***************************************************************************
3  * filetype.h - little utility to decide on filetype, this FireVision
4  * version can also detect FvRaw images.
5  *
6  * Generated: Tue Feb 23 13:49:38 2005
7  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef _FIREVISION_FVUTILS_FILETYPE_H_
26 #define _FIREVISION_FVUTILS_FILETYPE_H_
27 
28 #include <core/exception.h>
29 #include <fvutils/colormap/cmfile.h>
30 #include <fvutils/readers/fvraw.h>
31 #include <utils/system/filetype.h>
32 
33 #include <string>
34 
35 namespace firevision {
36 
37 inline std::string
38 fv_filetype_file(const char *filename)
39 {
40  std::string rv;
41 
42  try {
43  rv = fawkes::filetype_file(filename);
44  } catch (fawkes::Exception &e) {
45  // Some error occured, most likely libmagic was not available at compile
46  // time, assume data to make our own checks, we just cannot detect JPG
47  // and PNG in this case.
48  rv = "data";
49  }
50 
51  if (rv == "data") {
52  if (FvRawReader::is_FvRaw(filename)) {
53  rv = "FvRaw";
54  } else if (ColormapFile::is_colormap_file(filename)) {
55  rv = "FvColormap";
56  }
57  }
58 
59  return rv;
60 }
61 
62 } // end namespace firevision
63 
64 #endif
fawkes::filetype_file
std::string filetype_file(const char *filename)
Get filetype of file.
Definition: filetype.cpp:45
firevision::ColormapFile::is_colormap_file
static bool is_colormap_file(const char *filename)
Check if given file is a colormap file.
Definition: cmfile.cpp:202
firevision::FvRawReader::is_FvRaw
static bool is_FvRaw(const char *filename)
Check if given file contains FvRaw image.
Definition: fvraw.cpp:130
fawkes::Exception
Base class for exceptions in Fawkes.
Definition: exception.h:36