Fossil SCM

s/unlink/remove/ for Windows build (thanks again to Robert Engelhardt).

stephan 2011-09-16 13:34 UTC json
Commit ea8d28acf3b33fb8cfa09170e54bcc1f36e6c403
1 file changed +12 -9
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5265,11 +5265,11 @@
52655265
names[i] = NULL;
52665266
return names;
52675267
}
52685268
/* end file ./cson_session.c */
52695269
/* begin file ./cson_session_file.c */
5270
-#if !defined(_WIN32)
5270
+#if !defined(_WIN32) && !defined(_WIN64)
52715271
# if !defined(_POSIX_VERSION)
52725272
# define _POSIX_VERSION 200112L /* chmod(), unlink() */
52735273
# endif
52745274
# define ENABLE_POSIX_FILE_OPS 1
52755275
#else
@@ -5278,12 +5278,20 @@
52785278
52795279
#include <stdlib.h>
52805280
#include <string.h>
52815281
#include <assert.h>
52825282
#if ENABLE_POSIX_FILE_OPS
5283
+# define UNLINK_FILE unlink
52835284
# include <unistd.h> /* unlink() */
52845285
# 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() */
52855293
#endif
52865294
52875295
static int cson_session_file_load( cson_sessmgr * self, cson_value ** tgt, char const * id );
52885296
static int cson_session_file_save( cson_sessmgr * self, cson_value const * root, char const * id );
52895297
static int cson_session_file_remove( cson_sessmgr * self, char const * id );
@@ -5404,16 +5412,14 @@
54045412
#if ENABLE_POSIX_FILE_OPS
54055413
chmod( fname, 0600 );
54065414
#endif
54075415
rc = cson_output_FILE( root, fh, NULL );
54085416
fclose( fh );
5409
-#if ENABLE_POSIX_FILE_OPS
54105417
if( rc )
54115418
{
5412
- unlink( fname );
5419
+ UNLINK_FILE( fname );
54135420
}
5414
-#endif
54155421
return rc;
54165422
}
54175423
54185424
void cson_session_file_finalize( cson_sessmgr * self )
54195425
{
@@ -5437,15 +5443,11 @@
54375443
IMPL_DECL(cson_rc.ArgError);
54385444
if( !id || !*id ) return cson_rc.ArgError;
54395445
memset( fname, 0, BufSize );
54405446
rc = cson_session_file_name( impl, id, fname, BufSize );
54415447
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 );
54475449
return (0==rc) ? 0 : cson_rc.IOError;
54485450
}
54495451
54505452
54515453
int cson_sessmgr_file( cson_sessmgr ** tgt, cson_object const * opt )
@@ -5503,10 +5505,11 @@
55035505
return rc;
55045506
}
55055507
55065508
#undef IMPL_DECL
55075509
#undef ENABLE_POSIX_FILE_OPS
5510
+#undef UNLINK_FILE
55085511
/* end file ./cson_session_file.c */
55095512
/* begin file ./cson_sqlite3.c */
55105513
/** @file cson_sqlite3.c
55115514
55125515
This file contains the implementation code for the cson
55135516
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button