aboutsummaryrefslogtreecommitdiff
path: root/generator/util.js
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-02-12 23:51:08 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-02-12 23:51:08 +0800
commit42b38863761f8258781406469505f0ac1c27ac54 (patch)
treea493976206cd043041e89688d5bbd31ced1ad565 /generator/util.js
parentedd8aa6e058d12dd0f9b0b886e507bd73dce72cb (diff)
downloadsbs-42b38863761f8258781406469505f0ac1c27ac54.tar.xz
New feature: thumbnail generation!
Diffstat (limited to 'generator/util.js')
-rw-r--r--generator/util.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/generator/util.js b/generator/util.js
new file mode 100644
index 0000000..e9b5c78
--- /dev/null
+++ b/generator/util.js
@@ -0,0 +1,19 @@
+//Copyright Chris Xiong 2019
+//License: Expat (MIT)
+module.exports={
+ mtime_cmp:function(a,b){return _mtime_cmp(a,b);}
+};
+const fs=require('fs');
+
+/*Returns true when file b exists and has a mtime no earlier than file a,
+ *false otherwise.
+ */
+function _mtime_cmp(a,b)
+{
+ const mtimea=fs.statSync(a).mtimeMs;
+ let mtimeb=0;
+ try{
+ mtimeb=fs.statSync(b).mtimeMs;
+ }catch(e){return false};
+ return mtimeb>=mtimea;
+}