diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-07-27 10:55:20 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-07-27 10:55:20 +0400 |
commit | 48a64ffa702b0b7599aa8d8071d4a2265e9ba122 (patch) | |
tree | 38021e87e4ead192c8f4d2c1cfdf1d81c97bfcc5 /source/blender/editors/space_text | |
parent | 955ba3f7fb5bca6d454ee6a1158cbdc094d6d060 (diff) |
more minor warning cleanups and improve error reporting if text fails to save.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 2bd6bd624df..13eb24ed1f2 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -36,6 +36,7 @@ #include <string.h> #include <ctype.h> /* ispunct */ #include <sys/stat.h> +#include <errno.h> #include "MEM_guardedalloc.h" @@ -449,15 +450,14 @@ static void txt_write_file(Text *text, ReportList *reports) FILE *fp; TextLine *tmp; struct stat st; - int res; - char file[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAXDIR+FILE_MAXFILE]; - BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_path_abs(file, G.main->name); + BLI_strncpy(filepath, text->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_path_abs(filepath, G.main->name); - fp= fopen(file, "w"); + fp= fopen(filepath, "w"); if(fp==NULL) { - BKE_report(reports, RPT_ERROR, "Unable to save file."); + BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error writing file"); return; } @@ -471,8 +471,13 @@ static void txt_write_file(Text *text, ReportList *reports) fclose (fp); - res= stat(file, &st); - text->mtime= st.st_mtime; + if(stat(filepath, &st) == 0) { + text->mtime= st.st_mtime; + } + else { + text->mtime= 0; + BKE_reportf(reports, RPT_WARNING, "Unable to stat \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error starrng file"); + } if(text->flags & TXT_ISDIRTY) text->flags ^= TXT_ISDIRTY; |