Fossil SCM
s/unlink/remove/ for Windows build (thanks again to Robert Engelhardt).
Commit
ea8d28acf3b33fb8cfa09170e54bcc1f36e6c403
Parent
58d415644631a3b…
1 file changed
+12
-9
+12
-9
| --- src/cson_amalgamation.c | ||
| +++ src/cson_amalgamation.c | ||
| @@ -5265,11 +5265,11 @@ | ||
| 5265 | 5265 | names[i] = NULL; |
| 5266 | 5266 | return names; |
| 5267 | 5267 | } |
| 5268 | 5268 | /* end file ./cson_session.c */ |
| 5269 | 5269 | /* begin file ./cson_session_file.c */ |
| 5270 | -#if !defined(_WIN32) | |
| 5270 | +#if !defined(_WIN32) && !defined(_WIN64) | |
| 5271 | 5271 | # if !defined(_POSIX_VERSION) |
| 5272 | 5272 | # define _POSIX_VERSION 200112L /* chmod(), unlink() */ |
| 5273 | 5273 | # endif |
| 5274 | 5274 | # define ENABLE_POSIX_FILE_OPS 1 |
| 5275 | 5275 | #else |
| @@ -5278,12 +5278,20 @@ | ||
| 5278 | 5278 | |
| 5279 | 5279 | #include <stdlib.h> |
| 5280 | 5280 | #include <string.h> |
| 5281 | 5281 | #include <assert.h> |
| 5282 | 5282 | #if ENABLE_POSIX_FILE_OPS |
| 5283 | +# define UNLINK_FILE unlink | |
| 5283 | 5284 | # include <unistd.h> /* unlink() */ |
| 5284 | 5285 | # include <sys/stat.h> /* chmod() */ |
| 5286 | +#else | |
| 5287 | +/* http://msdn.microsoft.com/en-us/library/1c3tczd6(v=vs.80).aspx | |
| 5288 | + # define UNLINK_FILE _unlink | |
| 5289 | + # include <io.h> | |
| 5290 | +*/ | |
| 5291 | +# define UNLINK_FILE remove | |
| 5292 | +# include <stdio.h> /* remove(), _unlink() */ | |
| 5285 | 5293 | #endif |
| 5286 | 5294 | |
| 5287 | 5295 | static int cson_session_file_load( cson_sessmgr * self, cson_value ** tgt, char const * id ); |
| 5288 | 5296 | static int cson_session_file_save( cson_sessmgr * self, cson_value const * root, char const * id ); |
| 5289 | 5297 | static int cson_session_file_remove( cson_sessmgr * self, char const * id ); |
| @@ -5404,16 +5412,14 @@ | ||
| 5404 | 5412 | #if ENABLE_POSIX_FILE_OPS |
| 5405 | 5413 | chmod( fname, 0600 ); |
| 5406 | 5414 | #endif |
| 5407 | 5415 | rc = cson_output_FILE( root, fh, NULL ); |
| 5408 | 5416 | fclose( fh ); |
| 5409 | -#if ENABLE_POSIX_FILE_OPS | |
| 5410 | 5417 | if( rc ) |
| 5411 | 5418 | { |
| 5412 | - unlink( fname ); | |
| 5419 | + UNLINK_FILE( fname ); | |
| 5413 | 5420 | } |
| 5414 | -#endif | |
| 5415 | 5421 | return rc; |
| 5416 | 5422 | } |
| 5417 | 5423 | |
| 5418 | 5424 | void cson_session_file_finalize( cson_sessmgr * self ) |
| 5419 | 5425 | { |
| @@ -5437,15 +5443,11 @@ | ||
| 5437 | 5443 | IMPL_DECL(cson_rc.ArgError); |
| 5438 | 5444 | if( !id || !*id ) return cson_rc.ArgError; |
| 5439 | 5445 | memset( fname, 0, BufSize ); |
| 5440 | 5446 | rc = cson_session_file_name( impl, id, fname, BufSize ); |
| 5441 | 5447 | if( 0 != rc ) return rc; |
| 5442 | -#if ENABLE_POSIX_FILE_OPS | |
| 5443 | - rc = unlink( fname ); | |
| 5444 | -#else | |
| 5445 | -# error "unlink not implemented for this platform." | |
| 5446 | -#endif | |
| 5448 | + rc = UNLINK_FILE( fname ); | |
| 5447 | 5449 | return (0==rc) ? 0 : cson_rc.IOError; |
| 5448 | 5450 | } |
| 5449 | 5451 | |
| 5450 | 5452 | |
| 5451 | 5453 | int cson_sessmgr_file( cson_sessmgr ** tgt, cson_object const * opt ) |
| @@ -5503,10 +5505,11 @@ | ||
| 5503 | 5505 | return rc; |
| 5504 | 5506 | } |
| 5505 | 5507 | |
| 5506 | 5508 | #undef IMPL_DECL |
| 5507 | 5509 | #undef ENABLE_POSIX_FILE_OPS |
| 5510 | +#undef UNLINK_FILE | |
| 5508 | 5511 | /* end file ./cson_session_file.c */ |
| 5509 | 5512 | /* begin file ./cson_sqlite3.c */ |
| 5510 | 5513 | /** @file cson_sqlite3.c |
| 5511 | 5514 | |
| 5512 | 5515 | This file contains the implementation code for the cson |
| 5513 | 5516 |
| --- src/cson_amalgamation.c | |
| +++ src/cson_amalgamation.c | |
| @@ -5265,11 +5265,11 @@ | |
| 5265 | names[i] = NULL; |
| 5266 | return names; |
| 5267 | } |
| 5268 | /* end file ./cson_session.c */ |
| 5269 | /* begin file ./cson_session_file.c */ |
| 5270 | #if !defined(_WIN32) |
| 5271 | # if !defined(_POSIX_VERSION) |
| 5272 | # define _POSIX_VERSION 200112L /* chmod(), unlink() */ |
| 5273 | # endif |
| 5274 | # define ENABLE_POSIX_FILE_OPS 1 |
| 5275 | #else |
| @@ -5278,12 +5278,20 @@ | |
| 5278 | |
| 5279 | #include <stdlib.h> |
| 5280 | #include <string.h> |
| 5281 | #include <assert.h> |
| 5282 | #if ENABLE_POSIX_FILE_OPS |
| 5283 | # include <unistd.h> /* unlink() */ |
| 5284 | # include <sys/stat.h> /* chmod() */ |
| 5285 | #endif |
| 5286 | |
| 5287 | static int cson_session_file_load( cson_sessmgr * self, cson_value ** tgt, char const * id ); |
| 5288 | static int cson_session_file_save( cson_sessmgr * self, cson_value const * root, char const * id ); |
| 5289 | static int cson_session_file_remove( cson_sessmgr * self, char const * id ); |
| @@ -5404,16 +5412,14 @@ | |
| 5404 | #if ENABLE_POSIX_FILE_OPS |
| 5405 | chmod( fname, 0600 ); |
| 5406 | #endif |
| 5407 | rc = cson_output_FILE( root, fh, NULL ); |
| 5408 | fclose( fh ); |
| 5409 | #if ENABLE_POSIX_FILE_OPS |
| 5410 | if( rc ) |
| 5411 | { |
| 5412 | unlink( fname ); |
| 5413 | } |
| 5414 | #endif |
| 5415 | return rc; |
| 5416 | } |
| 5417 | |
| 5418 | void cson_session_file_finalize( cson_sessmgr * self ) |
| 5419 | { |
| @@ -5437,15 +5443,11 @@ | |
| 5437 | IMPL_DECL(cson_rc.ArgError); |
| 5438 | if( !id || !*id ) return cson_rc.ArgError; |
| 5439 | memset( fname, 0, BufSize ); |
| 5440 | rc = cson_session_file_name( impl, id, fname, BufSize ); |
| 5441 | if( 0 != rc ) return rc; |
| 5442 | #if ENABLE_POSIX_FILE_OPS |
| 5443 | rc = unlink( fname ); |
| 5444 | #else |
| 5445 | # error "unlink not implemented for this platform." |
| 5446 | #endif |
| 5447 | return (0==rc) ? 0 : cson_rc.IOError; |
| 5448 | } |
| 5449 | |
| 5450 | |
| 5451 | int cson_sessmgr_file( cson_sessmgr ** tgt, cson_object const * opt ) |
| @@ -5503,10 +5505,11 @@ | |
| 5503 | return rc; |
| 5504 | } |
| 5505 | |
| 5506 | #undef IMPL_DECL |
| 5507 | #undef ENABLE_POSIX_FILE_OPS |
| 5508 | /* end file ./cson_session_file.c */ |
| 5509 | /* begin file ./cson_sqlite3.c */ |
| 5510 | /** @file cson_sqlite3.c |
| 5511 | |
| 5512 | This file contains the implementation code for the cson |
| 5513 |
| --- src/cson_amalgamation.c | |
| +++ src/cson_amalgamation.c | |
| @@ -5265,11 +5265,11 @@ | |
| 5265 | names[i] = NULL; |
| 5266 | return names; |
| 5267 | } |
| 5268 | /* end file ./cson_session.c */ |
| 5269 | /* begin file ./cson_session_file.c */ |
| 5270 | #if !defined(_WIN32) && !defined(_WIN64) |
| 5271 | # if !defined(_POSIX_VERSION) |
| 5272 | # define _POSIX_VERSION 200112L /* chmod(), unlink() */ |
| 5273 | # endif |
| 5274 | # define ENABLE_POSIX_FILE_OPS 1 |
| 5275 | #else |
| @@ -5278,12 +5278,20 @@ | |
| 5278 | |
| 5279 | #include <stdlib.h> |
| 5280 | #include <string.h> |
| 5281 | #include <assert.h> |
| 5282 | #if ENABLE_POSIX_FILE_OPS |
| 5283 | # define UNLINK_FILE unlink |
| 5284 | # include <unistd.h> /* unlink() */ |
| 5285 | # include <sys/stat.h> /* chmod() */ |
| 5286 | #else |
| 5287 | /* http://msdn.microsoft.com/en-us/library/1c3tczd6(v=vs.80).aspx |
| 5288 | # define UNLINK_FILE _unlink |
| 5289 | # include <io.h> |
| 5290 | */ |
| 5291 | # define UNLINK_FILE remove |
| 5292 | # include <stdio.h> /* remove(), _unlink() */ |
| 5293 | #endif |
| 5294 | |
| 5295 | static int cson_session_file_load( cson_sessmgr * self, cson_value ** tgt, char const * id ); |
| 5296 | static int cson_session_file_save( cson_sessmgr * self, cson_value const * root, char const * id ); |
| 5297 | static int cson_session_file_remove( cson_sessmgr * self, char const * id ); |
| @@ -5404,16 +5412,14 @@ | |
| 5412 | #if ENABLE_POSIX_FILE_OPS |
| 5413 | chmod( fname, 0600 ); |
| 5414 | #endif |
| 5415 | rc = cson_output_FILE( root, fh, NULL ); |
| 5416 | fclose( fh ); |
| 5417 | if( rc ) |
| 5418 | { |
| 5419 | UNLINK_FILE( fname ); |
| 5420 | } |
| 5421 | return rc; |
| 5422 | } |
| 5423 | |
| 5424 | void cson_session_file_finalize( cson_sessmgr * self ) |
| 5425 | { |
| @@ -5437,15 +5443,11 @@ | |
| 5443 | IMPL_DECL(cson_rc.ArgError); |
| 5444 | if( !id || !*id ) return cson_rc.ArgError; |
| 5445 | memset( fname, 0, BufSize ); |
| 5446 | rc = cson_session_file_name( impl, id, fname, BufSize ); |
| 5447 | if( 0 != rc ) return rc; |
| 5448 | rc = UNLINK_FILE( fname ); |
| 5449 | return (0==rc) ? 0 : cson_rc.IOError; |
| 5450 | } |
| 5451 | |
| 5452 | |
| 5453 | int cson_sessmgr_file( cson_sessmgr ** tgt, cson_object const * opt ) |
| @@ -5503,10 +5505,11 @@ | |
| 5505 | return rc; |
| 5506 | } |
| 5507 | |
| 5508 | #undef IMPL_DECL |
| 5509 | #undef ENABLE_POSIX_FILE_OPS |
| 5510 | #undef UNLINK_FILE |
| 5511 | /* end file ./cson_session_file.c */ |
| 5512 | /* begin file ./cson_sqlite3.c */ |
| 5513 | /** @file cson_sqlite3.c |
| 5514 | |
| 5515 | This file contains the implementation code for the cson |
| 5516 |