summaryrefslogtreecommitdiffstats
path: root/lib/json/encodeFile.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/json/encodeFile.js')
-rw-r--r--lib/json/encodeFile.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/json/encodeFile.js b/lib/json/encodeFile.js
new file mode 100644
index 0000000..d2c9e8a
--- /dev/null
+++ b/lib/json/encodeFile.js
@@ -0,0 +1,21 @@
+
+/**
+ Return a JSON representation of a file
+
+ @param {File} file
+ @return {Object}
+*/
+function encodeFileToJson(file) {
+ var filePath = file.getPath();
+ if (!filePath) {
+ return undefined;
+ }
+
+ return {
+ path: filePath,
+ mtime: file.getMTime(),
+ type: file.getType()
+ };
+}
+
+module.exports = encodeFileToJson;