diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-27 18:55:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-27 18:55:10 +0400 |
commit | 0c6a01ca0072d8444309ec094bdc87d10695fc0d (patch) | |
tree | 5b2940ba9ed9d99cbd8d74c744803852408fda2c /source/blender/blenkernel | |
parent | 5aa006bc1c9b99bcbc1a5190d34a70fcaaa0d2da (diff) |
Use includes for blenderplayer stubs
exposes many incorrect and redundant stubs
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_text.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 56 |
2 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 67c1b6834dd..eb89216d360 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -55,6 +55,8 @@ struct Text *BKE_text_copy (struct Text *ta); void BKE_text_unlink (struct Main *bmain, struct Text *text); void BKE_text_clear (struct Text *text); void BKE_text_write (struct Text *text, const char *str); +int BKE_text_file_modified_check(struct Text *text); +void BKE_text_file_modified_ignore(struct Text *text); char *txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index efe3e98b2b3..145f832063a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -659,6 +659,62 @@ void BKE_text_write(Text *text, const char *str) /* called directly from rna */ txt_make_dirty(text); } + +/* returns 0 if file on disk is the same or Text is in memory only + * returns 1 if file has been modified on disk since last local edit + * returns 2 if file on disk has been deleted + * -1 is returned if an error occurs */ + +int BKE_text_file_modified_check(Text *text) +{ + struct stat st; + int result; + char file[FILE_MAX]; + + if (!text || !text->name) + return 0; + + BLI_strncpy(file, text->name, FILE_MAX); + BLI_path_abs(file, G.main->name); + + if (!BLI_exists(file)) + return 2; + + result = BLI_stat(file, &st); + + if (result == -1) + return -1; + + if ((st.st_mode & S_IFMT) != S_IFREG) + return -1; + + if (st.st_mtime > text->mtime) + return 1; + + return 0; +} + +void BKE_text_file_modified_ignore(Text *text) +{ + struct stat st; + int result; + char file[FILE_MAX]; + + if (!text || !text->name) return; + + BLI_strncpy(file, text->name, FILE_MAX); + BLI_path_abs(file, G.main->name); + + if (!BLI_exists(file)) return; + + result = BLI_stat(file, &st); + + if (result == -1 || (st.st_mode & S_IFMT) != S_IFREG) + return; + + text->mtime = st.st_mtime; +} + /*****************************/ /* Editing utility functions */ /*****************************/ |