Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-27 18:55:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-27 18:55:10 +0400
commit0c6a01ca0072d8444309ec094bdc87d10695fc0d (patch)
tree5b2940ba9ed9d99cbd8d74c744803852408fda2c /source/blender/blenkernel/intern/text.c
parent5aa006bc1c9b99bcbc1a5190d34a70fcaaa0d2da (diff)
Use includes for blenderplayer stubs
exposes many incorrect and redundant stubs
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r--source/blender/blenkernel/intern/text.c56
1 files changed, 56 insertions, 0 deletions
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 */
/*****************************/