diff options
author | Ian Thompson <quornian@googlemail.com> | 2008-06-26 22:28:33 +0400 |
---|---|---|
committer | Ian Thompson <quornian@googlemail.com> | 2008-06-26 22:28:33 +0400 |
commit | aee5e9561069628cc81bd230339043bee37a43e3 (patch) | |
tree | e0e3c87391469e962b3d9ffb8a8c20dc7a24a985 /source/blender/blenkernel/intern/text.c | |
parent | fc392040dd035dc03899896cc56d337a8e97e78f (diff) |
Modifying a file externally or deleting a file linked with a Blender Text object presents options for reloading, saving or separating the Text object from the external file (like the make local idea).
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index fbb94289166..f414498c1b9 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -30,6 +30,8 @@ */ #include <string.h> /* strstr */ +#include <sys/types.h> +#include <sys/stat.h> #include "MEM_guardedalloc.h" @@ -210,11 +212,12 @@ static void cleanup_textline(TextLine * tl) int reopen_text(Text *text) { FILE *fp; - int i, llen, len; + int i, llen, len, res; unsigned char *buffer; TextLine *tmp; char sfile[FILE_MAXFILE]; char str[FILE_MAXDIR+FILE_MAXFILE]; + struct stat fst; if (!text || !text->name) return 0; @@ -250,6 +253,9 @@ int reopen_text(Text *text) fseek(fp, 0L, SEEK_SET); text->undo_pos= -1; + + res= fstat(fp->_file, &fst); + text->mtime= fst.st_mtime; buffer= MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because @@ -308,12 +314,13 @@ int reopen_text(Text *text) Text *add_text(char *file) { FILE *fp; - int i, llen, len; + int i, llen, len, res; unsigned char *buffer; TextLine *tmp; Text *ta; char sfile[FILE_MAXFILE]; char str[FILE_MAXDIR+FILE_MAXFILE]; + struct stat fst; BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE); if (G.scene) /* can be NULL (bg mode) */ @@ -339,6 +346,9 @@ Text *add_text(char *file) ta->name= MEM_mallocN(strlen(file)+1, "text_name"); strcpy(ta->name, file); + res= fstat(fp->_file, &fst); + ta->mtime= fst.st_mtime; + ta->undo_pos= -1; ta->undo_len= TXT_INIT_UNDO; ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf"); |