[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13314] trunk/blender/source/blender/ blenlib: touch function that should also work on non unix os's, though I cant test here.
Campbell Barton
ideasman42 at gmail.com
Sun Jan 20 22:27:16 CET 2008
Revision: 13314
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13314
Author: campbellbarton
Date: 2008-01-20 22:27:16 +0100 (Sun, 20 Jan 2008)
Log Message:
-----------
touch function that should also work on non unix os's, though I cant test here.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_blenlib.h
trunk/blender/source/blender/blenlib/intern/fileops.c
Modified: trunk/blender/source/blender/blenlib/BLI_blenlib.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_blenlib.h 2008-01-20 21:10:55 UTC (rev 13313)
+++ trunk/blender/source/blender/blenlib/BLI_blenlib.h 2008-01-20 21:27:16 UTC (rev 13314)
@@ -296,7 +296,7 @@
int BLI_gzip(char *from, char *to);
int BLI_delete(char *file, int dir, int recursive);
int BLI_move(char *file, char *to);
-int BLI_touch(char *file);
+int BLI_touch(const char *file);
char *BLI_last_slash(const char *string);
/* BLI_rct.c */
Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c 2008-01-20 21:10:55 UTC (rev 13313)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c 2008-01-20 21:27:16 UTC (rev 13314)
@@ -140,6 +140,23 @@
}
}
+int BLI_touch(const char *file)
+{
+ FILE *f = fopen(file,"r+b");
+ if (f != NULL) {
+ char c = getc(f);
+ rewind(f);
+ putc(c,f);
+ } else {
+ f = fopen(file,"wb");
+ }
+ if (f) {
+ fclose(f);
+ return 1;
+ }
+ return 0;
+}
+
#ifdef WIN32
static char str[MAXPATHLEN+12];
@@ -161,12 +178,6 @@
return err;
}
-int BLI_touch(char *file) {
- callLocalErrorCallBack("Touching files is unsupported on Windows");
-
- return 1;
-}
-
int BLI_move(char *file, char *to) {
int err;
@@ -296,17 +307,6 @@
return -1;
}
-int BLI_touch(char *file)
-{
-
- if( BLI_exists("/bin/touch") )
- sprintf(str, "/bin/touch %s", file);
- else
- sprintf(str, "/usr/bin/touch %s", file);
-
- return system(str);
-}
-
int BLI_move(char *file, char *to) {
sprintf(str, "/bin/mv -f \"%s\" \"%s\"", file, to);
More information about the Bf-blender-cvs
mailing list