touch function that should also work on non unix os's, though I cant test here.
This commit is contained in:
@@ -296,7 +296,7 @@ int BLI_rename(char *from, char *to);
|
||||
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 */
|
||||
|
||||
@@ -140,6 +140,23 @@ int BLI_is_writable(char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ int BLI_delete(char *file, int dir, int recursive) {
|
||||
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 @@ int BLI_delete(char *file, int dir, int recursive)
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user