shp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +34 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +28 -0
  6. data/README.md +30 -0
  7. data/Rakefile +23 -0
  8. data/ext/shp/base.hpp +113 -0
  9. data/ext/shp/dbf.cpp +381 -0
  10. data/ext/shp/dbf.hpp +44 -0
  11. data/ext/shp/extconf.rb +13 -0
  12. data/ext/shp/shape_object.cpp +58 -0
  13. data/ext/shp/shape_object.hpp +27 -0
  14. data/ext/shp/shapefile.cpp +299 -0
  15. data/ext/shp/shapefile.hpp +35 -0
  16. data/ext/shp/shapelib/.cvsignore +15 -0
  17. data/ext/shp/shapelib/ChangeLog +450 -0
  18. data/ext/shp/shapelib/HOWTO-RELEASE +16 -0
  19. data/ext/shp/shapelib/LICENSE.LGPL +483 -0
  20. data/ext/shp/shapelib/Makefile +113 -0
  21. data/ext/shp/shapelib/README +41 -0
  22. data/ext/shp/shapelib/README.tree +172 -0
  23. data/ext/shp/shapelib/contrib/.cvsignore +12 -0
  24. data/ext/shp/shapelib/contrib/Makefile +66 -0
  25. data/ext/shp/shapelib/contrib/ShapeFileII.pas +234 -0
  26. data/ext/shp/shapelib/contrib/Shape_PointInPoly.cpp +238 -0
  27. data/ext/shp/shapelib/contrib/Shape_PointInPoly_README.txt +59 -0
  28. data/ext/shp/shapelib/contrib/csv2shp.c +558 -0
  29. data/ext/shp/shapelib/contrib/dbfcat.c +166 -0
  30. data/ext/shp/shapelib/contrib/dbfinfo.c +106 -0
  31. data/ext/shp/shapelib/contrib/makefile.vc +34 -0
  32. data/ext/shp/shapelib/contrib/my_nan.h +46 -0
  33. data/ext/shp/shapelib/contrib/shpcat.c +100 -0
  34. data/ext/shp/shapelib/contrib/shpcentrd.c +159 -0
  35. data/ext/shp/shapelib/contrib/shpdata.c +129 -0
  36. data/ext/shp/shapelib/contrib/shpdxf.c +340 -0
  37. data/ext/shp/shapelib/contrib/shpfix.c +110 -0
  38. data/ext/shp/shapelib/contrib/shpgeo.c +1595 -0
  39. data/ext/shp/shapelib/contrib/shpgeo.h +154 -0
  40. data/ext/shp/shapelib/contrib/shpinfo.c +113 -0
  41. data/ext/shp/shapelib/contrib/shpproj.c +260 -0
  42. data/ext/shp/shapelib/contrib/shpsort.c +605 -0
  43. data/ext/shp/shapelib/contrib/shpsort.txt +44 -0
  44. data/ext/shp/shapelib/contrib/shpwkb.c +123 -0
  45. data/ext/shp/shapelib/contrib/tests/shpproj.sh +38 -0
  46. data/ext/shp/shapelib/dbfopen.c +2221 -0
  47. data/ext/shp/shapelib/makefile.vc +86 -0
  48. data/ext/shp/shapelib/makeshape.sh +21 -0
  49. data/ext/shp/shapelib/mkdist.sh +37 -0
  50. data/ext/shp/shapelib/mkinstalldirs +38 -0
  51. data/ext/shp/shapelib/mkrelease.sh +55 -0
  52. data/ext/shp/shapelib/safileio.c +286 -0
  53. data/ext/shp/shapelib/shapefil.h +647 -0
  54. data/ext/shp/shapelib/shapelib.def +46 -0
  55. data/ext/shp/shapelib/shpopen.c +2388 -0
  56. data/ext/shp/shapelib/shptree.c +1187 -0
  57. data/ext/shp/shapelib/shputils.c +1072 -0
  58. data/ext/shp/shapelib/stream1.out +1465 -0
  59. data/ext/shp/shapelib/stream1.sh +28 -0
  60. data/ext/shp/shapelib/stream2.out +530 -0
  61. data/ext/shp/shapelib/stream2.sh +11 -0
  62. data/ext/shp/shapelib/stream3.out +37 -0
  63. data/ext/shp/shapelib/web/.cvsignore +2 -0
  64. data/ext/shp/shapelib/web/codepage.html +403 -0
  65. data/ext/shp/shapelib/web/dbf_api.html +436 -0
  66. data/ext/shp/shapelib/web/index.html +235 -0
  67. data/ext/shp/shapelib/web/license.html +78 -0
  68. data/ext/shp/shapelib/web/manifest.html +87 -0
  69. data/ext/shp/shapelib/web/release.html +80 -0
  70. data/ext/shp/shapelib/web/shapelib-tools.html +352 -0
  71. data/ext/shp/shapelib/web/shp_api.html +376 -0
  72. data/ext/shp/shp.cpp +19 -0
  73. data/ext/shp/shp.hpp +47 -0
  74. data/lib/shp.rb +35 -0
  75. data/lib/shp/version.rb +3 -0
  76. data/shp.gemspec +23 -0
  77. data/spec/shp_spec.rb +127 -0
  78. metadata +176 -0
