Skip to content
Snippets Groups Projects
Commit 1b4667b3 authored by Ton Roosendaal's avatar Ton Roosendaal
Browse files

Errors in saving runtime, and fileops in file window; files were copied

or deleted without keeping track of spaces in names, causing in potential
loss of data.

Needs review!
parent 6719d88a
No related branches found
No related tags found
No related merge requests found
...@@ -222,12 +222,19 @@ int BLI_rename(char *from, char *to) { ...@@ -222,12 +222,19 @@ int BLI_rename(char *from, char *to) {
* */ * */
static char str[MAXPATHLEN+12]; static char str[MAXPATHLEN+12];
int BLI_delete(char *file, int dir, int recursive) { int BLI_delete(char *file, int dir, int recursive)
if (recursive) sprintf(str, "/bin/rm -rf %s", file); {
else if (dir) sprintf(str, "/bin/rmdir \"%s\"", file); if(strchr(file, '"')) {
else sprintf(str, "/bin/rm -f \"%s\"", file); printf("Error: not deleted file %s because of quote!\n", file);
}
else {
if (recursive) sprintf(str, "/bin/rm -rf \"%s\"", file);
else if (dir) sprintf(str, "/bin/rmdir \"%s\"", file);
else sprintf(str, "/bin/rm -f \"%s\"", file);
return system(str); return system(str);
}
return -1;
} }
int BLI_touch(char *file) int BLI_touch(char *file)
...@@ -242,19 +249,19 @@ int BLI_touch(char *file) ...@@ -242,19 +249,19 @@ int BLI_touch(char *file)
} }
int BLI_move(char *file, char *to) { int BLI_move(char *file, char *to) {
sprintf(str, "/bin/mv -f %s %s", file, to); sprintf(str, "/bin/mv -f \"%s\" \"%s\"", file, to);
return system(str); return system(str);
} }
int BLI_copy_fileops(char *file, char *to) { int BLI_copy_fileops(char *file, char *to) {
sprintf(str, "/bin/cp -rf \"%s\" %s", file, to); sprintf(str, "/bin/cp -rf \"%s\" \"%s\"", file, to);
return system(str); return system(str);
} }
int BLI_link(char *file, char *to) { int BLI_link(char *file, char *to) {
sprintf(str, "/bin/ln -f %s %s", file, to); sprintf(str, "/bin/ln -f \"%s\" \"%s\"", file, to);
return system(str); return system(str);
} }
......
...@@ -1667,7 +1667,8 @@ static char *get_runtime_path(char *exename) { ...@@ -1667,7 +1667,8 @@ static char *get_runtime_path(char *exename) {
#ifdef __APPLE__ #ifdef __APPLE__
static int recursive_copy_runtime(char *outname, char *exename, char **cause_r) { static int recursive_copy_runtime(char *outname, char *exename, char **cause_r)
{
char *cause = NULL, *runtime = get_runtime_path(exename); char *cause = NULL, *runtime = get_runtime_path(exename);
char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32]; char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
int progfd = -1; int progfd = -1;
...@@ -1676,14 +1677,16 @@ static int recursive_copy_runtime(char *outname, char *exename, char **cause_r) ...@@ -1676,14 +1677,16 @@ static int recursive_copy_runtime(char *outname, char *exename, char **cause_r)
cause= "Unable to find runtime"; cause= "Unable to find runtime";
goto cleanup; goto cleanup;
} }
//printf("runtimepath %s\n", runtime);
progfd= open(runtime, O_BINARY|O_RDONLY, 0); progfd= open(runtime, O_BINARY|O_RDONLY, 0);
if (progfd==-1) { if (progfd==-1) {
cause= "Unable to find runtime"; cause= "Unable to find runtime";
goto cleanup; goto cleanup;
} }
sprintf(command, "/bin/cp -R %s %s", runtime, outname); sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
//printf("command %s\n", command);
if (system(command) == -1) { if (system(command) == -1) {
cause = "Couldn't copy runtime"; cause = "Couldn't copy runtime";
} }
...@@ -1707,6 +1710,7 @@ void BLO_write_runtime(char *file, char *exename) { ...@@ -1707,6 +1710,7 @@ void BLO_write_runtime(char *file, char *exename) {
char *cause= NULL; char *cause= NULL;
// remove existing file / bundle // remove existing file / bundle
//printf("Delete file %s\n", file);
BLI_delete(file, NULL, TRUE); BLI_delete(file, NULL, TRUE);
if (!recursive_copy_runtime(file, exename, &cause)) if (!recursive_copy_runtime(file, exename, &cause))
...@@ -1714,7 +1718,7 @@ void BLO_write_runtime(char *file, char *exename) { ...@@ -1714,7 +1718,7 @@ void BLO_write_runtime(char *file, char *exename) {
strcpy(gamename, file); strcpy(gamename, file);
strcat(gamename, "/Contents/Resources/game.blend"); strcat(gamename, "/Contents/Resources/game.blend");
//printf("gamename %s\n", gamename);
outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777); outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
if (outfd != -1) { if (outfd != -1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment