FreeWRL/FreeX3D  3.0.0
io_files.h
1 /*
2 
3  FreeWRL support library.
4  IO with files.
5 
6 */
7 
8 /****************************************************************************
9  This file is part of the FreeWRL/FreeX3D Distribution.
10 
11  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12 
13  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14  it under the terms of the GNU Lesser Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25 ****************************************************************************/
26 
27 #ifndef __LIBFREEWRL_IO_FILES_H__
28 #define __LIBFREEWRL_IO_FILES_H__
29 
30 void fwg_frontEndReturningData(char* fileData,int length,int width,int height,bool hasAlpha);
31 void fwg_frontEndReturningLocalFile(char *localfile, int iret);
32 void process_x3z(resource_item_t *res);
33 
34 /* Path manipulation */
35 char* concat_path(const char *a, const char *b);
36 char* remove_filename_from_path(const char *path);
37 
38 
39 /* Simple functions for file/dir access */
40 char *get_current_dir();
41 bool do_file_exists(const char *filename);
42 bool do_file_readable(const char *filename);
43 bool do_dir_exists(const char *dir);
44 int fw_mkdir(const char* path);
45 
46 typedef struct openned_file {
47  const char *fileFileName;
48  int fileDescriptor;
49  int fileDataSize;
50  char *fileData;
51  int imageHeight;
52  int imageWidth;
53  bool imageAlpha;
54  int imageChannels;
56 
57 void of_dump(openned_file_t *of);
58 openned_file_t* load_file(const char *filename);
59 
64 /* VRML/X3D version */
65 #define IS_TYPE_UNKNOWN 200
66 #define IS_TYPE_XML_X3D 100
67 #define IS_TYPE_VRML 101
68 #define IS_TYPE_VRML1 102
69 
70 #if defined (INCLUDE_NON_WEB3D_FORMATS)
71 #define IS_TYPE_SKETCHUP 103
72 #define IS_TYPE_KML 104
73 #define IS_TYPE_COLLADA 105
74 #endif //INCLUDE_NON_WEB3D_FORMATS
75 
76 #if defined (INCLUDE_STL_FILES)
77 #define IS_TYPE_ASCII_STL 300
78 #define IS_TYPE_BINARY_STL 301
79 #endif //INCLUDE_STL_FILES
80 
81 
82 extern int inputFileType;
83 extern int inputFileVersion[];
84 
85 int determineFileType(const char *buffer, const int len);
86 
87 
88 /* borrowed from headers.h -- need a clean-up */
89 
90 /* types to tell the Perl thread what to handle */
91 #define FROMSTRING 1
92 #define FROMURL 2
93 #define INLINE 3
94 #define ZEROBINDABLES 8 /* get rid of Perl datastructures */
95 #define FROMCREATENODE 13 /* create a node by just giving its node type */
96 #define FROMCREATEPROTO 14 /* create a node by just giving its node type */
97 #define UPDATEPROTOD 16 /* update a PROTO definition */
98 #define GETPROTOD 17 /* update a PROTO definition */
99 
100 #ifdef _MSC_VER
101 #include <io.h>
102 #include <fcntl.h>
103 #include <stdio.h>
104 #define R_OK 4
105 #define X_OK 4
106 #define O_NONBLOCK 0
107 #define SSIZE_MAX 100000000L
108 #define close _close
109 #define open _open
110 #define read _read
111 #define write _write
112 #endif
113 #endif /* __LIBFREEWRL_IO_FILES_H__ */