@@ -0,0 +1,86 @@
1
+
2
+ #CFLAGS = /DSHPAPI_CALL=__stdcall
3
+ CFLAGS = /nologo /Ox /MD /DSHAPELIB_DLLEXPORT
4
+
5
+ IMPORT_LIB = shapelib_i.lib
6
+ STATIC_LIB = shapelib.lib
7
+ DLLNAME = shapelib.dll
8
+ LINK_LIB = $(IMPORT_LIB)
9
+
10
+ OBJ = shpopen.obj dbfopen.obj shptree.obj safileio.obj
11
+
12
+ all: $(STATIC_LIB) $(DLLNAME) \
13
+ shpcreate.exe shpadd.exe shpdump.exe shprewind.exe dbfcreate.exe \
14
+ dbfadd.exe dbfdump.exe shptest.exe shptreedump.exe
15
+
16
+ shpopen.obj: shpopen.c shapefil.h
17
+ $(CC) $(CFLAGS) -c shpopen.c
18
+
19
+ shptree.obj: shptree.c shapefil.h
20
+ $(CC) $(CFLAGS) -c shptree.c
21
+
22
+ dbfopen.obj: dbfopen.c shapefil.h
23
+ $(CC) $(CFLAGS) -c dbfopen.c
24
+
25
+ safileio.obj: safileio.c shapefil.h
26
+ $(CC) $(CFLAGS) -c safileio.c
27
+
28
+ shpcreate.exe: shpcreate.c $(LINK_LIB)
29
+ $(CC) $(CFLAGS) shpcreate.c $(LINK_LIB) $(LINKOPT)
30
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
31
+
32
+ shpadd.exe: shpadd.c $(LINK_LIB)
33
+ $(CC) $(CFLAGS) shpadd.c $(LINK_LIB) $(LINKOPT)
34
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
35
+
36
+ shpdump.exe: shpdump.c $(LINK_LIB)
37
+ $(CC) $(CFLAGS) shpdump.c $(LINK_LIB) $(LINKOPT)
38
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
39
+
40
+ shprewind.exe: shprewind.c $(LINK_LIB)
41
+ $(CC) $(CFLAGS) shprewind.c $(LINK_LIB) $(LINKOPT)
42
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
43
+
44
+ dbfcreate.exe: dbfcreate.c $(LINK_LIB)
45
+ $(CC) $(CFLAGS) dbfcreate.c $(LINK_LIB) $(LINKOPT)
46
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
47
+
48
+ dbfadd.exe: dbfadd.c $(LINK_LIB)
49
+ $(CC) $(CFLAGS) dbfadd.c $(LINK_LIB) $(LINKOPT)
50
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
51
+
52
+ dbfdump.exe: dbfdump.c $(LINK_LIB)
53
+ $(CC) $(CFLAGS) dbfdump.c $(LINK_LIB) $(LINKOPT)
54
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
55
+
56
+ shptest.exe: shptest.c $(LINK_LIB)
57
+ $(CC) $(CFLAGS) shptest.c $(LINK_LIB) $(LINKOPT)
58
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
59
+
60
+ shputils.exe: shputils.c $(LINK_LIB)
61
+ $(CC) $(CFLAGS) shputils.c $(LINK_LIB) $(LINKOPT)
62
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
63
+
64
+ shptreedump.exe: shptreedump.c $(LINK_LIB)
65
+ $(CC) $(CFLAGS) shptreedump.c $(LINK_LIB) $(LINKOPT)
66
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
67
+
68
+ shpdiff.exe: shpdiff.c $(LINK_LIB)
69
+ $(CC) $(CFLAGS) shpdiff.c $(LINK_LIB) $(LINKOPT)
70
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
71
+
72
+ clean:
73
+ -del *.obj
74
+ -del *.exe
75
+ -del *.lib
76
+ -del *.dll
77
+ -del *.manifest
78
+
79
+ $(STATIC_LIB): $(OBJ)
80
+ lib /nologo /out:$(STATIC_LIB) $(OBJ)
81
+
82
+ $(IMPORT_LIB): $(DLLNAME)
83
+
84
+ $(DLLNAME): $(OBJ)
85
+ link /nologo /dll /out:$(DLLNAME) /implib:$(IMPORT_LIB) $(OBJ)
86
+ if exist $(DLLNAME).manifest mt /nologo -manifest $(DLLNAME).manifest -outputresource:$(DLLNAME);2
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Use example programs to create a very simple dataset that
5
+ # should display in ARCView II.
6
+ #
7
+
8
+ ./shpcreate test polygon
9
+ ./dbfcreate test.dbf -s Description 30 -n TestInt 6 0 -n TestDouble 16 5
10
+
11
+ ./shpadd test 0 0 100 0 100 100 0 100 0 0 + 20 20 20 30 30 30 20 20
12
+ ./dbfadd test.dbf "Square with triangle missing" 1.5 2.5
13
+
14
+ ./shpadd test 150 150 160 150 180 170 150 150
15
+ ./dbfadd test.dbf "Smaller triangle" 100 1000.25
16
+
17
+ ./shpadd test 150 150 160 150 180 170 150 150
18
+ ./dbfadd test.dbf "" "" ""
19
+
20
+ ./shpdump test.shp
21
+ ./dbfdump test.dbf
@@ -0,0 +1,37 @@
1
+ #!/bin/sh
2
+
3
+ if [ $# -lt 1 ] ; then
4
+ echo "Usage: mkdist.sh <version>"
5
+ echo " <version> - version number used in name of generated archive."
6
+ echo "Example: mkdist.sh 1.1.4"
7
+ exit
8
+ fi
9
+
10
+ VERSION=$1
11
+
12
+ rm -rf dist_wrk
13
+ mkdir dist_wrk
14
+ cd dist_wrk
15
+
16
+ REP=:pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot
17
+ if cvs -d $REP co shapelib ; then
18
+ echo checkout succeeds.
19
+ else
20
+ cvs -d $REP login
21
+ cvs -d $REP co shapelib
22
+ fi
23
+
24
+ if [ ! -d shapelib ] ; then
25
+ exit 1
26
+ fi
27
+
28
+ mv shapelib shapelib-$VERSION
29
+
30
+ find . -name CVS -type d -exec echo rm -rf {} \;
31
+
32
+ tar czvf ../shapelib-$VERSION.tar.gz shapelib-$VERSION
33
+ zip -r ../shapelib-$VERSION.zip shapelib-$VERSION
34
+ cd ..
35
+ rm -rf dist_wrk
36
+
37
+
@@ -0,0 +1,38 @@
1
+ #! /bin/sh
2
+ # mkinstalldirs --- make directory hierarchy
3
+ # Author: Noah Friedman <friedman@prep.ai.mit.edu>
4
+ # Created: 1993-05-16
5
+ # Public domain
6
+
7
+ errstatus=0
8
+
9
+ for file
10
+ do
11
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
12
+ shift
13
+
14
+ pathcomp=
15
+ for d
16
+ do
17
+ pathcomp="$pathcomp$d"
18
+ case "$pathcomp" in
19
+ -* ) pathcomp=./$pathcomp ;;
20
+ esac
21
+
22
+ if test ! -d "$pathcomp"; then
23
+ echo "mkdir $pathcomp"
24
+
25
+ mkdir "$pathcomp" || lasterr=$?
26
+
27
+ if test ! -d "$pathcomp"; then
28
+ errstatus=$lasterr
29
+ fi
30
+ fi
31
+
32
+ pathcomp="$pathcomp/"
33
+ done
34
+ done
35
+
36
+ exit $errstatus
37
+
38
+ # mkinstalldirs ends here
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ #
3
+ # mkrelease.sh - prepares Shapelib source distribution package
4
+ #
5
+ if [ $# -lt 1 ] ; then
6
+ echo "Usage: mkrelease.sh <version>"
7
+ echo " <version> - version number used in name of generated archive."
8
+ echo
9
+ echo "Example: mkrelease 1.3.0beta1"
10
+ exit
11
+ fi
12
+
13
+ #
14
+ # Processing script input arguments
15
+ #
16
+ VERSION=$1
17
+
18
+ #
19
+ # Checkout Shapelib sources from the repository
20
+ #
21
+ echo "* Downloading Shapelib sources from CVS..."
22
+ rm -rf dist_wrk
23
+ mkdir dist_wrk
24
+ cd dist_wrk
25
+
26
+ cvs -d :pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot export -D now shapelib
27
+
28
+ if [ \! -d shapelib ] ; then
29
+ echo "checkout reported an error ..."
30
+ echo "perhaps you need to do:"
31
+ echo "cvs -d :pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot login"
32
+ cd ..
33
+ rm -rf dist_wrk
34
+ exit
35
+ fi
36
+
37
+ #
38
+ # Make distribution packages
39
+ #
40
+ echo "* Making distribution packages..."
41
+
42
+ mv shapelib shapelib-${VERSION}
43
+
44
+ rm -f ../shapelib-${VERSION}.tar.gz ../shapelib-${VERSION}.zip
45
+
46
+ tar cf ../shapelib-${VERSION}.tar shapelib-${VERSION}
47
+ gzip -9 ../shapelib-${VERSION}.tar
48
+ zip -r ../shapelib-${VERSION}.zip shapelib-${VERSION}
49
+
50
+ echo "* Cleaning..."
51
+ cd ..
52
+ rm -rf dist_wrk
53
+
54
+ echo "*** The End ***"
55
+
@@ -0,0 +1,286 @@
1
+ /******************************************************************************
2
+ * $Id: safileio.c,v 1.4 2008-01-16 20:05:14 bram Exp $
3
+ *
4
+ * Project: Shapelib
5
+ * Purpose: Default implementation of file io based on stdio.
6
+ * Author: Frank Warmerdam, warmerdam@pobox.com
7
+ *
8
+ ******************************************************************************
9
+ * Copyright (c) 2007, Frank Warmerdam
10
+ *
11
+ * This software is available under the following "MIT Style" license,
12
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
13
+ * option is discussed in more detail in shapelib.html.
14
+ *
15
+ * --
16
+ *
17
+ * Permission is hereby granted, free of charge, to any person obtaining a
18
+ * copy of this software and associated documentation files (the "Software"),
19
+ * to deal in the Software without restriction, including without limitation
20
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
21
+ * and/or sell copies of the Software, and to permit persons to whom the
22
+ * Software is furnished to do so, subject to the following conditions:
23
+ *
24
+ * The above copyright notice and this permission notice shall be included
25
+ * in all copies or substantial portions of the Software.
26
+ *
27
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
28
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33
+ * DEALINGS IN THE SOFTWARE.
34
+ ******************************************************************************
35
+ *
36
+ * $Log: safileio.c,v $
37
+ * Revision 1.4 2008-01-16 20:05:14 bram
38
+ * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks
39
+ * tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this
40
+ * is only available on the Windows platform that decodes the UTF-8 filenames to wide
41
+ * character strings and feeds them to _wfopen and _wremove.
42
+ *
43
+ * Revision 1.3 2007/12/18 18:28:11 bram
44
+ * - create hook for client specific atof (bugzilla ticket 1615)
45
+ * - check for NULL handle before closing cpCPG file, and close after reading.
46
+ *
47
+ * Revision 1.2 2007/12/15 20:25:30 bram
48
+ * dbfopen.c now reads the Code Page information from the DBF file, and exports
49
+ * this information as a string through the DBFGetCodePage function. This is
50
+ * either the number from the LDID header field ("LDID/<number>") or as the
51
+ * content of an accompanying .CPG file. When creating a DBF file, the code can
52
+ * be set using DBFCreateEx.
53
+ *
54
+ * Revision 1.1 2007/12/06 06:56:41 fwarmerdam
55
+ * new
56
+ *
57
+ */
58
+
59
+ #include "shapefil.h"
60
+
61
+ #include <math.h>
62
+ #include <limits.h>
63
+ #include <assert.h>
64
+ #include <stdlib.h>
65
+ #include <string.h>
66
+ #include <stdio.h>
67
+
68
+ SHP_CVSID("$Id: safileio.c,v 1.4 2008-01-16 20:05:14 bram Exp $");
69
+
70
+ #ifdef SHPAPI_UTF8_HOOKS
71
+ # ifdef SHPAPI_WINDOWS
72
+ # define WIN32_LEAN_AND_MEAN
73
+ # define NOMINMAX
74
+ # include <windows.h>
75
+ # pragma comment(lib, "kernel32.lib")
76
+ # endif
77
+ #endif
78
+
79
+ /************************************************************************/
80
+ /* SADFOpen() */
81
+ /************************************************************************/
82
+
83
+ SAFile SADFOpen( const char *pszFilename, const char *pszAccess )
84
+
85
+ {
86
+ return (SAFile) fopen( pszFilename, pszAccess );
87
+ }
88
+
89
+ /************************************************************************/
90
+ /* SADFRead() */
91
+ /************************************************************************/
92
+
93
+ SAOffset SADFRead( void *p, SAOffset size, SAOffset nmemb, SAFile file )
94
+
95
+ {
96
+ return (SAOffset) fread( p, (size_t) size, (size_t) nmemb,
97
+ (FILE *) file );
98
+ }
99
+
100
+ /************************************************************************/
101
+ /* SADFWrite() */
102
+ /************************************************************************/
103
+
104
+ SAOffset SADFWrite( void *p, SAOffset size, SAOffset nmemb, SAFile file )
105
+
106
+ {
107
+ return (SAOffset) fwrite( p, (size_t) size, (size_t) nmemb,
108
+ (FILE *) file );
109
+ }
110
+
111
+ /************************************************************************/
112
+ /* SADFSeek() */
113
+ /************************************************************************/
114
+
115
+ SAOffset SADFSeek( SAFile file, SAOffset offset, int whence )
116
+
117
+ {
118
+ return (SAOffset) fseek( (FILE *) file, (long) offset, whence );
119
+ }
120
+
121
+ /************************************************************************/
122
+ /* SADFTell() */
123
+ /************************************************************************/
124
+
125
+ SAOffset SADFTell( SAFile file )
126
+
127
+ {
128
+ return (SAOffset) ftell( (FILE *) file );
129
+ }
130
+
131
+ /************************************************************************/
132
+ /* SADFFlush() */
133
+ /************************************************************************/
134
+
135
+ int SADFFlush( SAFile file )
136
+
137
+ {
138
+ return fflush( (FILE *) file );
139
+ }
140
+
141
+ /************************************************************************/
142
+ /* SADFClose() */
143
+ /************************************************************************/
144
+
145
+ int SADFClose( SAFile file )
146
+
147
+ {
148
+ return fclose( (FILE *) file );
149
+ }
150
+
151
+ /************************************************************************/
152
+ /* SADFClose() */
153
+ /************************************************************************/
154
+
155
+ int SADRemove( const char *filename )
156
+
157
+ {
158
+ return remove( filename );
159
+ }
160
+
161
+ /************************************************************************/
162
+ /* SADError() */
163
+ /************************************************************************/
164
+
165
+ void SADError( const char *message )
166
+
167
+ {
168
+ fprintf( stderr, "%s\n", message );
169
+ }
170
+
171
+ /************************************************************************/
172
+ /* SASetupDefaultHooks() */
173
+ /************************************************************************/
174
+
175
+ void SASetupDefaultHooks( SAHooks *psHooks )
176
+
177
+ {
178
+ psHooks->FOpen = SADFOpen;
179
+ psHooks->FRead = SADFRead;
180
+ psHooks->FWrite = SADFWrite;
181
+ psHooks->FSeek = SADFSeek;
182
+ psHooks->FTell = SADFTell;
183
+ psHooks->FFlush = SADFFlush;
184
+ psHooks->FClose = SADFClose;
185
+ psHooks->Remove = SADRemove;
186
+
187
+ psHooks->Error = SADError;
188
+ psHooks->Atof = atof;
189
+ }
190
+
191
+
192
+
193
+
194
+ #ifdef SHPAPI_WINDOWS
195
+
196
+ /************************************************************************/
197
+ /* Utf8ToWideChar */
198
+ /************************************************************************/
199
+
200
+ const wchar_t* Utf8ToWideChar( const char *pszFilename )
201
+ {
202
+ int nMulti, nWide;
203
+ wchar_t *pwszFileName;
204
+
205
+ nMulti = strlen(pszFilename) + 1;
206
+ nWide = MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, 0, 0);
207
+ if( nWide == 0 )
208
+ {
209
+ return NULL;
210
+ }
211
+ pwszFileName = (wchar_t*) malloc(nWide * sizeof(wchar_t));
212
+ if ( pwszFileName == NULL )
213
+ {
214
+ return NULL;
215
+ }
216
+ if( MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, pwszFileName, nWide ) == 0 )
217
+ {
218
+ free( pwszFileName );
219
+ return NULL;
220
+ }
221
+ return pwszFileName;
222
+ }
223
+
224
+ /************************************************************************/
225
+ /* SAUtf8WFOpen */
226
+ /************************************************************************/
227
+
228
+ SAFile SAUtf8WFOpen( const char *pszFilename, const char *pszAccess )
229
+ {
230
+ SAFile file = NULL;
231
+ const wchar_t *pwszFileName, *pwszAccess;
232
+ pwszFileName = Utf8ToWideChar( pszFilename );
233
+ pwszAccess = Utf8ToWideChar( pszAccess );
234
+ if( pwszFileName != NULL && pwszFileName != NULL)
235
+ {
236
+ file = (SAFile) _wfopen( pwszFileName, pwszAccess );
237
+ }
238
+ free ((wchar_t*) pwszFileName);
239
+ free ((wchar_t*) pwszAccess);
240
+ return file;
241
+ }
242
+
243
+ /************************************************************************/
244
+ /* SAUtf8WRemove() */
245
+ /************************************************************************/
246
+
247
+ int SAUtf8WRemove( const char *pszFilename )
248
+ {
249
+ const wchar_t *pwszFileName = Utf8ToWideChar( pszFilename );
250
+ int rc = -1;
251
+ if( pwszFileName != NULL )
252
+ {
253
+ rc = _wremove( pwszFileName );
254
+ }
255
+ free ((wchar_t*) pwszFileName);
256
+ return rc;
257
+ }
258
+
259
+ #endif
260
+
261
+ #ifdef SHPAPI_UTF8_HOOKS
262
+
263
+ /************************************************************************/
264
+ /* SASetupUtf8Hooks() */
265
+ /************************************************************************/
266
+
267
+ void SASetupUtf8Hooks( SAHooks *psHooks )
268
+ {
269
+ #ifdef SHPAPI_WINDOWS
270
+ psHooks->FOpen = SAUtf8WFOpen;
271
+ psHooks->Remove = SAUtf8WRemove;
272
+ #else
273
+ # error "no implementations of UTF-8 hooks available for this platform"
274
+ #endif
275
+ psHooks->FRead = SADFRead;
276
+ psHooks->FWrite = SADFWrite;
277
+ psHooks->FSeek = SADFSeek;
278
+ psHooks->FTell = SADFTell;
279
+ psHooks->FFlush = SADFFlush;
280
+ psHooks->FClose = SADFClose;
281
+
282
+ psHooks->Error = SADError;
283
+ psHooks->Atof = atof;
284
+ }
285
+
286
+ #endif