TagSpaces is an offline, open source, document manager with tagging support
Android app should show all kind of files not only images (#1365)
Stanimir1e2d7f9fad92
diff --git a/cordova/config.xml b/cordova/config.xmlindex ec3c1c7a4..8ce2978b5 100644--- a/cordova/config.xml+++ b/cordova/config.xml@@ -77,8 +77,8 @@<preference name="AndroidPersistentFileLocation" value="Compatibility" /><preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" /><preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" />- <plugin name="cordova-plugin-device" spec="^2.0.2" />- <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />+ <plugin name="cordova-plugin-device" spec="^2.0.3" />+ <plugin name="cordova-plugin-whitelist" spec="^1.3.4" /><plugin name="cordova-plugin-background-mode" spec="^0.7.3" /><plugin name="cordova-plugin-file" spec="6.0.2" /></widget>diff --git a/cordova/package-lock.json b/cordova/package-lock.jsonindex f4f9e24e9..84e627064 100644--- a/cordova/package-lock.json+++ b/cordova/package-lock.json@@ -16,9 +16,9 @@"integrity": "sha512-b+MGNyP9/LXkapreJzNUzcvuzZslj/RGgdVVJ16P2wSlYatfLycPObImqVJSmNAdyeShvNeM/pl3sVZsObFueg==","dev": true,"requires": {- "assert-plus": "1.0.0",- "extsprintf": "1.4.0",- "lodash": "4.17.21"+ "assert-plus": "^1.0.0",+ "extsprintf": "^1.4.0",+ "lodash": "^4.17.15"}},"@nodelib/fs.scandir": {@@ -28,7 +28,7 @@"dev": true,"requires": {"@nodelib/fs.stat": "2.0.4",- "run-parallel": "1.2.0"+ "run-parallel": "^1.1.9"}},"@nodelib/fs.stat": {@@ -44,7 +44,7 @@"dev": true,"requires": {"@nodelib/fs.scandir": "2.1.4",- "fastq": "1.11.0"+ "fastq": "^1.6.0"}},"abbrev": {@@ -59,7 +59,7 @@"integrity": "sha512-ojC2Ig7b/KJ6iNtR8e4bacmOsJyEkoERk3CKMIsnH7kJz5z6551NMbrVaRb7KXYavu1d74Uhml/bfcmqT3nAcg==","dev": true,"requires": {- "semver": "5.7.1"+ "semver": "^5.7.1"}},"ansi": {@@ -87,6 +87,7 @@},"bamboo.cordova.plugin.downloader": {"version": "git+https://github.com/sytolk/cordova-plugin-downloader.git#9ab2c3ad6c0faf9aefcc32a7870593daab5c69db",+ "from": "git+https://github.com/sytolk/cordova-plugin-downloader.git","dev": true},"base64-js": {@@ -104,7 +105,7 @@"resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.8.tgz","integrity": "sha512-Za9JKzD6fjLC16oX2wsXfc+qBEhJBJB1YPInoAQpMLhDuj5aVOv1baGeIQSq1Fr3OCqzvsoQcSBSwGId/Ja2PA==","requires": {- "stream-buffers": "2.2.0"+ "stream-buffers": "~2.2.0"}},"bplist-parser": {@@ -112,7 +113,7 @@"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz","integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==","requires": {- "big-integer": "1.6.48"+ "big-integer": "^1.6.44"}},"brace-expansion": {@@ -120,7 +121,7 @@"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz","integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==","requires": {- "balanced-match": "1.0.0",+ "balanced-match": "^1.0.0","concat-map": "0.0.1"}},@@ -130,7 +131,7 @@"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==","dev": true,"requires": {- "fill-range": "7.0.1"+ "fill-range": "^7.0.1"}},"com-darryncampbell-cordova-plugin-intent": {@@ -150,13 +151,13 @@"integrity": "sha512-2ZEgApK4LPMYW0zh/mLAH3CabzCaKE0yxQTzA2wTf0Eo2HHTJnRtDCf9spGf3nPOkubyXS6+pvzz5QzNHpVTqQ==","dev": true,"requires": {- "android-versions": "1.6.0",- "cordova-common": "4.0.2",- "execa": "4.1.0",- "fs-extra": "9.1.0",- "nopt": "4.0.3",- "properties-parser": "0.3.1",- "which": "2.0.2"+ "android-versions": "^1.5.0",+ "cordova-common": "^4.0.1",+ "execa": "^4.0.2",+ "fs-extra": "^9.0.1",+ "nopt": "^4.0.3",+ "properties-parser": "^0.3.1",+ "which": "^2.0.2"}},"cordova-common": {@@ -165,20 +166,20 @@"integrity": "sha512-od7aNShyuBajzPY83mUEO8tERwwWdFklXETHiXP5Ft87CWeo/tSuwNPFztyTy8XYc74yXdogXKPTJeUHuVzB8Q==","dev": true,"requires": {- "@netflix/nerror": "1.1.3",- "ansi": "0.3.1",- "bplist-parser": "0.2.0",- "cross-spawn": "7.0.3",- "elementtree": "0.1.7",- "endent": "1.4.1",- "fast-glob": "3.2.5",- "fs-extra": "9.1.0",- "glob": "7.1.6",- "plist": "3.0.1",- "q": "1.5.1",- "read-chunk": "3.2.0",- "strip-bom": "4.0.0",- "underscore": "1.12.0"+ "@netflix/nerror": "^1.1.3",+ "ansi": "^0.3.1",+ "bplist-parser": "^0.2.0",+ "cross-spawn": "^7.0.1",+ "elementtree": "^0.1.7",+ "endent": "^1.4.1",+ "fast-glob": "^3.2.2",+ "fs-extra": "^9.0.0",+ "glob": "^7.1.6",+ "plist": "^3.0.1",+ "q": "^1.5.1",+ "read-chunk": "^3.2.0",+ "strip-bom": "^4.0.0",+ "underscore": "^1.9.2"}},"cordova-ios": {@@ -187,16 +188,16 @@"integrity": "sha512-sLjZg2QBI1SpQVwfe0MSn89YNVkBGLW9Q1vcFJBsqKBrhvoEOJ5Ytq0gwqdhgTOGzlwJUfxC6OHM3jcsRjtYrw==","dev": true,"requires": {- "cordova-common": "4.0.2",- "fs-extra": "9.1.0",- "ios-sim": "8.0.2",- "nopt": "5.0.0",- "plist": "3.0.1",- "semver": "7.3.4",- "unorm": "1.6.0",- "which": "2.0.2",- "xcode": "3.0.1",- "xml-escape": "1.1.0"+ "cordova-common": "^4.0.2",+ "fs-extra": "^9.1.0",+ "ios-sim": "^8.0.2",+ "nopt": "^5.0.0",+ "plist": "^3.0.1",+ "semver": "^7.3.4",+ "unorm": "^1.6.0",+ "which": "^2.0.2",+ "xcode": "^3.0.1",+ "xml-escape": "^1.1.0"},"dependencies": {"nopt": {@@ -205,7 +206,7 @@"integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==","dev": true,"requires": {- "abbrev": "1.1.1"+ "abbrev": "1"}},"semver": {@@ -214,13 +215,14 @@"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==","dev": true,"requires": {- "lru-cache": "6.0.0"+ "lru-cache": "^6.0.0"}}}},"cordova-ourcodeworld-filebrowser": {"version": "git+https://github.com/muhammed-noufal/cordova-ourcodeworld-filebrowser.git#07b8d2298a53691913101da5f704cb11159aed70",+ "from": "git+https://github.com/muhammed-noufal/cordova-ourcodeworld-filebrowser.git","dev": true},"cordova-plugin-add-swift-support": {@@ -228,9 +230,9 @@"resolved": "https://registry.npmjs.org/cordova-plugin-add-swift-support/-/cordova-plugin-add-swift-support-2.0.2.tgz","integrity": "sha512-K03WDnsD3GT+n7Od3BnS17D8rYnAFZbZjjQJa2r7qW8QLq8+h7hGbFaiF+w5+nUtyAqUNq+HT/d/MdqBGLNzxA==","requires": {- "glob": "7.1.6",- "semver": "6.3.0",- "xcode": "2.1.0"+ "glob": "^7.1.3",+ "semver": "^6.0.0",+ "xcode": "^2.0.0"},"dependencies": {"semver": {@@ -248,8 +250,8 @@"resolved": "https://registry.npmjs.org/xcode/-/xcode-2.1.0.tgz","integrity": "sha512-uCrmPITrqTEzhn0TtT57fJaNaw8YJs1aCzs+P/QqxsDbvPZSv7XMPPwXrKvHtD6pLjBM/NaVwraWJm8q83Y4iQ==","requires": {- "simple-plist": "1.1.1",- "uuid": "3.4.0"+ "simple-plist": "^1.0.0",+ "uuid": "^3.3.2"}}}@@ -266,8 +268,8 @@"integrity": "sha512-W1SImn0cCCvOSTSfWWp5TnanIQrSuh2Bch+dcZXIzEn0km3Qb7VryeAqHhgBQYwwzC5Ollk1DtUAk/AJSojuZA==","dev": true,"requires": {- "q": "1.5.1",- "recursive-readdir": "2.2.2"+ "q": "^1.5.1",+ "recursive-readdir": "^2.2.2"}},"cordova-plugin-background-mode": {@@ -287,9 +289,9 @@"integrity": "sha512-Jb3V72btxf3XHpkPQsGdyc8N6tVBYn1vsxSFj43fIz9vonJDUThYPCJJHqk6PX6N4dJw6I4FjxkpfCR4LDYMlw=="},"cordova-plugin-file": {- "version": "6.0.2",- "resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.2.tgz",- "integrity": "sha512-m7cughw327CjONN/qjzsTpSesLaeybksQh420/gRuSXJX5Zt9NfgsSbqqKDon6jnQ9Mm7h7imgyO2uJ34XMBtA=="+ "version": "git+https://github.com/apache/cordova-plugin-file.git#5274cab39e3f96a8682a74ba28663f32611501c8",+ "from": "git+https://github.com/apache/cordova-plugin-file.git",+ "dev": true},"cordova-plugin-file-opener2": {"version": "3.0.5",@@ -313,9 +315,9 @@"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==","dev": true,"requires": {- "path-key": "3.1.1",- "shebang-command": "2.0.0",- "which": "2.0.2"+ "path-key": "^3.1.0",+ "shebang-command": "^2.0.0",+ "which": "^2.0.1"}},"dedent": {@@ -339,7 +341,7 @@"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==","dev": true,"requires": {- "once": "1.4.0"+ "once": "^1.4.0"}},"endent": {@@ -348,9 +350,9 @@"integrity": "sha512-buHTb5c8AC9NshtP6dgmNLYkiT+olskbq1z6cEGvfGCF3Qphbu/1zz5Xu+yjTDln8RbxNhPoUyJ5H8MSrp1olQ==","dev": true,"requires": {- "dedent": "0.7.0",- "fast-json-parse": "1.0.3",- "objectorarray": "1.0.4"+ "dedent": "^0.7.0",+ "fast-json-parse": "^1.0.3",+ "objectorarray": "^1.0.4"}},"es6-promise-plugin": {@@ -364,15 +366,15 @@"integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==","dev": true,"requires": {- "cross-spawn": "7.0.3",- "get-stream": "5.2.0",- "human-signals": "1.1.1",- "is-stream": "2.0.0",- "merge-stream": "2.0.0",- "npm-run-path": "4.0.1",- "onetime": "5.1.2",- "signal-exit": "3.0.3",- "strip-final-newline": "2.0.0"+ "cross-spawn": "^7.0.0",+ "get-stream": "^5.0.0",+ "human-signals": "^1.1.1",+ "is-stream": "^2.0.0",+ "merge-stream": "^2.0.0",+ "npm-run-path": "^4.0.0",+ "onetime": "^5.1.0",+ "signal-exit": "^3.0.2",+ "strip-final-newline": "^2.0.0"}},"extsprintf": {@@ -387,12 +389,12 @@"integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==","dev": true,"requires": {- "@nodelib/fs.stat": "2.0.4",- "@nodelib/fs.walk": "1.2.6",- "glob-parent": "5.1.2",- "merge2": "1.4.1",- "micromatch": "4.0.2",- "picomatch": "2.2.2"+ "@nodelib/fs.stat": "^2.0.2",+ "@nodelib/fs.walk": "^1.2.3",+ "glob-parent": "^5.1.0",+ "merge2": "^1.3.0",+ "micromatch": "^4.0.2",+ "picomatch": "^2.2.1"}},"fast-json-parse": {@@ -407,7 +409,7 @@"integrity": "sha512-7Eczs8gIPDrVzT+EksYBcupqMyxSHXXrHOLRRxU2/DicV8789MRBRR8+Hc2uWzUupOs4YS4JzBmBxjjCVBxD/g==","dev": true,"requires": {- "reusify": "1.0.4"+ "reusify": "^1.0.4"}},"fill-range": {@@ -416,7 +418,7 @@"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==","dev": true,"requires": {- "to-regex-range": "5.0.1"+ "to-regex-range": "^5.0.1"}},"fs-extra": {@@ -425,10 +427,10 @@"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==","dev": true,"requires": {- "at-least-node": "1.0.0",- "graceful-fs": "4.2.6",- "jsonfile": "6.1.0",- "universalify": "2.0.0"+ "at-least-node": "^1.0.0",+ "graceful-fs": "^4.2.0",+ "jsonfile": "^6.0.1",+ "universalify": "^2.0.0"}},"fs.realpath": {@@ -442,7 +444,7 @@"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==","dev": true,"requires": {- "pump": "3.0.0"+ "pump": "^3.0.0"}},"glob": {@@ -450,12 +452,12 @@"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz","integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==","requires": {- "fs.realpath": "1.0.0",- "inflight": "1.0.6",- "inherits": "2.0.4",- "minimatch": "3.0.4",- "once": "1.4.0",- "path-is-absolute": "1.0.1"+ "fs.realpath": "^1.0.0",+ "inflight": "^1.0.4",+ "inherits": "2",+ "minimatch": "^3.0.4",+ "once": "^1.3.0",+ "path-is-absolute": "^1.0.0"}},"glob-parent": {@@ -464,7 +466,7 @@"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==","dev": true,"requires": {- "is-glob": "4.0.1"+ "is-glob": "^4.0.1"}},"graceful-fs": {@@ -484,8 +486,8 @@"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz","integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=","requires": {- "once": "1.4.0",- "wrappy": "1.0.2"+ "once": "^1.3.0",+ "wrappy": "1"}},"inherits": {@@ -499,10 +501,10 @@"integrity": "sha512-P7nEG771bfd+JoMRjnis1gpZOkjTUUxu+4Ek1Z+eoaEEoT9byllU9pxfQ8Df7hL3gSkIQxNwTSLhos2I8tWUQA==","dev": true,"requires": {- "bplist-parser": "0.0.6",+ "bplist-parser": "^0.0.6","nopt": "1.0.9",- "plist": "3.0.1",- "simctl": "2.0.0"+ "plist": "^3.0.1",+ "simctl": "^2"},"dependencies": {"bplist-parser": {@@ -517,7 +519,7 @@"integrity": "sha1-O8DXy6e/sNWmdtvtfA6+SKT9RU4=","dev": true,"requires": {- "abbrev": "1.1.1"+ "abbrev": "1"}}}@@ -534,7 +536,7 @@"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==","dev": true,"requires": {- "is-extglob": "2.1.1"+ "is-extglob": "^2.1.1"}},"is-number": {@@ -561,8 +563,8 @@"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==","dev": true,"requires": {- "graceful-fs": "4.2.6",- "universalify": "2.0.0"+ "graceful-fs": "^4.1.6",+ "universalify": "^2.0.0"}},"lodash": {@@ -577,7 +579,7 @@"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==","dev": true,"requires": {- "yallist": "4.0.0"+ "yallist": "^4.0.0"}},"merge-stream": {@@ -598,8 +600,8 @@"integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==","dev": true,"requires": {- "braces": "3.0.2",- "picomatch": "2.2.2"+ "braces": "^3.0.1",+ "picomatch": "^2.0.5"}},"mimic-fn": {@@ -613,7 +615,7 @@"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz","integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==","requires": {- "brace-expansion": "1.1.11"+ "brace-expansion": "^1.1.7"}},"nopt": {@@ -622,8 +624,8 @@"integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==","dev": true,"requires": {- "abbrev": "1.1.1",- "osenv": "0.1.5"+ "abbrev": "1",+ "osenv": "^0.1.4"}},"npm-run-path": {@@ -632,7 +634,7 @@"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==","dev": true,"requires": {- "path-key": "3.1.1"+ "path-key": "^3.0.0"}},"objectorarray": {@@ -646,7 +648,7 @@"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz","integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=","requires": {- "wrappy": "1.0.2"+ "wrappy": "1"}},"onetime": {@@ -655,7 +657,7 @@"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==","dev": true,"requires": {- "mimic-fn": "2.1.0"+ "mimic-fn": "^2.1.0"}},"os-homedir": {@@ -676,8 +678,8 @@"integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==","dev": true,"requires": {- "os-homedir": "1.0.2",- "os-tmpdir": "1.0.2"+ "os-homedir": "^1.0.0",+ "os-tmpdir": "^1.0.0"}},"p-finally": {@@ -720,9 +722,9 @@"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.1.tgz","integrity": "sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ==","requires": {- "base64-js": "1.5.1",- "xmlbuilder": "9.0.7",- "xmldom": "0.1.31"+ "base64-js": "^1.2.3",+ "xmlbuilder": "^9.0.7",+ "xmldom": "0.1.x"}},"properties-parser": {@@ -731,7 +733,7 @@"integrity": "sha1-ExbpU5/7/ZOEXjabIRAiq9R4dxo=","dev": true,"requires": {- "string.prototype.codepointat": "0.2.1"+ "string.prototype.codepointat": "^0.2.0"}},"pump": {@@ -740,8 +742,8 @@"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==","dev": true,"requires": {- "end-of-stream": "1.4.4",- "once": "1.4.0"+ "end-of-stream": "^1.1.0",+ "once": "^1.3.1"}},"q": {@@ -762,8 +764,8 @@"integrity": "sha512-CEjy9LCzhmD7nUpJ1oVOE6s/hBkejlcJEgLQHVnQznOSilOPb+kpKktlLfFDK3/WP43+F80xkUTM2VOkYoSYvQ==","dev": true,"requires": {- "pify": "4.0.1",- "with-open-file": "0.1.7"+ "pify": "^4.0.1",+ "with-open-file": "^0.1.6"}},"recursive-readdir": {@@ -787,7 +789,7 @@"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==","dev": true,"requires": {- "queue-microtask": "1.2.2"+ "queue-microtask": "^1.2.2"}},"sax": {@@ -808,7 +810,7 @@"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==","dev": true,"requires": {- "shebang-regex": "3.0.0"+ "shebang-regex": "^3.0.0"}},"shebang-regex": {@@ -835,8 +837,8 @@"integrity": "sha512-5rB7rN4N3b0z0nFdy9eczVssXqrv2aAgdVRksPVqVoiDtvXmfzNvebp3EMdId2sAUzXIflarQlx4P0hjVQEzKQ==","dev": true,"requires": {- "shelljs": "0.2.6",- "tail": "0.4.0"+ "shelljs": "^0.2.6",+ "tail": "^0.4.0"}},"simple-plist": {@@ -846,7 +848,7 @@"requires": {"bplist-creator": "0.0.8","bplist-parser": "0.2.0",- "plist": "3.0.1"+ "plist": "^3.0.1"}},"stream-buffers": {@@ -884,7 +886,7 @@"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==","dev": true,"requires": {- "is-number": "7.0.0"+ "is-number": "^7.0.0"}},"underscore": {@@ -917,7 +919,7 @@"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==","dev": true,"requires": {- "isexe": "2.0.0"+ "isexe": "^2.0.0"}},"with-open-file": {@@ -926,9 +928,9 @@"integrity": "sha512-ecJS2/oHtESJ1t3ZfMI3B7KIDKyfN0O16miWxdn30zdh66Yd3LsRFebXZXq6GU4xfxLf6nVxp9kIqElb5fqczA==","dev": true,"requires": {- "p-finally": "1.0.0",- "p-try": "2.2.0",- "pify": "4.0.1"+ "p-finally": "^1.0.0",+ "p-try": "^2.1.0",+ "pify": "^4.0.1"}},"wrappy": {@@ -942,8 +944,8 @@"integrity": "sha512-kCz5k7J7XbJtjABOvkc5lJmkiDh8VhjVCGNiqdKCscmVpdVUpEAyXv1xmCLkQJ5dsHqx3IPO4XW+NTDhU/fatA==","dev": true,"requires": {- "simple-plist": "1.1.1",- "uuid": "7.0.3"+ "simple-plist": "^1.1.0",+ "uuid": "^7.0.3"}},"xml-escape": {diff --git a/cordova/package.json b/cordova/package.jsonindex 1c9b4f7f9..6b517c21c 100644--- a/cordova/package.json+++ b/cordova/package.json@@ -13,7 +13,6 @@"cordova-plugin-add-swift-support": "2.0.2","cordova-plugin-background-mode": "^0.7.3","cordova-plugin-device": "^2.0.3",- "cordova-plugin-file": "6.0.2","cordova-plugin-file-opener2": "^3.0.5","cordova-plugin-whitelist": "^1.3.4","es6-promise-plugin": "^4.2.2"@@ -42,8 +41,8 @@"cordova-plugin-androidx": {}},"platforms": [- "android",- "ios"+ "ios",+ "android"]},"devDependencies": {@@ -56,6 +55,7 @@"cordova-plugin-androidx": "^3.0.0","cordova-plugin-androidx-adapter": "^1.1.3","cordova-plugin-camera": "^5.0.1",+ "cordova-plugin-file": "git+https://github.com/apache/cordova-plugin-file.git","cordova-plugin-x-socialsharing": "^6.0.3"}}diff --git a/cordova/platforms/android/android.json b/cordova/platforms/android/android.jsonindex 25fe4f4d0..f0a84424d 100644--- a/cordova/platforms/android/android.json+++ b/cordova/platforms/android/android.json@@ -10,11 +10,11 @@"/manifest/application/activity": [{"xml": "<intent-filter><action android:name=\"android.intent.action.VIEW\" /><category android:name=\"android.intent.category.DEFAULT\" /><category android:name=\"android.intent.category.BROWSABLE\" /><data android:mimeType=\"application/pdf\" android:scheme=\"file\" /><data android:mimeType=\"text/plain\" android:scheme=\"file\" /><data android:mimeType=\"image/x-windows-bmp\" android:scheme=\"file\" /><data android:mimeType=\"image/gif\" android:scheme=\"file\" /><data android:mimeType=\"image/png\" android:scheme=\"file\" /><data android:mimeType=\"image/jpeg\" android:scheme=\"file\" /><data android:mimeType=\"image/webp\" android:scheme=\"file\" /><data android:mimeType=\"video/webm\" android:scheme=\"file\" /><data android:mimeType=\"video/ogg\" android:scheme=\"file\" /><data android:mimeType=\"text/html\" android:scheme=\"file\" /><data android:mimeType=\"application/json\" android:scheme=\"file\" /></intent-filter>",- "count": 7+ "count": 3},{"xml": "<intent-filter><action android:name=\"android.intent.action.VIEW\" /><category android:name=\"android.intent.category.DEFAULT\" /><category android:name=\"android.intent.category.BROWSABLE\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..json\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..mht\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..mhtml\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..md\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..md.txt\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..markdown\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..ogv\" android:scheme=\"file\" /></intent-filter>",- "count": 7+ "count": 3},{"xml": "<intent-filter><action android:name=\"com.darryncampbell.cordova.plugin.intent.ACTION\" /><category android:name=\"android.intent.category.DEFAULT\" /></intent-filter>",@@ -24,7 +24,11 @@"/manifest/application": [{"xml": "<provider android:authorities=\"${applicationId}.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"android.support.v4.content.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/mnk_file_path\" /></provider>",- "count": 7+ "count": 3+ },+ {+ "xml": "<provider android:authorities=\"${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/provider_paths\" /></provider>",+ "count": 1},{"xml": "<activity android:label=\"Our Code World filepicker\" android:name=\"com.ourcodeworld.plugins.filebrowser.DialogShowPicker\"><intent-filter><action android:name=\"com.ourcodeworld.plugins.filebrowser.DialogShowPicker\" /><category android:name=\"android.intent.category.DEFAULT\" /></intent-filter></activity>",@@ -41,27 +45,23 @@{"xml": "<provider android:authorities=\"${applicationId}.sharing.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"nl.xservices.plugins.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/sharing_paths\" /></provider>","count": 1- },- {- "xml": "<provider android:authorities=\"${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/provider_paths\" /></provider>",- "count": 1}],"/manifest": [- {- "xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",- "count": 2- },{"xml": "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />","count": 3},{- "xml": "<uses-permission android:name=\"android.permission.WAKE_LOCK\" />",+ "xml": "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\" />","count": 1},{- "xml": "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\" />",+ "xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",+ "count": 2+ },+ {+ "xml": "<uses-permission android:name=\"android.permission.WAKE_LOCK\" />","count": 1}],@@ -100,6 +100,10 @@"res/xml/config.xml": {"parents": {"/*": [+ {+ "xml": "<feature name=\"IntentShim\"><param name=\"android-package\" value=\"com.darryncampbell.cordova.plugin.intent.IntentShim\" /><param name=\"onload\" value=\"true\" /></feature>",+ "count": 1+ },{"xml": "<feature name=\"Filebrowser\"><param name=\"android-package\" value=\"com.ourcodeworld.plugins.filebrowser.Filebrowser\" /></feature>","count": 1@@ -147,10 +151,6 @@{"xml": "<feature name=\"SocialSharing\"><param name=\"android-package\" value=\"nl.xservices.plugins.SocialSharing\" /></feature>","count": 1- },- {- "xml": "<feature name=\"IntentShim\"><param name=\"android-package\" value=\"com.darryncampbell.cordova.plugin.intent.IntentShim\" /><param name=\"onload\" value=\"true\" /></feature>",- "count": 1}]}@@ -168,6 +168,9 @@}},"installed_plugins": {+ "com-darryncampbell-cordova-plugin-intent": {+ "PACKAGE_NAME": "org.tagspaces.mobile"+ },"com.ourcodeworld.plugins.Filebrowser": {"PACKAGE_NAME": "org.tagspaces.mobile"},@@ -209,13 +212,18 @@"cordova-plugin-x-socialsharing": {"ANDROID_SUPPORT_V4_VERSION": "24.1.1+","PACKAGE_NAME": "org.tagspaces.mobile"- },- "com-darryncampbell-cordova-plugin-intent": {- "PACKAGE_NAME": "org.tagspaces.mobile"}},"dependent_plugins": {},"modules": [+ {+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",+ "pluginId": "com-darryncampbell-cordova-plugin-intent",+ "clobbers": [+ "intentShim"+ ]+ },{"id": "com.ourcodeworld.plugins.Filebrowser.Filebrowser","file": "plugins/com.ourcodeworld.plugins.Filebrowser/www/filebrowser.js",@@ -483,17 +491,10 @@"clobbers": ["window.plugins.socialsharing"]- },- {- "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",- "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",- "pluginId": "com-darryncampbell-cordova-plugin-intent",- "clobbers": [- "intentShim"- ]}],"plugin_metadata": {+ "com-darryncampbell-cordova-plugin-intent": "2.0.0","com.ourcodeworld.plugins.Filebrowser": "1.0.0","com.whebcraft.cordova.plugin.downloader": "0.1.0","cordova-plugin-add-swift-support": "2.0.2",@@ -506,7 +507,6 @@"cordova-plugin-file-opener2": "3.0.4","cordova-plugin-whitelist": "1.3.4","es6-promise-plugin": "4.2.2",- "cordova-plugin-x-socialsharing": "5.6.8",- "com-darryncampbell-cordova-plugin-intent": "2.0.0"+ "cordova-plugin-x-socialsharing": "5.6.8"}}diff --git a/cordova/platforms/android/app/build.gradle b/cordova/platforms/android/app/build.gradleindex c1a7c58b7..d73a40417 100644--- a/cordova/platforms/android/app/build.gradle+++ b/cordova/platforms/android/app/build.gradle@@ -352,8 +352,8 @@ dependencies {// SUB-PROJECT DEPENDENCIES STARTimplementation(project(path: ":CordovaLib"))- implementation "androidx.legacy:legacy-support-v4:1.0.0"implementation "androidx.core:core:1.1.0"+ implementation "androidx.legacy:legacy-support-v4:1.0.0"// SUB-PROJECT DEPENDENCIES END}diff --git a/cordova/platforms/android/app/gradle/wrapper/gradle-wrapper.jar b/cordova/platforms/android/app/gradle/wrapper/gradle-wrapper.jardeleted file mode 100644index f3d88b1c2..000000000Binary files a/cordova/platforms/android/app/gradle/wrapper/gradle-wrapper.jar and /dev/null differdiff --git a/cordova/platforms/android/app/gradle/wrapper/gradle-wrapper.properties b/cordova/platforms/android/app/gradle/wrapper/gradle-wrapper.propertiesdeleted file mode 100644index 622ab64a3..000000000--- a/cordova/platforms/android/app/gradle/wrapper/gradle-wrapper.properties+++ /dev/null@@ -1,5 +0,0 @@-distributionBase=GRADLE_USER_HOME-distributionPath=wrapper/dists-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip-zipStoreBase=GRADLE_USER_HOME-zipStorePath=wrapper/distsdiff --git a/cordova/platforms/android/app/gradlew b/cordova/platforms/android/app/gradlewdeleted file mode 100755index 2fe81a7d9..000000000--- a/cordova/platforms/android/app/gradlew+++ /dev/null@@ -1,183 +0,0 @@-#!/usr/bin/env sh--#-# Copyright 2015 the original author or authors.-#-# Licensed under the Apache License, Version 2.0 (the "License");-# you may not use this file except in compliance with the License.-# You may obtain a copy of the License at-#-# https://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing, software-# distributed under the License is distributed on an "AS IS" BASIS,-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-# See the License for the specific language governing permissions and-# limitations under the License.-#--##############################################################################-##-## Gradle start up script for UN*X-##-##############################################################################--# Attempt to set APP_HOME-# Resolve links: $0 may be a link-PRG="$0"-# Need this for relative symlinks.-while [ -h "$PRG" ] ; do- ls=`ls -ld "$PRG"`- link=`expr "$ls" : '.*-> \(.*\)$'`- if expr "$link" : '/.*' > /dev/null; then- PRG="$link"- else- PRG=`dirname "$PRG"`"/$link"- fi-done-SAVED="`pwd`"-cd "`dirname \"$PRG\"`/" >/dev/null-APP_HOME="`pwd -P`"-cd "$SAVED" >/dev/null--APP_NAME="Gradle"-APP_BASE_NAME=`basename "$0"`--# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'--# Use the maximum available, or set MAX_FD != -1 to use that value.-MAX_FD="maximum"--warn () {- echo "$*"-}--die () {- echo- echo "$*"- echo- exit 1-}--# OS specific support (must be 'true' or 'false').-cygwin=false-msys=false-darwin=false-nonstop=false-case "`uname`" in- CYGWIN* )- cygwin=true- ;;- Darwin* )- darwin=true- ;;- MINGW* )- msys=true- ;;- NONSTOP* )- nonstop=true- ;;-esac--CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar--# Determine the Java command to use to start the JVM.-if [ -n "$JAVA_HOME" ] ; then- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then- # IBM's JDK on AIX uses strange locations for the executables- JAVACMD="$JAVA_HOME/jre/sh/java"- else- JAVACMD="$JAVA_HOME/bin/java"- fi- if [ ! -x "$JAVACMD" ] ; then- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME--Please set the JAVA_HOME variable in your environment to match the-location of your Java installation."- fi-else- JAVACMD="java"- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.--Please set the JAVA_HOME variable in your environment to match the-location of your Java installation."-fi--# Increase the maximum file descriptors if we can.-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then- MAX_FD_LIMIT=`ulimit -H -n`- if [ $? -eq 0 ] ; then- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then- MAX_FD="$MAX_FD_LIMIT"- fi- ulimit -n $MAX_FD- if [ $? -ne 0 ] ; then- warn "Could not set maximum file descriptor limit: $MAX_FD"- fi- else- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"- fi-fi--# For Darwin, add options to specify how the application appears in the dock-if $darwin; then- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""-fi--# For Cygwin or MSYS, switch paths to Windows format before running java-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then- APP_HOME=`cygpath --path --mixed "$APP_HOME"`- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`- JAVACMD=`cygpath --unix "$JAVACMD"`-- # We build the pattern for arguments to be converted via cygpath- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`- SEP=""- for dir in $ROOTDIRSRAW ; do- ROOTDIRS="$ROOTDIRS$SEP$dir"- SEP="|"- done- OURCYGPATTERN="(^($ROOTDIRS))"- # Add a user-defined pattern to the cygpath arguments- if [ "$GRADLE_CYGPATTERN" != "" ] ; then- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"- fi- # Now convert the arguments - kludge to limit ourselves to /bin/sh- i=0- for arg in "$@" ; do- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option-- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`- else- eval `echo args$i`="\"$arg\""- fi- i=`expr $i + 1`- done- case $i in- 0) set -- ;;- 1) set -- "$args0" ;;- 2) set -- "$args0" "$args1" ;;- 3) set -- "$args0" "$args1" "$args2" ;;- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;- esac-fi--# Escape application args-save () {- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done- echo " "-}-APP_ARGS=`save "$@"`--# Collect all arguments for the java command, following the shell quoting and substitution rules-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"--exec "$JAVACMD" "$@"diff --git a/cordova/platforms/android/app/gradlew.bat b/cordova/platforms/android/app/gradlew.batdeleted file mode 100644index 9618d8d96..000000000--- a/cordova/platforms/android/app/gradlew.bat+++ /dev/null@@ -1,100 +0,0 @@-@rem-@rem Copyright 2015 the original author or authors.-@rem-@rem Licensed under the Apache License, Version 2.0 (the "License");-@rem you may not use this file except in compliance with the License.-@rem You may obtain a copy of the License at-@rem-@rem https://www.apache.org/licenses/LICENSE-2.0-@rem-@rem Unless required by applicable law or agreed to in writing, software-@rem distributed under the License is distributed on an "AS IS" BASIS,-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-@rem See the License for the specific language governing permissions and-@rem limitations under the License.-@rem--@if "%DEBUG%" == "" @echo off-@rem ##########################################################################-@rem-@rem Gradle startup script for Windows-@rem-@rem ##########################################################################--@rem Set local scope for the variables with windows NT shell-if "%OS%"=="Windows_NT" setlocal--set DIRNAME=%~dp0-if "%DIRNAME%" == "" set DIRNAME=.-set APP_BASE_NAME=%~n0-set APP_HOME=%DIRNAME%--@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"--@rem Find java.exe-if defined JAVA_HOME goto findJavaFromJavaHome--set JAVA_EXE=java.exe-%JAVA_EXE% -version >NUL 2>&1-if "%ERRORLEVEL%" == "0" goto init--echo.-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.-echo.-echo Please set the JAVA_HOME variable in your environment to match the-echo location of your Java installation.--goto fail--:findJavaFromJavaHome-set JAVA_HOME=%JAVA_HOME:"=%-set JAVA_EXE=%JAVA_HOME%/bin/java.exe--if exist "%JAVA_EXE%" goto init--echo.-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%-echo.-echo Please set the JAVA_HOME variable in your environment to match the-echo location of your Java installation.--goto fail--:init-@rem Get command-line arguments, handling Windows variants--if not "%OS%" == "Windows_NT" goto win9xME_args--:win9xME_args-@rem Slurp the command line arguments.-set CMD_LINE_ARGS=-set _SKIP=2--:win9xME_args_slurp-if "x%~1" == "x" goto execute--set CMD_LINE_ARGS=%*--:execute-@rem Setup the command line--set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar--@rem Execute Gradle-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%--:end-@rem End local scope for the variables with windows NT shell-if "%ERRORLEVEL%"=="0" goto mainEnd--:fail-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of-rem the _cmd.exe /c_ return code!-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1-exit /b 1--:mainEnd-if "%OS%"=="Windows_NT" endlocal--:omegadiff --git a/cordova/platforms/android/app/src/main/AndroidManifest.xml b/cordova/platforms/android/app/src/main/AndroidManifest.xmlindex 07f4d630b..2a58a260a 100644--- a/cordova/platforms/android/app/src/main/AndroidManifest.xml+++ b/cordova/platforms/android/app/src/main/AndroidManifest.xml@@ -2,7 +2,7 @@<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="org.tagspaces.mobile" xmlns:android="http://schemas.android.com/apk/res/android"><supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /><uses-permission android:name="android.permission.INTERNET" />- <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">+ <application android:requestLegacyExternalStorage="true" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true"><activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize"><intent-filter android:label="@string/launcher_name"><action android:name="android.intent.action.MAIN" />@@ -44,6 +44,9 @@<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider"><meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/mnk_file_path" /></provider>+ <provider android:authorities="${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider">+ <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />+ </provider><activity android:label="Our Code World filepicker" android:name="com.ourcodeworld.plugins.filebrowser.DialogShowPicker"><intent-filter><action android:name="com.ourcodeworld.plugins.filebrowser.DialogShowPicker" />@@ -71,21 +74,12 @@<provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider"><meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" /></provider>- <provider android:authorities="${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider">- <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />- </provider>- <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">- <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/mnk_file_path" />- </provider>- <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">- <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/mnk_file_path" />- </provider><provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider"><meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/mnk_file_path" /></provider></application>- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />- <uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />+ <uses-permission android:name="android.permission.WAKE_LOCK" /></manifest>diff --git a/cordova/platforms/android/app/src/main/res/xml/config.xml b/cordova/platforms/android/app/src/main/res/xml/config.xmlindex 2931a097d..34b8c6847 100644--- a/cordova/platforms/android/app/src/main/res/xml/config.xml+++ b/cordova/platforms/android/app/src/main/res/xml/config.xml@@ -1,5 +1,9 @@<?xml version='1.0' encoding='utf-8'?><widget id="org.tagspaces.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">+ <feature name="IntentShim">+ <param name="android-package" value="com.darryncampbell.cordova.plugin.intent.IntentShim" />+ <param name="onload" value="true" />+ </feature><feature name="Filebrowser"><param name="android-package" value="com.ourcodeworld.plugins.filebrowser.Filebrowser" /></feature>@@ -33,10 +37,6 @@<feature name="SocialSharing"><param name="android-package" value="nl.xservices.plugins.SocialSharing" /></feature>- <feature name="IntentShim">- <param name="android-package" value="com.darryncampbell.cordova.plugin.intent.IntentShim" />- <param name="onload" value="true" />- </feature><feature name="Chooser"><param name="android-package" value="com.cyph.cordova.Chooser" /></feature>diff --git a/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar b/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jarindex f3d88b1c2..e708b1c02 100644Binary files a/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar and b/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar differdiff --git a/cordova/platforms/android/gradlew b/cordova/platforms/android/gradlewindex 2fe81a7d9..4f906e0c8 100755--- a/cordova/platforms/android/gradlew+++ b/cordova/platforms/android/gradlew@@ -82,6 +82,7 @@ esacCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar+# Determine the Java command to use to start the JVM.if [ -n "$JAVA_HOME" ] ; thenif [ -x "$JAVA_HOME/jre/sh/java" ] ; then@@ -129,6 +130,7 @@ fiif [ "$cygwin" = "true" -o "$msys" = "true" ] ; thenAPP_HOME=`cygpath --path --mixed "$APP_HOME"`CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`+JAVACMD=`cygpath --unix "$JAVACMD"`# We build the pattern for arguments to be converted via cygpathdiff --git a/cordova/platforms/android/gradlew.bat b/cordova/platforms/android/gradlew.batindex 9618d8d96..107acd32c 100644--- a/cordova/platforms/android/gradlew.bat+++ b/cordova/platforms/android/gradlew.bat@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.set APP_BASE_NAME=%~n0set APP_HOME=%DIRNAME%+@rem Resolve any "." and ".." in APP_HOME to make it shorter.+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"@@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHomeset JAVA_EXE=java.exe%JAVA_EXE% -version >NUL 2>&1-if "%ERRORLEVEL%" == "0" goto init+if "%ERRORLEVEL%" == "0" goto executeecho.echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.@@ -51,7 +54,7 @@ goto failset JAVA_HOME=%JAVA_HOME:"=%set JAVA_EXE=%JAVA_HOME%/bin/java.exe-if exist "%JAVA_EXE%" goto init+if exist "%JAVA_EXE%" goto executeecho.echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%@@ -61,28 +64,14 @@ echo location of your Java installation.goto fail-:init-@rem Get command-line arguments, handling Windows variants--if not "%OS%" == "Windows_NT" goto win9xME_args--:win9xME_args-@rem Slurp the command line arguments.-set CMD_LINE_ARGS=-set _SKIP=2--:win9xME_args_slurp-if "x%~1" == "x" goto execute--set CMD_LINE_ARGS=%*-:execute@rem Setup the command lineset CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar+@rem Execute Gradle-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*:end@rem End local scope for the variables with windows NT shelldiff --git a/cordova/platforms/android/platform_www/cordova_plugins.js b/cordova/platforms/android/platform_www/cordova_plugins.jsindex 5bfda3c57..0666e2eb6 100644--- a/cordova/platforms/android/platform_www/cordova_plugins.js+++ b/cordova/platforms/android/platform_www/cordova_plugins.js@@ -1,5 +1,13 @@cordova.define('cordova/plugin_list', function(require, exports, module) {module.exports = [+ {+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",+ "pluginId": "com-darryncampbell-cordova-plugin-intent",+ "clobbers": [+ "intentShim"+ ]+ },{"id": "com.ourcodeworld.plugins.Filebrowser.Filebrowser","file": "plugins/com.ourcodeworld.plugins.Filebrowser/www/filebrowser.js",@@ -267,17 +275,10 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {"clobbers": ["window.plugins.socialsharing"]- },- {- "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",- "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",- "pluginId": "com-darryncampbell-cordova-plugin-intent",- "clobbers": [- "intentShim"- ]}];module.exports.metadata = {+ "com-darryncampbell-cordova-plugin-intent": "2.0.0","com.ourcodeworld.plugins.Filebrowser": "1.0.0","com.whebcraft.cordova.plugin.downloader": "0.1.0","cordova-plugin-add-swift-support": "2.0.2",@@ -290,7 +291,6 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {"cordova-plugin-file-opener2": "3.0.4","cordova-plugin-whitelist": "1.3.4","es6-promise-plugin": "4.2.2",- "cordova-plugin-x-socialsharing": "5.6.8",- "com-darryncampbell-cordova-plugin-intent": "2.0.0"+ "cordova-plugin-x-socialsharing": "5.6.8"};-});\ No newline at end of file+});diff --git a/cordova/platforms/android/project.properties b/cordova/platforms/android/project.propertiesindex ef5f114f1..43d3a1420 100644--- a/cordova/platforms/android/project.properties+++ b/cordova/platforms/android/project.properties@@ -11,8 +11,8 @@target=android-29android.library.reference.1=CordovaLibandroid.library.reference.2=app+cordova.system.library.1=androidx.core:core:1.1.0cordova.gradle.include.1=com.ourcodeworld.plugins.Filebrowser/mobile-plugin.gradle-cordova.system.library.1=androidx.legacy:legacy-support-v4:1.0.0cordova.system.library.2=androidx.legacy:legacy-support-v4:1.0.0cordova.system.library.3=androidx.legacy:legacy-support-v4:1.0.0-cordova.system.library.4=androidx.core:core:1.1.0\ No newline at end of file+cordova.system.library.4=androidx.legacy:legacy-support-v4:1.0.0diff --git a/cordova/platforms/ios/TagSpaces.xcodeproj/project.pbxproj b/cordova/platforms/ios/TagSpaces.xcodeproj/project.pbxprojindex d284621e6..16e89734a 100755--- a/cordova/platforms/ios/TagSpaces.xcodeproj/project.pbxproj+++ b/cordova/platforms/ios/TagSpaces.xcodeproj/project.pbxproj@@ -15,6 +15,9 @@302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; };6AFF5BF91D6E424B00AB3073 /* CDVLaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6AFF5BF81D6E424B00AB3073 /* CDVLaunchScreen.storyboard */; };F833DAD9664D4D998385F691 /* Downloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 092C2B0C2C7844CB9D043A41 /* Downloader.swift */; };+ C785352031594E4F9251FB09 /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = E4530B4CA9C8414AA5889210 /* CDVFile.m */; };+ 345DF1403BE0418CB5433A2B /* CDVLocalFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DCE5A08D6304A29AE80946C /* CDVLocalFilesystem.m */; };+ 89D3404E8CDE4028B29F3A39 /* CDVAssetLibraryFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C1850F8A964922BA4AC443 /* CDVAssetLibraryFilesystem.m */; };/* End PBXBuildFile section *//* Begin PBXContainerItemProxy section */@@ -63,6 +66,12 @@ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = "TagSpaces/config.xml"; sourceTree = "<group>"; };092C2B0C2C7844CB9D043A41 /* Downloader.swift */ = {isa = PBXFileReference; name = "Downloader.swift"; path = "com.whebcraft.cordova.plugin.downloader/Downloader.swift"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.swift; explicitFileType = undefined; includeInIndex = 0; };+ E4530B4CA9C8414AA5889210 /* CDVFile.m */ = {isa = PBXFileReference; name = "CDVFile.m"; path = "cordova-plugin-file/CDVFile.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };+ 4DCE5A08D6304A29AE80946C /* CDVLocalFilesystem.m */ = {isa = PBXFileReference; name = "CDVLocalFilesystem.m"; path = "cordova-plugin-file/CDVLocalFilesystem.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };+ 96C1850F8A964922BA4AC443 /* CDVAssetLibraryFilesystem.m */ = {isa = PBXFileReference; name = "CDVAssetLibraryFilesystem.m"; path = "cordova-plugin-file/CDVAssetLibraryFilesystem.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };+ CB882AF1B8AA440C871B5841 /* CDVFile.h */ = {isa = PBXFileReference; name = "CDVFile.h"; path = "cordova-plugin-file/CDVFile.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };+ F0B1357B1AC84CC79FFB7C50 /* CDVLocalFilesystem.h */ = {isa = PBXFileReference; name = "CDVLocalFilesystem.h"; path = "cordova-plugin-file/CDVLocalFilesystem.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };+ BF1652E774F1400BA3AC52D3 /* CDVAssetLibraryFilesystem.h */ = {isa = PBXFileReference; name = "CDVAssetLibraryFilesystem.h"; path = "cordova-plugin-file/CDVAssetLibraryFilesystem.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };/* End PBXFileReference section *//* Begin PBXFrameworksBuildPhase section */@@ -168,6 +177,12 @@isa = PBXGroup;children = (092C2B0C2C7844CB9D043A41 /* Downloader.swift */,+ E4530B4CA9C8414AA5889210 /* CDVFile.m */,+ 4DCE5A08D6304A29AE80946C /* CDVLocalFilesystem.m */,+ 96C1850F8A964922BA4AC443 /* CDVAssetLibraryFilesystem.m */,+ CB882AF1B8AA440C871B5841 /* CDVFile.h */,+ F0B1357B1AC84CC79FFB7C50 /* CDVLocalFilesystem.h */,+ BF1652E774F1400BA3AC52D3 /* CDVAssetLibraryFilesystem.h */,);name = Plugins;path = "TagSpaces/Plugins";@@ -297,6 +312,9 @@1D3623260D0F684500981E51 /* AppDelegate.m in Sources */,302D95F114D2391D003F00A1 /* MainViewController.m in Sources */,F833DAD9664D4D998385F691 /* Downloader.swift in Sources */,+ C785352031594E4F9251FB09 /* CDVFile.m in Sources */,+ 345DF1403BE0418CB5433A2B /* CDVLocalFilesystem.m in Sources */,+ 89D3404E8CDE4028B29F3A39 /* CDVAssetLibraryFilesystem.m in Sources */,);runOnlyForDeploymentPostprocessing = 0;};@@ -333,6 +351,10 @@PRODUCT_NAME = "$(TARGET_NAME)";TARGETED_DEVICE_FAMILY = "1,2";VALIDATE_WORKSPACE = NO;+ SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h";+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;+ SWIFT_VERSION = 5;+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";};name = Debug;};@@ -356,6 +378,9 @@PRODUCT_NAME = "$(TARGET_NAME)";TARGETED_DEVICE_FAMILY = "1,2";VALIDATE_WORKSPACE = NO;+ SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h";+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;+ SWIFT_VERSION = 5;};name = Release;};@@ -399,6 +424,10 @@SDKROOT = iphoneos;SKIP_INSTALL = NO;WK_WEB_VIEW_ONLY = 1;+ SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h";+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;+ SWIFT_VERSION = 5;+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";};name = Debug;};@@ -440,6 +469,9 @@SDKROOT = iphoneos;SKIP_INSTALL = NO;WK_WEB_VIEW_ONLY = 1;+ SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h";+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;+ SWIFT_VERSION = 5;};name = Release;};diff --git a/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVAssetLibraryFilesystem.h b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVAssetLibraryFilesystem.hnew file mode 100644index 000000000..e09e2250e--- /dev/null+++ b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVAssetLibraryFilesystem.h@@ -0,0 +1,30 @@+/*+ Licensed to the Apache Software Foundation (ASF) under one+ or more contributor license agreements. See the NOTICE file+ distributed with this work for additional information+ regarding copyright ownership. The ASF licenses this file+ to you under the Apache License, Version 2.0 (the+ "License"); you may not use this file except in compliance+ with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing,+ software distributed under the License is distributed on an+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ KIND, either express or implied. See the License for the+ specific language governing permissions and limitations+ under the License.+ */++#import "CDVFile.h"++extern NSString* const kCDVAssetsLibraryPrefix;+extern NSString* const kCDVAssetsLibraryScheme;++@interface CDVAssetLibraryFilesystem : NSObject<CDVFileSystem> {+}++- (id) initWithName:(NSString *)name;++@enddiff --git a/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVAssetLibraryFilesystem.m b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVAssetLibraryFilesystem.mnew file mode 100644index 000000000..8486b7be1--- /dev/null+++ b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVAssetLibraryFilesystem.m@@ -0,0 +1,253 @@+/*+ Licensed to the Apache Software Foundation (ASF) under one+ or more contributor license agreements. See the NOTICE file+ distributed with this work for additional information+ regarding copyright ownership. The ASF licenses this file+ to you under the Apache License, Version 2.0 (the+ "License"); you may not use this file except in compliance+ with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing,+ software distributed under the License is distributed on an+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ KIND, either express or implied. See the License for the+ specific language governing permissions and limitations+ under the License.+ */++#import "CDVFile.h"+#import "CDVAssetLibraryFilesystem.h"+#import <Cordova/CDV.h>+#import <AssetsLibrary/ALAsset.h>+#import <AssetsLibrary/ALAssetRepresentation.h>+#import <AssetsLibrary/ALAssetsLibrary.h>+#import <MobileCoreServices/MobileCoreServices.h>++NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";+NSString* const kCDVAssetsLibraryScheme = @"assets-library";++@implementation CDVAssetLibraryFilesystem+@synthesize name=_name, urlTransformer;+++/*+ The CDVAssetLibraryFilesystem works with resources which are identified+ by iOS as+ asset-library://<path>+ and represents them internally as URLs of the form+ cdvfile://localhost/assets-library/<path>+ */++- (NSURL *)assetLibraryURLForLocalURL:(CDVFilesystemURL *)url+{+ if ([url.url.scheme isEqualToString:kCDVFilesystemURLPrefix]) {+ NSString *path = [[url.url absoluteString] substringFromIndex:[@"cdvfile://localhost/assets-library" length]];+ return [NSURL URLWithString:[NSString stringWithFormat:@"assets-library:/%@", path]];+ }+ return url.url;+}++- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url+{+ NSDictionary* entry = [self makeEntryForLocalURL:url];+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:entry];+}++- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url {+ return [self makeEntryForPath:url.fullPath isDirectory:NO];+}++- (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir+{+ NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:5];+ NSString* lastPart = [fullPath lastPathComponent];+ if (isDir && ![fullPath hasSuffix:@"/"]) {+ fullPath = [fullPath stringByAppendingString:@"/"];+ }+ [dirEntry setObject:[NSNumber numberWithBool:!isDir] forKey:@"isFile"];+ [dirEntry setObject:[NSNumber numberWithBool:isDir] forKey:@"isDirectory"];+ [dirEntry setObject:fullPath forKey:@"fullPath"];+ [dirEntry setObject:lastPart forKey:@"name"];+ [dirEntry setObject:self.name forKey: @"filesystemName"];++ NSURL* nativeURL = [NSURL URLWithString:[NSString stringWithFormat:@"assets-library:/%@",fullPath]];+ if (self.urlTransformer) {+ nativeURL = self.urlTransformer(nativeURL);+ }+ dirEntry[@"nativeURL"] = [nativeURL absoluteString];++ return dirEntry;+}++/* helper function to get the mimeType from the file extension+ * IN:+ * NSString* fullPath - filename (may include path)+ * OUT:+ * NSString* the mime type as type/subtype. nil if not able to determine+ */++ (NSString*)getMimeTypeFromPath:(NSString*)fullPath+{+ NSString* mimeType = nil;++ if (fullPath) {+ CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);+ if (typeId) {+ mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);+ if (!mimeType) {+ // special case for m4a+ if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {+ mimeType = @"audio/mp4";+ } else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {+ mimeType = @"audio/wav";+ } else if ([[fullPath pathExtension] rangeOfString:@"css"].location != NSNotFound) {+ mimeType = @"text/css";+ }+ }+ CFRelease(typeId);+ }+ }+ return mimeType;+}++- (id)initWithName:(NSString *)name+{+ if (self) {+ self.name = name;+ }+ return self;+}++- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options+{+ // return unsupported result for assets-library URLs+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getFile not supported for assets-library URLs."];+}++- (CDVPluginResult*)getParentForURL:(CDVFilesystemURL *)localURI+{+ // we don't (yet?) support getting the parent of an asset+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];+}++- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options+{+ // setMetadata doesn't make sense for asset library files+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];+}++- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI+{+ // return error for assets-library URLs+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:INVALID_MODIFICATION_ERR];+}++- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI+{+ // return error for assets-library URLs+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"removeRecursively not supported for assets-library URLs."];+}++- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI+{+ // return unsupported result for assets-library URLs+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"readEntries not supported for assets-library URLs."];+}++- (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos+{+ // assets-library files can't be truncated+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];+}++- (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend+{+ // text can't be written into assets-library files+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];+}++- (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback+{+ // Copying to an assets library file is not doable, since we can't write it.+ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:INVALID_MODIFICATION_ERR];+ callback(result);+}++- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)url+{+ NSString *path = nil;+ if ([[url.url scheme] isEqualToString:kCDVAssetsLibraryScheme]) {+ path = [url.url path];+ } else {+ path = url.fullPath;+ }+ if ([path hasSuffix:@"/"]) {+ path = [path substringToIndex:([path length]-1)];+ }+ return path;+}++- (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback+{+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {+ if (asset) {+ // We have the asset! Get the data and send it off.+ ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];+ NSUInteger size = (end > start) ? (end - start) : [assetRepresentation size];+ Byte* buffer = (Byte*)malloc(size);+ NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:start length:size error:nil];+ NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];+ NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);++ callback(data, MIMEType, NO_ERROR);+ } else {+ callback(nil, nil, NOT_FOUND_ERR);+ }+ };++ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {+ // Retrieving the asset failed for some reason. Send the appropriate error.+ NSLog(@"Error: %@", error);+ callback(nil, nil, SECURITY_ERR);+ };++ ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];+ [assetsLibrary assetForURL:[self assetLibraryURLForLocalURL:localURL] resultBlock:resultBlock failureBlock:failureBlock];+}++- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback+{+ // In this case, we need to use an asynchronous method to retrieve the file.+ // Because of this, we can't just assign to `result` and send it at the end of the method.+ // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {+ if (asset) {+ // We have the asset! Populate the dictionary and send it off.+ NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];+ ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];+ [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[assetRepresentation size]] forKey:@"size"];+ [fileInfo setObject:localURL.fullPath forKey:@"fullPath"];+ NSString* filename = [assetRepresentation filename];+ [fileInfo setObject:filename forKey:@"name"];+ [fileInfo setObject:[CDVAssetLibraryFilesystem getMimeTypeFromPath:filename] forKey:@"type"];+ NSDate* creationDate = [asset valueForProperty:ALAssetPropertyDate];+ NSNumber* msDate = [NSNumber numberWithDouble:[creationDate timeIntervalSince1970] * 1000];+ [fileInfo setObject:msDate forKey:@"lastModifiedDate"];++ callback([CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo]);+ } else {+ // We couldn't find the asset. Send the appropriate error.+ callback([CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR]);+ }+ };+ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {+ // Retrieving the asset failed for some reason. Send the appropriate error.+ callback([CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]]);+ };++ ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];+ [assetsLibrary assetForURL:[self assetLibraryURLForLocalURL:localURL] resultBlock:resultBlock failureBlock:failureBlock];+ return;+}+@enddiff --git a/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVFile.h b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVFile.hnew file mode 100644index 000000000..987c66b5c--- /dev/null+++ b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVFile.h@@ -0,0 +1,157 @@+/*+ Licensed to the Apache Software Foundation (ASF) under one+ or more contributor license agreements. See the NOTICE file+ distributed with this work for additional information+ regarding copyright ownership. The ASF licenses this file+ to you under the Apache License, Version 2.0 (the+ "License"); you may not use this file except in compliance+ with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing,+ software distributed under the License is distributed on an+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ KIND, either express or implied. See the License for the+ specific language governing permissions and limitations+ under the License.+ */++#import <Foundation/Foundation.h>+#import <Cordova/CDVPlugin.h>++extern NSString* const kCDVAssetsLibraryPrefix;+extern NSString* const kCDVFilesystemURLPrefix;++enum CDVFileError {+ NO_ERROR = 0,+ NOT_FOUND_ERR = 1,+ SECURITY_ERR = 2,+ ABORT_ERR = 3,+ NOT_READABLE_ERR = 4,+ ENCODING_ERR = 5,+ NO_MODIFICATION_ALLOWED_ERR = 6,+ INVALID_STATE_ERR = 7,+ SYNTAX_ERR = 8,+ INVALID_MODIFICATION_ERR = 9,+ QUOTA_EXCEEDED_ERR = 10,+ TYPE_MISMATCH_ERR = 11,+ PATH_EXISTS_ERR = 12+};+typedef int CDVFileError;++@interface CDVFilesystemURL : NSObject {+ NSURL *_url;+ NSString *_fileSystemName;+ NSString *_fullPath;+}++- (id) initWithString:(NSString*)strURL;+- (id) initWithURL:(NSURL*)URL;++ (CDVFilesystemURL *)fileSystemURLWithString:(NSString *)strURL;++ (CDVFilesystemURL *)fileSystemURLWithURL:(NSURL *)URL;++- (NSString *)absoluteURL;++@property (atomic) NSURL *url;+@property (atomic) NSString *fileSystemName;+@property (atomic) NSString *fullPath;++@end++@interface CDVFilesystemURLProtocol : NSURLProtocol+@end++@protocol CDVFileSystem+- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url;+- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options;+- (CDVPluginResult *)getParentForURL:(CDVFilesystemURL *)localURI;+- (CDVPluginResult *)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options;+- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI;+- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI;+- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI;+- (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos;+- (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend;+- (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback;+- (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback;+- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback;++- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url;+- (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir;++@property (nonatomic,strong) NSString *name;+@property (nonatomic, copy) NSURL*(^urlTransformer)(NSURL*);++@optional+- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)localURI;+- (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path;++@end++@interface CDVFile : CDVPlugin {+ NSString* rootDocsPath;+ NSString* appDocsPath;+ NSString* appLibraryPath;+ NSString* appTempPath;++ NSMutableArray* fileSystems_;+ BOOL userHasAllowed;+}++- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;+- (NSDictionary*)makeEntryForPath:(NSString*)fullPath fileSystemName:(NSString *)fsName isDirectory:(BOOL)isDir;+- (NSDictionary *)makeEntryForURL:(NSURL *)URL;+- (CDVFilesystemURL *)fileSystemURLforLocalPath:(NSString *)localPath;++- (NSObject<CDVFileSystem> *)filesystemForURL:(CDVFilesystemURL *)localURL;++/* Native Registration API */+- (void)registerFilesystem:(NSObject<CDVFileSystem> *)fs;+- (NSObject<CDVFileSystem> *)fileSystemByName:(NSString *)fsName;++/* Exec API */+- (void)requestFileSystem:(CDVInvokedUrlCommand*)command;+- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;+- (void)getDirectory:(CDVInvokedUrlCommand*)command;+- (void)getFile:(CDVInvokedUrlCommand*)command;+- (void)getParent:(CDVInvokedUrlCommand*)command;+- (void)removeRecursively:(CDVInvokedUrlCommand*)command;+- (void)remove:(CDVInvokedUrlCommand*)command;+- (void)copyTo:(CDVInvokedUrlCommand*)command;+- (void)moveTo:(CDVInvokedUrlCommand*)command;+- (void)getFileMetadata:(CDVInvokedUrlCommand*)command;+- (void)readEntries:(CDVInvokedUrlCommand*)command;+- (void)readAsText:(CDVInvokedUrlCommand*)command;+- (void)readAsDataURL:(CDVInvokedUrlCommand*)command;+- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;+- (void)write:(CDVInvokedUrlCommand*)command;+- (void)testFileExists:(CDVInvokedUrlCommand*)command;+- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;+- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;+- (void)truncate:(CDVInvokedUrlCommand*)command;+- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;++/* Compatibilty with older File API */+- (NSString*)getMimeTypeFromPath:(NSString*)fullPath;+- (NSDictionary *)getDirectoryEntry:(NSString *)target isDirectory:(BOOL)bDirRequest;++/* Conversion between filesystem paths and URLs */+- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)URL;++/* Internal methods for testing */+- (void)_getLocalFilesystemPath:(CDVInvokedUrlCommand*)command;++@property (nonatomic, strong) NSString* rootDocsPath;+@property (nonatomic, strong) NSString* appDocsPath;+@property (nonatomic, strong) NSString* appLibraryPath;+@property (nonatomic, strong) NSString* appTempPath;+@property (nonatomic, strong) NSString* persistentPath;+@property (nonatomic, strong) NSString* temporaryPath;+@property (nonatomic, strong) NSMutableArray* fileSystems;++@property BOOL userHasAllowed;++@end++#define kW3FileTemporary @"temporary"+#define kW3FilePersistent @"persistent"diff --git a/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVFile.m b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVFile.mnew file mode 100644index 000000000..75640c9c1--- /dev/null+++ b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVFile.m@@ -0,0 +1,1119 @@+/*+ Licensed to the Apache Software Foundation (ASF) under one+ or more contributor license agreements. See the NOTICE file+ distributed with this work for additional information+ regarding copyright ownership. The ASF licenses this file+ to you under the Apache License, Version 2.0 (the+ "License"); you may not use this file except in compliance+ with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing,+ software distributed under the License is distributed on an+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ KIND, either express or implied. See the License for the+ specific language governing permissions and limitations+ under the License.+ */++#import <Cordova/CDV.h>+#import "CDVFile.h"+#import "CDVLocalFilesystem.h"+#import "CDVAssetLibraryFilesystem.h"+#import <objc/message.h>++static NSString* toBase64(NSData* data) {+ SEL s1 = NSSelectorFromString(@"cdv_base64EncodedString");+ SEL s2 = NSSelectorFromString(@"base64EncodedString");+ SEL s3 = NSSelectorFromString(@"base64EncodedStringWithOptions:");++ if ([data respondsToSelector:s1]) {+ NSString* (*func)(id, SEL) = (void *)[data methodForSelector:s1];+ return func(data, s1);+ } else if ([data respondsToSelector:s2]) {+ NSString* (*func)(id, SEL) = (void *)[data methodForSelector:s2];+ return func(data, s2);+ } else if ([data respondsToSelector:s3]) {+ NSString* (*func)(id, SEL, NSUInteger) = (void *)[data methodForSelector:s3];+ return func(data, s3, 0);+ } else {+ return nil;+ }+}++CDVFile *filePlugin = nil;++extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));++#ifndef __IPHONE_5_1+ NSString* const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";+#endif++NSString* const kCDVFilesystemURLPrefix = @"cdvfile";++@implementation CDVFilesystemURL+@synthesize url=_url;+@synthesize fileSystemName=_fileSystemName;+@synthesize fullPath=_fullPath;++- (id) initWithString:(NSString *)strURL+{+ if ( self = [super init] ) {+ NSURL *decodedURL = [NSURL URLWithString:strURL];+ return [self initWithURL:decodedURL];+ }+ return nil;+}++-(id) initWithURL:(NSURL *)URL+{+ if ( self = [super init] ) {+ self.url = URL;+ self.fileSystemName = [self filesystemNameForLocalURI:URL];+ self.fullPath = [self fullPathForLocalURI:URL];+ }+ return self;+}++/*+ * IN+ * NSString localURI+ * OUT+ * NSString FileSystem Name for this URI, or nil if it is not recognized.+ */+- (NSString *)filesystemNameForLocalURI:(NSURL *)uri+{+ if ([[uri scheme] isEqualToString:kCDVFilesystemURLPrefix] && [[uri host] isEqualToString:@"localhost"]) {+ NSArray *pathComponents = [uri pathComponents];+ if (pathComponents != nil && pathComponents.count > 1) {+ return [pathComponents objectAtIndex:1];+ }+ } else if ([[uri scheme] isEqualToString:kCDVAssetsLibraryScheme]) {+ return @"assets-library";+ }+ return nil;+}++/*+ * IN+ * NSString localURI+ * OUT+ * NSString fullPath component suitable for an Entry object.+ * The incoming URI should be properly escaped. The returned fullPath is unescaped.+ */+- (NSString *)fullPathForLocalURI:(NSURL *)uri+{+ if ([[uri scheme] isEqualToString:kCDVFilesystemURLPrefix] && [[uri host] isEqualToString:@"localhost"]) {+ NSString *path = [uri path];+ if ([uri query]) {+ path = [NSString stringWithFormat:@"%@?%@", path, [uri query]];+ }+ NSRange slashRange = [path rangeOfString:@"/" options:0 range:NSMakeRange(1, path.length-1)];+ if (slashRange.location == NSNotFound) {+ return @"";+ }+ return [path substringFromIndex:slashRange.location];+ } else if ([[uri scheme] isEqualToString:kCDVAssetsLibraryScheme]) {+ return [[uri absoluteString] substringFromIndex:[kCDVAssetsLibraryScheme length]+2];+ }+ return nil;+}+++ (CDVFilesystemURL *)fileSystemURLWithString:(NSString *)strURL+{+ return [[CDVFilesystemURL alloc] initWithString:strURL];+}+++ (CDVFilesystemURL *)fileSystemURLWithURL:(NSURL *)URL+{+ return [[CDVFilesystemURL alloc] initWithURL:URL];+}++- (NSString *)absoluteURL+{+ return [NSString stringWithFormat:@"cdvfile://localhost/%@%@", self.fileSystemName, self.fullPath];+}++@end++@implementation CDVFilesystemURLProtocol+++ (BOOL)canInitWithRequest:(NSURLRequest*)request+{+ NSURL* url = [request URL];+ return [[url scheme] isEqualToString:kCDVFilesystemURLPrefix];+}+++ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request+{+ return request;+}+++ (BOOL)requestIsCacheEquivalent:(NSURLRequest*)requestA toRequest:(NSURLRequest*)requestB+{+ return [[[requestA URL] resourceSpecifier] isEqualToString:[[requestB URL] resourceSpecifier]];+}++- (void)startLoading+{+ CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithURL:[[self request] URL]];+ NSObject<CDVFileSystem> *fs = [filePlugin filesystemForURL:url];+ __weak CDVFilesystemURLProtocol* weakSelf = self;++ [fs readFileAtURL:url start:0 end:-1 callback:^void(NSData *data, NSString *mimetype, CDVFileError error) {+ NSMutableDictionary* responseHeaders = [[NSMutableDictionary alloc] init];+ responseHeaders[@"Cache-Control"] = @"no-cache";++ if (!error) {+ responseHeaders[@"Content-Type"] = mimetype;+ NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url.url statusCode:200 HTTPVersion:@"HTTP/1.1"headerFields:responseHeaders];+ [[weakSelf client] URLProtocol:weakSelf didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];+ [[weakSelf client] URLProtocol:weakSelf didLoadData:data];+ [[weakSelf client] URLProtocolDidFinishLoading:weakSelf];+ } else {+ NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url.url statusCode:404 HTTPVersion:@"HTTP/1.1"headerFields:responseHeaders];+ [[weakSelf client] URLProtocol:weakSelf didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];+ [[weakSelf client] URLProtocolDidFinishLoading:weakSelf];+ }+ }];+}++- (void)stopLoading+{}++- (NSCachedURLResponse *)connection:(NSURLConnection *)connection+ willCacheResponse:(NSCachedURLResponse*)cachedResponse {+ return nil;+}++@end+++@implementation CDVFile++@synthesize rootDocsPath, appDocsPath, appLibraryPath, appTempPath, userHasAllowed, fileSystems=fileSystems_;++- (void)registerFilesystem:(NSObject<CDVFileSystem> *)fs {+ __weak CDVFile* weakSelf = self;+ SEL sel = NSSelectorFromString(@"urlTransformer");+ // for backwards compatibility - we check if this property is there+ // we create a wrapper block because the urlTransformer property+ // on the commandDelegate might be set dynamically at a future time+ // (and not dependent on plugin loading order)+ if ([self.commandDelegate respondsToSelector:sel]) {+ fs.urlTransformer = ^NSURL*(NSURL* urlToTransform) {+ // grab the block from the commandDelegate+ NSURL* (^urlTransformer)(NSURL*) = ((id(*)(id, SEL))objc_msgSend)(weakSelf.commandDelegate, sel);+ // if block is not null, we call it+ if (urlTransformer) {+ return urlTransformer(urlToTransform);+ } else { // else we return the same url+ return urlToTransform;+ }+ };+ }+ [fileSystems_ addObject:fs];+}++- (NSObject<CDVFileSystem> *)fileSystemByName:(NSString *)fsName+{+ if (self.fileSystems != nil) {+ for (NSObject<CDVFileSystem> *fs in self.fileSystems) {+ if ([fs.name isEqualToString:fsName]) {+ return fs;+ }+ }+ }+ return nil;+}++- (NSObject<CDVFileSystem> *)filesystemForURL:(CDVFilesystemURL *)localURL {+ if (localURL.fileSystemName == nil) return nil;+ @try {+ return [self fileSystemByName:localURL.fileSystemName];+ }+ @catch (NSException *e) {+ return nil;+ }+}++- (NSArray *)getExtraFileSystemsPreference:(UIViewController *)vc+{+ NSString *filesystemsStr = nil;+ if([self.viewController isKindOfClass:[CDVViewController class]]) {+ CDVViewController *vc = (CDVViewController *)self.viewController;+ NSDictionary *settings = [vc settings];+ filesystemsStr = [settings[@"iosextrafilesystems"] lowercaseString];+ }+ if (!filesystemsStr) {+ filesystemsStr = @"library,library-nosync,documents,documents-nosync,cache,bundle,root";+ }+ return [filesystemsStr componentsSeparatedByString:@","];+}++- (void)makeNonSyncable:(NSString*)path {+ [[NSFileManager defaultManager] createDirectoryAtPath:path+ withIntermediateDirectories:YES+ attributes:nil+ error:nil];+ NSURL* url = [NSURL fileURLWithPath:path];+ [url setResourceValue: [NSNumber numberWithBool: YES]+ forKey: NSURLIsExcludedFromBackupKey error:nil];++}++- (void)registerExtraFileSystems:(NSArray *)filesystems fromAvailableSet:(NSDictionary *)availableFileSystems+{+ NSMutableSet *installedFilesystems = [[NSMutableSet alloc] initWithCapacity:7];++ /* Build non-syncable directories as necessary */+ for (NSString *nonSyncFS in @[@"library-nosync", @"documents-nosync"]) {+ if ([filesystems containsObject:nonSyncFS]) {+ [self makeNonSyncable:availableFileSystems[nonSyncFS]];+ }+ }++ /* Register filesystems in order */+ for (NSString *fsName in filesystems) {+ if (![installedFilesystems containsObject:fsName]) {+ NSString *fsRoot = availableFileSystems[fsName];+ if (fsRoot) {+ [filePlugin registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:fsName root:fsRoot]];+ [installedFilesystems addObject:fsName];+ } else {+ NSLog(@"Unrecognized extra filesystem identifier: %@", fsName);+ }+ }+ }+}++- (NSDictionary *)getAvailableFileSystems+{+ NSString *libPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];+ NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];+ return @{+ @"library": libPath,+ @"library-nosync": [libPath stringByAppendingPathComponent:@"NoCloud"],+ @"documents": docPath,+ @"documents-nosync": [docPath stringByAppendingPathComponent:@"NoCloud"],+ @"cache": [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0],+ @"bundle": [[NSBundle mainBundle] bundlePath],+ @"root": @"/"+ };+}++- (void)pluginInitialize+{+ filePlugin = self;+ [NSURLProtocol registerClass:[CDVFilesystemURLProtocol class]];++ fileSystems_ = [[NSMutableArray alloc] initWithCapacity:3];++ // Get the Library directory path+ NSArray* paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);+ self.appLibraryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"files"];++ // Get the Temporary directory path+ self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath]; // remove trailing slash from NSTemporaryDirectory()++ // Get the Documents directory path+ paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);+ self.rootDocsPath = [paths objectAtIndex:0];+ self.appDocsPath = [self.rootDocsPath stringByAppendingPathComponent:@"files"];+++ NSString *location = nil;+ if([self.viewController isKindOfClass:[CDVViewController class]]) {+ CDVViewController *vc = (CDVViewController *)self.viewController;+ NSMutableDictionary *settings = vc.settings;+ location = [[settings objectForKey:@"iospersistentfilelocation"] lowercaseString];+ }+ if (location == nil) {+ // Compatibilty by default (if the config preference is not set, or+ // if we're not embedded in a CDVViewController somehow.)+ location = @"compatibility";+ }++ NSError *error;+ if ([[NSFileManager defaultManager] createDirectoryAtPath:self.appTempPath+ withIntermediateDirectories:YES+ attributes:nil+ error:&error]) {+ [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"temporary" root:self.appTempPath]];+ } else {+ NSLog(@"Unable to create temporary directory: %@", error);+ }+ if ([location isEqualToString:@"library"]) {+ if ([[NSFileManager defaultManager] createDirectoryAtPath:self.appLibraryPath+ withIntermediateDirectories:YES+ attributes:nil+ error:&error]) {+ [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.appLibraryPath]];+ } else {+ NSLog(@"Unable to create library directory: %@", error);+ }+ } else if ([location isEqualToString:@"compatibility"]) {+ /*+ * Fall-back to compatibility mode -- this is the logic implemented in+ * earlier versions of this plugin, and should be maintained here so+ * that apps which were originally deployed with older versions of the+ * plugin can continue to provide access to files stored under those+ * versions.+ */+ [self registerFilesystem:[[CDVLocalFilesystem alloc] initWithName:@"persistent" root:self.rootDocsPath]];+ } else {+ NSAssert(false,+ @"File plugin configuration error: Please set iosPersistentFileLocation in config.xml to one of \"library\" (for new applications) or \"compatibility\" (for compatibility with previous versions)");+ }+ [self registerFilesystem:[[CDVAssetLibraryFilesystem alloc] initWithName:@"assets-library"]];++ [self registerExtraFileSystems:[self getExtraFileSystemsPreference:self.viewController]+ fromAvailableSet:[self getAvailableFileSystems]];++}++- (CDVFilesystemURL *)fileSystemURLforArg:(NSString *)urlArg+{+ CDVFilesystemURL* ret = nil;+ if ([urlArg hasPrefix:@"file://"]) {+ /* This looks like a file url. Get the path, and see if any handlers recognize it. */+ NSURL *fileURL = [NSURL URLWithString:urlArg];+ NSURL *resolvedFileURL = [fileURL URLByResolvingSymlinksInPath];+ NSString *path = [resolvedFileURL path];+ ret = [self fileSystemURLforLocalPath:path];+ } else {+ ret = [CDVFilesystemURL fileSystemURLWithString:urlArg];+ }+ return ret;+}++- (CDVFilesystemURL *)fileSystemURLforLocalPath:(NSString *)localPath+{+ CDVFilesystemURL *localURL = nil;+ NSUInteger shortestFullPath = 0;++ // Try all installed filesystems, in order. Return the most match url.+ for (id object in self.fileSystems) {+ if ([object respondsToSelector:@selector(URLforFilesystemPath:)]) {+ CDVFilesystemURL *url = [object URLforFilesystemPath:localPath];+ if (url){+ // A shorter fullPath would imply that the filesystem is a better match for the local path+ if (!localURL || ([[url fullPath] length] < shortestFullPath)) {+ localURL = url;+ shortestFullPath = [[url fullPath] length];+ }+ }+ }+ }+ return localURL;+}++- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath+{+ NSFileManager* fMgr = [[NSFileManager alloc] init];++ NSError* __autoreleasing pError = nil;++ NSDictionary* pDict = [fMgr attributesOfFileSystemForPath:appPath error:&pError];+ NSNumber* pNumAvail = (NSNumber*)[pDict objectForKey:NSFileSystemFreeSize];++ return pNumAvail;+}++/* Request the File System info+ *+ * IN:+ * arguments[0] - type (number as string)+ * TEMPORARY = 0, PERSISTENT = 1;+ * arguments[1] - size+ *+ * OUT:+ * Dictionary representing FileSystem object+ * name - the human readable directory name+ * root = DirectoryEntry object+ * bool isDirectory+ * bool isFile+ * string name+ * string fullPath+ * fileSystem = FileSystem object - !! ignored because creates circular reference !!+ */++- (void)requestFileSystem:(CDVInvokedUrlCommand*)command+{+ // arguments+ NSString* strType = [command argumentAtIndex:0];+ unsigned long long size = [[command argumentAtIndex:1] longLongValue];++ int type = [strType intValue];+ CDVPluginResult* result = nil;++ if (type >= self.fileSystems.count) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:NOT_FOUND_ERR];+ NSLog(@"No filesystem of type requested");+ } else {+ NSString* fullPath = @"/";+ // check for avail space for size request+ NSNumber* pNumAvail = [self checkFreeDiskSpace:self.rootDocsPath];+ // NSLog(@"Free space: %@", [NSString stringWithFormat:@"%qu", [ pNumAvail unsignedLongLongValue ]]);+ if (pNumAvail && ([pNumAvail unsignedLongLongValue] < size)) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:QUOTA_EXCEEDED_ERR];+ } else {+ NSObject<CDVFileSystem> *rootFs = [self.fileSystems objectAtIndex:type];+ if (rootFs == nil) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:NOT_FOUND_ERR];+ NSLog(@"No filesystem of type requested");+ } else {+ NSMutableDictionary* fileSystem = [NSMutableDictionary dictionaryWithCapacity:2];+ [fileSystem setObject:rootFs.name forKey:@"name"];+ NSDictionary* dirEntry = [self makeEntryForPath:fullPath fileSystemName:rootFs.name isDirectory:YES];+ [fileSystem setObject:dirEntry forKey:@"root"];+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];+ }+ }+ }+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}+++- (void)requestAllFileSystems:(CDVInvokedUrlCommand*)command+{+ NSMutableArray* ret = [[NSMutableArray alloc] init];+ for (NSObject<CDVFileSystem>* root in fileSystems_) {+ [ret addObject:[self makeEntryForPath:@"/" fileSystemName:root.name isDirectory:YES]];+ }+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:ret];+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++- (void)requestAllPaths:(CDVInvokedUrlCommand*)command+{+ NSString* libPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];+ NSString* libPathSync = [libPath stringByAppendingPathComponent:@"Cloud"];+ NSString* libPathNoSync = [libPath stringByAppendingPathComponent:@"NoCloud"];+ NSString* docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];+ NSString* storagePath = [libPath stringByDeletingLastPathComponent];+ NSString* cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];++ // Create the directories if necessary.+ [[NSFileManager defaultManager] createDirectoryAtPath:libPathSync withIntermediateDirectories:YES attributes:nil error:nil];+ [[NSFileManager defaultManager] createDirectoryAtPath:libPathNoSync withIntermediateDirectories:YES attributes:nil error:nil];+ // Mark NoSync as non-iCloud.+ [[NSURL fileURLWithPath:libPathNoSync] setResourceValue: [NSNumber numberWithBool: YES]+ forKey: NSURLIsExcludedFromBackupKey error:nil];++ NSDictionary* ret = @{+ @"applicationDirectory": [[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]] absoluteString],+ @"applicationStorageDirectory": [[NSURL fileURLWithPath:storagePath] absoluteString],+ @"dataDirectory": [[NSURL fileURLWithPath:libPathNoSync] absoluteString],+ @"syncedDataDirectory": [[NSURL fileURLWithPath:libPathSync] absoluteString],+ @"documentsDirectory": [[NSURL fileURLWithPath:docPath] absoluteString],+ @"cacheDirectory": [[NSURL fileURLWithPath:cachePath] absoluteString],+ @"tempDirectory": [[NSURL fileURLWithPath:NSTemporaryDirectory()] absoluteString]+ };++ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:ret];+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/* Creates and returns a dictionary representing an Entry Object+ *+ * IN:+ * NSString* fullPath of the entry+ * int fsType - FileSystem type+ * BOOL isDirectory - YES if this is a directory, NO if is a file+ * OUT:+ * NSDictionary* Entry object+ * bool as NSNumber isDirectory+ * bool as NSNumber isFile+ * NSString* name - last part of path+ * NSString* fullPath+ * NSString* filesystemName - FileSystem name -- actual filesystem will be created on the JS side if necessary, to avoid+ * creating circular reference (FileSystem contains DirectoryEntry which contains FileSystem.....!!)+ */+- (NSDictionary*)makeEntryForPath:(NSString*)fullPath fileSystemName:(NSString *)fsName isDirectory:(BOOL)isDir+{+ NSObject<CDVFileSystem> *fs = [self fileSystemByName:fsName];+ return [fs makeEntryForPath:fullPath isDirectory:isDir];+}++- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)localURL+{+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURL];+ return [fs makeEntryForLocalURL:localURL];+}++- (NSDictionary *)makeEntryForURL:(NSURL *)URL+{+ CDVFilesystemURL* fsURL = [self fileSystemURLforArg:[URL absoluteString]];+ return [self makeEntryForLocalURL:fsURL];+}++/*+ * Given a URI determine the File System information associated with it and return an appropriate W3C entry object+ * IN+ * NSString* localURI: Should be an escaped local filesystem URI+ * OUT+ * Entry object+ * bool isDirectory+ * bool isFile+ * string name+ * string fullPath+ * fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!+ */+- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command+{+ // arguments+ NSString* localURIstr = [command argumentAtIndex:0];+ CDVPluginResult* result;++ localURIstr = [self encodePath:localURIstr]; //encode path before resolving+ CDVFilesystemURL* inputURI = [self fileSystemURLforArg:localURIstr];++ if (inputURI == nil || inputURI.fileSystemName == nil) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];+ } else {+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:inputURI];+ if (fs == nil) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];+ } else {+ result = [fs entryForLocalURI:inputURI];+ }+ }+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++//encode path with percent escapes+-(NSString *)encodePath:(NSString *)path+{+ NSString *decodedPath = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //decode incase it's already encoded to avoid encoding twice+ return [decodedPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];+}+++/* Part of DirectoryEntry interface, creates or returns the specified directory+ * IN:+ * NSString* localURI - local filesystem URI for this directory+ * NSString* path - directory to be created/returned; may be full path or relative path+ * NSDictionary* - Flags object+ * boolean as NSNumber create -+ * if create is true and directory does not exist, create dir and return directory entry+ * if create is true and exclusive is true and directory does exist, return error+ * if create is false and directory does not exist, return error+ * if create is false and the path represents a file, return error+ * boolean as NSNumber exclusive - used in conjunction with create+ * if exclusive is true and create is true - specifies failure if directory already exists+ *+ *+ */+- (void)getDirectory:(CDVInvokedUrlCommand*)command+{+ NSMutableArray* arguments = [NSMutableArray arrayWithArray:command.arguments];+ NSMutableDictionary* options = nil;++ if ([arguments count] >= 3) {+ options = [command argumentAtIndex:2 withDefault:nil];+ }+ // add getDir to options and call getFile()+ if (options != nil) {+ options = [NSMutableDictionary dictionaryWithDictionary:options];+ } else {+ options = [NSMutableDictionary dictionaryWithCapacity:1];+ }+ [options setObject:[NSNumber numberWithInt:1] forKey:@"getDir"];+ if ([arguments count] >= 3) {+ [arguments replaceObjectAtIndex:2 withObject:options];+ } else {+ [arguments addObject:options];+ }+ CDVInvokedUrlCommand* subCommand =+ [[CDVInvokedUrlCommand alloc] initWithArguments:arguments+ callbackId:command.callbackId+ className:command.className+ methodName:command.methodName];++ [self getFile:subCommand];+}++/* Part of DirectoryEntry interface, creates or returns the specified file+ * IN:+ * NSString* baseURI - local filesytem URI for the base directory to search+ * NSString* requestedPath - file to be created/returned; may be absolute path or relative path+ * NSDictionary* options - Flags object+ * boolean as NSNumber create -+ * if create is true and file does not exist, create file and return File entry+ * if create is true and exclusive is true and file does exist, return error+ * if create is false and file does not exist, return error+ * if create is false and the path represents a directory, return error+ * boolean as NSNumber exclusive - used in conjunction with create+ * if exclusive is true and create is true - specifies failure if file already exists+ */+- (void)getFile:(CDVInvokedUrlCommand*)command+{+ NSString* baseURIstr = [command argumentAtIndex:0];+ CDVFilesystemURL* baseURI = [self fileSystemURLforArg:baseURIstr];+ NSString* requestedPath = [command argumentAtIndex:1];+ NSDictionary* options = [command argumentAtIndex:2 withDefault:nil];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:baseURI];+ CDVPluginResult* result = [fs getFileForURL:baseURI requestedPath:requestedPath options:options];+++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/*+ * Look up the parent Entry containing this Entry.+ * If this Entry is the root of its filesystem, its parent is itself.+ * IN:+ * NSArray* arguments+ * 0 - NSString* localURI+ * NSMutableDictionary* options+ * empty+ */+- (void)getParent:(CDVInvokedUrlCommand*)command+{+ // arguments are URL encoded+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ CDVPluginResult* result = [fs getParentForURL:localURI];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/*+ * set MetaData of entry+ * Currently we only support "com.apple.MobileBackup" (boolean)+ */+- (void)setMetadata:(CDVInvokedUrlCommand*)command+{+ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSDictionary* options = [command argumentAtIndex:1 withDefault:nil];+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ CDVPluginResult* result = [fs setMetadataForURL:localURI withObject:options];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/* removes the directory or file entry+ * IN:+ * NSArray* arguments+ * 0 - NSString* localURI+ *+ * returns NO_MODIFICATION_ALLOWED_ERR if is top level directory or no permission to delete dir+ * returns INVALID_MODIFICATION_ERR if is non-empty dir or asset library file+ * returns NOT_FOUND_ERR if file or dir is not found+*/+- (void)remove:(CDVInvokedUrlCommand*)command+{+ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ CDVPluginResult* result = nil;++ if ([localURI.fullPath isEqualToString:@""]) {+ // error if try to remove top level (documents or tmp) dir+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];+ } else {+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ result = [fs removeFileAtURL:localURI];+ }+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/* recursively removes the directory+ * IN:+ * NSArray* arguments+ * 0 - NSString* localURI+ *+ * returns NO_MODIFICATION_ALLOWED_ERR if is top level directory or no permission to delete dir+ * returns NOT_FOUND_ERR if file or dir is not found+ */+- (void)removeRecursively:(CDVInvokedUrlCommand*)command+{+ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ CDVPluginResult* result = nil;++ if ([localURI.fullPath isEqualToString:@""]) {+ // error if try to remove top level (documents or tmp) dir+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];+ } else {+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ result = [fs recursiveRemoveFileAtURL:localURI];+ }+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++- (void)copyTo:(CDVInvokedUrlCommand*)command+{+ [self doCopyMove:command isCopy:YES];+}++- (void)moveTo:(CDVInvokedUrlCommand*)command+{+ [self doCopyMove:command isCopy:NO];+}++/* Copy/move a file or directory to a new location+ * IN:+ * NSArray* arguments+ * 0 - NSString* URL of entry to copy+ * 1 - NSString* URL of the directory into which to copy/move the entry+ * 2 - Optionally, the new name of the entry, defaults to the current name+ * BOOL - bCopy YES if copy, NO if move+ */+- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy+{+ NSArray* arguments = command.arguments;++ // arguments+ NSString* srcURLstr = [command argumentAtIndex:0];+ NSString* destURLstr = [command argumentAtIndex:1];++ CDVPluginResult *result;++ if (!srcURLstr || !destURLstr) {+ // either no source or no destination provided+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ return;+ }++ CDVFilesystemURL* srcURL = [self fileSystemURLforArg:srcURLstr];+ CDVFilesystemURL* destURL = [self fileSystemURLforArg:destURLstr];++ NSObject<CDVFileSystem> *srcFs = [self filesystemForURL:srcURL];+ NSObject<CDVFileSystem> *destFs = [self filesystemForURL:destURL];++ // optional argument; use last component from srcFullPath if new name not provided+ NSString* newName = ([arguments count] > 2) ? [command argumentAtIndex:2] : [srcURL.url lastPathComponent];+ if ([newName rangeOfString:@":"].location != NSNotFound) {+ // invalid chars in new name+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ENCODING_ERR];+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ return;+ }++ __weak CDVFile* weakSelf = self;+ [self.commandDelegate runInBackground:^ {+ [destFs copyFileToURL:destURL withName:newName fromFileSystem:srcFs atURL:srcURL copy:bCopy callback:^(CDVPluginResult* result) {+ [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ }];+ }];++}++- (void)getFileMetadata:(CDVInvokedUrlCommand*)command+{+ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ __weak CDVFile* weakSelf = self;+ [fs getFileMetadataForURL:localURI callback:^(CDVPluginResult* result) {+ [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ }];+}++- (void)readEntries:(CDVInvokedUrlCommand*)command+{+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ CDVPluginResult *result = [fs readEntriesAtURL:localURI];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/* read and return file data+ * IN:+ * NSArray* arguments+ * 0 - NSString* fullPath+ * 1 - NSString* encoding+ * 2 - NSString* start+ * 3 - NSString* end+ */+- (void)readAsText:(CDVInvokedUrlCommand*)command+{+ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSString* encoding = [command argumentAtIndex:1];+ NSInteger start = [[command argumentAtIndex:2] integerValue];+ NSInteger end = [[command argumentAtIndex:3] integerValue];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];++ if (fs == nil) {+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ return;+ }++ // TODO: implement+ if ([@"UTF-8" caseInsensitiveCompare : encoding] != NSOrderedSame) {+ NSLog(@"Only UTF-8 encodings are currently supported by readAsText");+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ENCODING_ERR];+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ return;+ }++ __weak CDVFile* weakSelf = self;++ [self.commandDelegate runInBackground:^ {+ [fs readFileAtURL:localURI start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {+ CDVPluginResult* result = nil;+ if (data != nil) {+ NSString* str = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSUTF8StringEncoding freeWhenDone:NO];+ // Check that UTF8 conversion did not fail.+ if (str != nil) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:str];+ result.associatedObject = data;+ } else {+ errorCode = ENCODING_ERR;+ }+ }+ if (result == nil) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }++ [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ }];+ }];+}++/* Read content of text file and return as base64 encoded data url.+ * IN:+ * NSArray* arguments+ * 0 - NSString* fullPath+ * 1 - NSString* start+ * 2 - NSString* end+ *+ * Determines the mime type from the file extension, returns ENCODING_ERR if mimetype can not be determined.+ */++- (void)readAsDataURL:(CDVInvokedUrlCommand*)command+{+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSInteger start = [[command argumentAtIndex:1] integerValue];+ NSInteger end = [[command argumentAtIndex:2] integerValue];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];++ __weak CDVFile* weakSelf = self;+ [self.commandDelegate runInBackground:^ {+ [fs readFileAtURL:localURI start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {+ CDVPluginResult* result = nil;+ if (data != nil) {+ NSString* b64Str = toBase64(data);+ NSString* output = [NSString stringWithFormat:@"data:%@;base64,%@", mimeType, b64Str];+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:output];+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }++ [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ }];+ }];+}++/* Read content of text file and return as an arraybuffer+ * IN:+ * NSArray* arguments+ * 0 - NSString* fullPath+ * 1 - NSString* start+ * 2 - NSString* end+ */++- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command+{+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSInteger start = [[command argumentAtIndex:1] integerValue];+ NSInteger end = [[command argumentAtIndex:2] integerValue];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];++ __weak CDVFile* weakSelf = self;++ [self.commandDelegate runInBackground:^ {+ [fs readFileAtURL:localURI start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {+ CDVPluginResult* result = nil;+ if (data != nil) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArrayBuffer:data];+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }++ [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ }];+ }];+}++- (void)readAsBinaryString:(CDVInvokedUrlCommand*)command+{+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ NSInteger start = [[command argumentAtIndex:1] integerValue];+ NSInteger end = [[command argumentAtIndex:2] integerValue];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];++ __weak CDVFile* weakSelf = self;++ [self.commandDelegate runInBackground:^ {+ [fs readFileAtURL:localURI start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {+ CDVPluginResult* result = nil;+ if (data != nil) {+ NSString* payload = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSASCIIStringEncoding freeWhenDone:NO];+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload];+ result.associatedObject = data;+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }++ [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];+ }];+ }];+}+++- (void)truncate:(CDVInvokedUrlCommand*)command+{+ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ unsigned long long pos = (unsigned long long)[[command argumentAtIndex:1] longLongValue];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+ CDVPluginResult *result = [fs truncateFileAtURL:localURI atPosition:pos];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++/* write+ * IN:+ * NSArray* arguments+ * 0 - NSString* localURI of file to write to+ * 1 - NSString* or NSData* data to write+ * 2 - NSNumber* position to begin writing+ */+- (void)write:(CDVInvokedUrlCommand*)command+{+ __weak CDVFile* weakSelf = self;++ [self.commandDelegate runInBackground:^ {+ NSString* callbackId = command.callbackId;++ // arguments+ CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]];+ id argData = [command argumentAtIndex:1];+ unsigned long long pos = (unsigned long long)[[command argumentAtIndex:2] longLongValue];++ NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI];+++ [fs truncateFileAtURL:localURI atPosition:pos];+ CDVPluginResult *result;+ if ([argData isKindOfClass:[NSString class]]) {+ NSData *encData = [argData dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];+ result = [fs writeToFileAtURL:localURI withData:encData append:YES];+ } else if ([argData isKindOfClass:[NSData class]]) {+ result = [fs writeToFileAtURL:localURI withData:argData append:YES];+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid parameter type"];+ }+ [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];+ }];+}++#pragma mark Methods for converting between URLs and paths++- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)localURL+{+ for (NSObject<CDVFileSystem> *fs in self.fileSystems) {+ if ([fs.name isEqualToString:localURL.fileSystemName]) {+ if ([fs respondsToSelector:@selector(filesystemPathForURL:)]) {+ return [fs filesystemPathForURL:localURL];+ }+ }+ }+ return nil;+}++#pragma mark Undocumented Filesystem API++- (void)testFileExists:(CDVInvokedUrlCommand*)command+{+ // arguments+ NSString* argPath = [command argumentAtIndex:0];++ // Get the file manager+ NSFileManager* fMgr = [NSFileManager defaultManager];+ NSString* appFile = argPath; // [ self getFullPath: argPath];++ BOOL bExists = [fMgr fileExistsAtPath:appFile];+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(bExists ? 1 : 0)];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command+{+ // arguments+ NSString* argPath = [command argumentAtIndex:0];++ // Get the file manager+ NSFileManager* fMgr = [[NSFileManager alloc] init];+ NSString* appFile = argPath; // [self getFullPath: argPath];+ BOOL bIsDir = NO;+ BOOL bExists = [fMgr fileExistsAtPath:appFile isDirectory:&bIsDir];++ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:((bExists && bIsDir) ? 1 : 0)];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++// Returns number of bytes available via callback+- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command+{+ // no arguments++ NSNumber* pNumAvail = [self checkFreeDiskSpace:self.rootDocsPath];++ NSString* strFreeSpace = [NSString stringWithFormat:@"%qu", [pNumAvail unsignedLongLongValue]];+ // NSLog(@"Free space is %@", strFreeSpace );++ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:strFreeSpace];++ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++#pragma mark Compatibility with older File API++- (NSString*)getMimeTypeFromPath:(NSString*)fullPath+{+ return [CDVLocalFilesystem getMimeTypeFromPath:fullPath];+}++- (NSDictionary *)getDirectoryEntry:(NSString *)localPath isDirectory:(BOOL)bDirRequest+{+ CDVFilesystemURL *localURL = [self fileSystemURLforLocalPath:localPath];+ return [self makeEntryForPath:localURL.fullPath fileSystemName:localURL.fileSystemName isDirectory:bDirRequest];+}++#pragma mark Internal methods for testing+// Internal methods for testing: Get the on-disk location of a local filesystem url.+// [Currently used for testing file-transfer]++- (void)_getLocalFilesystemPath:(CDVInvokedUrlCommand*)command+{+ CDVFilesystemURL* localURL = [self fileSystemURLforArg:command.arguments[0]];++ NSString* fsPath = [self filesystemPathForURL:localURL];+ CDVPluginResult* result;+ if (fsPath) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:fsPath];+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Cannot resolve URL to a file"];+ }+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];+}++@enddiff --git a/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVLocalFilesystem.h b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVLocalFilesystem.hnew file mode 100644index 000000000..a0186c853--- /dev/null+++ b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVLocalFilesystem.h@@ -0,0 +1,32 @@+/*+ Licensed to the Apache Software Foundation (ASF) under one+ or more contributor license agreements. See the NOTICE file+ distributed with this work for additional information+ regarding copyright ownership. The ASF licenses this file+ to you under the Apache License, Version 2.0 (the+ "License"); you may not use this file except in compliance+ with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing,+ software distributed under the License is distributed on an+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ KIND, either express or implied. See the License for the+ specific language governing permissions and limitations+ under the License.+ */++#import "CDVFile.h"++@interface CDVLocalFilesystem : NSObject<CDVFileSystem> {+ NSString *_name;+ NSString *_fsRoot;+}++- (id) initWithName:(NSString *)name root:(NSString *)fsRoot;++ (NSString*)getMimeTypeFromPath:(NSString*)fullPath;++@property (nonatomic,strong) NSString *fsRoot;++@enddiff --git a/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVLocalFilesystem.m b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVLocalFilesystem.mnew file mode 100644index 000000000..ddc77404d--- /dev/null+++ b/cordova/platforms/ios/TagSpaces/Plugins/cordova-plugin-file/CDVLocalFilesystem.m@@ -0,0 +1,750 @@+/*+ Licensed to the Apache Software Foundation (ASF) under one+ or more contributor license agreements. See the NOTICE file+ distributed with this work for additional information+ regarding copyright ownership. The ASF licenses this file+ to you under the Apache License, Version 2.0 (the+ "License"); you may not use this file except in compliance+ with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing,+ software distributed under the License is distributed on an+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ KIND, either express or implied. See the License for the+ specific language governing permissions and limitations+ under the License.+ */++#import "CDVFile.h"+#import "CDVLocalFilesystem.h"+#import <Cordova/CDV.h>+#import <MobileCoreServices/MobileCoreServices.h>+#import <sys/xattr.h>++@implementation CDVLocalFilesystem+@synthesize name=_name, fsRoot=_fsRoot, urlTransformer;++- (id) initWithName:(NSString *)name root:(NSString *)fsRoot+{+ if (self) {+ self.name = name;+ self.fsRoot = fsRoot;+ }+ return self;+}++/*+ * IN+ * NSString localURI+ * OUT+ * CDVPluginResult result containing a file or directoryEntry for the localURI, or an error if the+ * URI represents a non-existent path, or is unrecognized or otherwise malformed.+ */+- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url+{+ CDVPluginResult* result = nil;+ NSDictionary* entry = [self makeEntryForLocalURL:url];+ if (entry) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:entry];+ } else {+ // return NOT_FOUND_ERR+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];+ }+ return result;+}+- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url {+ NSString *path = [self filesystemPathForURL:url];+ NSFileManager* fileMgr = [[NSFileManager alloc] init];+ BOOL isDir = NO;+ // see if exists and is file or dir+ BOOL bExists = [fileMgr fileExistsAtPath:path isDirectory:&isDir];+ if (bExists) {+ return [self makeEntryForPath:url.fullPath isDirectory:isDir];+ } else {+ return nil;+ }+}+- (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir+{+ NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:5];+ NSString* lastPart = [[self stripQueryParametersFromPath:fullPath] lastPathComponent];+ if (isDir && ![fullPath hasSuffix:@"/"]) {+ fullPath = [fullPath stringByAppendingString:@"/"];+ }+ [dirEntry setObject:[NSNumber numberWithBool:!isDir] forKey:@"isFile"];+ [dirEntry setObject:[NSNumber numberWithBool:isDir] forKey:@"isDirectory"];+ [dirEntry setObject:fullPath forKey:@"fullPath"];+ [dirEntry setObject:lastPart forKey:@"name"];+ [dirEntry setObject:self.name forKey: @"filesystemName"];++ NSURL* nativeURL = [NSURL fileURLWithPath:[self filesystemPathForFullPath:fullPath]];+ if (self.urlTransformer) {+ nativeURL = self.urlTransformer(nativeURL);+ }++ dirEntry[@"nativeURL"] = [nativeURL absoluteString];++ return dirEntry;+}++- (NSString *)stripQueryParametersFromPath:(NSString *)fullPath+{+ NSRange questionMark = [fullPath rangeOfString:@"?"];+ if (questionMark.location != NSNotFound) {+ return [fullPath substringWithRange:NSMakeRange(0,questionMark.location)];+ }+ return fullPath;+}++- (NSString *)filesystemPathForFullPath:(NSString *)fullPath+{+ NSString *path = nil;+ NSString *strippedFullPath = [self stripQueryParametersFromPath:fullPath];+ path = [NSString stringWithFormat:@"%@%@", self.fsRoot, strippedFullPath];+ if ([path length] > 1 && [path hasSuffix:@"/"]) {+ path = [path substringToIndex:([path length]-1)];+ }+ return path;+}+/*+ * IN+ * NSString localURI+ * OUT+ * NSString full local filesystem path for the represented file or directory, or nil if no such path is possible+ * The file or directory does not necessarily have to exist. nil is returned if the filesystem type is not recognized,+ * or if the URL is malformed.+ * The incoming URI should be properly escaped (no raw spaces, etc. URI percent-encoding is expected).+ */+- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)url+{+ return [self filesystemPathForFullPath:url.fullPath];+}++- (CDVFilesystemURL *)URLforFullPath:(NSString *)fullPath+{+ if (fullPath) {+ NSString* escapedPath = [fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];+ if ([fullPath hasPrefix:@"/"]) {+ return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, escapedPath]];+ }+ return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@/%@", kCDVFilesystemURLPrefix, self.name, escapedPath]];+ }+ return nil;+}++- (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path+{+ return [self URLforFullPath:[self fullPathForFileSystemPath:path]];++}++- (NSString *)normalizePath:(NSString *)rawPath+{+ // If this is an absolute path, the first path component will be '/'. Skip it if that's the case+ BOOL isAbsolutePath = [rawPath hasPrefix:@"/"];+ if (isAbsolutePath) {+ rawPath = [rawPath substringFromIndex:1];+ }+ NSMutableArray *components = [NSMutableArray arrayWithArray:[rawPath pathComponents]];+ for (int index = 0; index < [components count]; ++index) {+ if ([[components objectAtIndex:index] isEqualToString:@".."]) {+ [components removeObjectAtIndex:index];+ if (index > 0) {+ [components removeObjectAtIndex:index-1];+ --index;+ }+ }+ }++ if (isAbsolutePath) {+ return [NSString stringWithFormat:@"/%@", [components componentsJoinedByString:@"/"]];+ } else {+ return [components componentsJoinedByString:@"/"];+ }+++}++- (BOOL)valueForKeyIsNumber:(NSDictionary*)dict key:(NSString*)key+{+ BOOL bNumber = NO;+ NSObject* value = dict[key];+ if (value) {+ bNumber = [value isKindOfClass:[NSNumber class]];+ }+ return bNumber;+}++- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options+{+ CDVPluginResult* result = nil;+ BOOL bDirRequest = NO;+ BOOL create = NO;+ BOOL exclusive = NO;+ int errorCode = 0; // !!! risky - no error code currently defined for 0++ if ([self valueForKeyIsNumber:options key:@"create"]) {+ create = [(NSNumber*)[options valueForKey:@"create"] boolValue];+ }+ if ([self valueForKeyIsNumber:options key:@"exclusive"]) {+ exclusive = [(NSNumber*)[options valueForKey:@"exclusive"] boolValue];+ }+ if ([self valueForKeyIsNumber:options key:@"getDir"]) {+ // this will not exist for calls directly to getFile but will have been set by getDirectory before calling this method+ bDirRequest = [(NSNumber*)[options valueForKey:@"getDir"] boolValue];+ }+ // see if the requested path has invalid characters - should we be checking for more than just ":"?+ if ([requestedPath rangeOfString:@":"].location != NSNotFound) {+ errorCode = ENCODING_ERR;+ } else {+ // Build new fullPath for the requested resource.+ // We concatenate the two paths together, and then scan the resulting string to remove+ // parent ("..") references. Any parent references at the beginning of the string are+ // silently removed.+ NSString *combinedPath = [baseURI.fullPath stringByAppendingPathComponent:requestedPath];+ combinedPath = [self normalizePath:combinedPath];+ CDVFilesystemURL* requestedURL = [self URLforFullPath:combinedPath];++ NSFileManager* fileMgr = [[NSFileManager alloc] init];+ BOOL bIsDir;+ BOOL bExists = [fileMgr fileExistsAtPath:[self filesystemPathForURL:requestedURL] isDirectory:&bIsDir];+ if (bExists && (create == NO) && (bIsDir == !bDirRequest)) {+ // path exists and is not of requested type - return TYPE_MISMATCH_ERR+ errorCode = TYPE_MISMATCH_ERR;+ } else if (!bExists && (create == NO)) {+ // path does not exist and create is false - return NOT_FOUND_ERR+ errorCode = NOT_FOUND_ERR;+ } else if (bExists && (create == YES) && (exclusive == YES)) {+ // file/dir already exists and exclusive and create are both true - return PATH_EXISTS_ERR+ errorCode = PATH_EXISTS_ERR;+ } else {+ // if bExists and create == YES - just return data+ // if bExists and create == NO - just return data+ // if !bExists and create == YES - create and return data+ BOOL bSuccess = YES;+ NSError __autoreleasing* pError = nil;+ if (!bExists && (create == YES)) {+ if (bDirRequest) {+ // create the dir+ bSuccess = [fileMgr createDirectoryAtPath:[self filesystemPathForURL:requestedURL] withIntermediateDirectories:NO attributes:nil error:&pError];+ } else {+ // create the empty file+ bSuccess = [fileMgr createFileAtPath:[self filesystemPathForURL:requestedURL] contents:nil attributes:nil];+ }+ }+ if (!bSuccess) {+ errorCode = ABORT_ERR;+ if (pError) {+ NSLog(@"error creating directory: %@", [pError localizedDescription]);+ }+ } else {+ // NSLog(@"newly created file/dir (%@) exists: %d", reqFullPath, [fileMgr fileExistsAtPath:reqFullPath]);+ // file existed or was created+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self makeEntryForPath:requestedURL.fullPath isDirectory:bDirRequest]];+ }+ } // are all possible conditions met?+ }++ if (errorCode > 0) {+ // create error callback+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }+ return result;++}++- (CDVPluginResult*)getParentForURL:(CDVFilesystemURL *)localURI+{+ CDVPluginResult* result = nil;+ CDVFilesystemURL *newURI = nil;+ if ([localURI.fullPath isEqualToString:@""]) {+ // return self+ newURI = localURI;+ } else {+ newURI = [CDVFilesystemURL fileSystemURLWithURL:[localURI.url URLByDeletingLastPathComponent]]; /* TODO: UGLY - FIX */+ }+ NSFileManager* fileMgr = [[NSFileManager alloc] init];+ BOOL bIsDir;+ BOOL bExists = [fileMgr fileExistsAtPath:[self filesystemPathForURL:newURI] isDirectory:&bIsDir];+ if (bExists) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self makeEntryForPath:newURI.fullPath isDirectory:bIsDir]];+ } else {+ // invalid path or file does not exist+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];+ }+ return result;+}++- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options+{+ BOOL ok = NO;++ NSString* filePath = [self filesystemPathForURL:localURI];+ // we only care about this iCloud key for now.+ // set to 1/true to skip backup, set to 0/false to back it up (effectively removing the attribute)+ NSString* iCloudBackupExtendedAttributeKey = @"com.apple.MobileBackup";+ id iCloudBackupExtendedAttributeValue = [options objectForKey:iCloudBackupExtendedAttributeKey];++ if ((iCloudBackupExtendedAttributeValue != nil) && [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]]) {+ if (IsAtLeastiOSVersion(@"5.1")) {+ NSURL* url = [NSURL fileURLWithPath:filePath];+ NSError* __autoreleasing error = nil;++ ok = [url setResourceValue:[NSNumber numberWithBool:[iCloudBackupExtendedAttributeValue boolValue]] forKey:NSURLIsExcludedFromBackupKey error:&error];+ } else { // below 5.1 (deprecated - only really supported in 5.01)+ u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];+ if (value == 0) { // remove the attribute (allow backup, the default)+ ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);+ } else { // set the attribute (skip backup)+ ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);+ }+ }+ }++ if (ok) {+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];+ } else {+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];+ }+}++/* remove the file or directory (recursively)+ * IN:+ * NSString* fullPath - the full path to the file or directory to be removed+ * NSString* callbackId+ * called from remove and removeRecursively - check all pubic api specific error conditions (dir not empty, etc) before calling+ */++- (CDVPluginResult*)doRemove:(NSString*)fullPath+{+ CDVPluginResult* result = nil;+ BOOL bSuccess = NO;+ NSError* __autoreleasing pError = nil;+ NSFileManager* fileMgr = [[NSFileManager alloc] init];++ @try {+ bSuccess = [fileMgr removeItemAtPath:fullPath error:&pError];+ if (bSuccess) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];+ } else {+ // see if we can give a useful error+ CDVFileError errorCode = ABORT_ERR;+ NSLog(@"error removing filesystem entry at %@: %@", fullPath, [pError localizedDescription]);+ if ([pError code] == NSFileNoSuchFileError) {+ errorCode = NOT_FOUND_ERR;+ } else if ([pError code] == NSFileWriteNoPermissionError) {+ errorCode = NO_MODIFICATION_ALLOWED_ERR;+ }++ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }+ } @catch(NSException* e) { // NSInvalidArgumentException if path is . or ..+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SYNTAX_ERR];+ }++ return result;+}++- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI+{+ NSString *fileSystemPath = [self filesystemPathForURL:localURI];++ NSFileManager* fileMgr = [[NSFileManager alloc] init];+ BOOL bIsDir = NO;+ BOOL bExists = [fileMgr fileExistsAtPath:fileSystemPath isDirectory:&bIsDir];+ if (!bExists) {+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];+ }+ if (bIsDir && ([[fileMgr contentsOfDirectoryAtPath:fileSystemPath error:nil] count] != 0)) {+ // dir is not empty+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:INVALID_MODIFICATION_ERR];+ }+ return [self doRemove:fileSystemPath];+}++- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI+{+ NSString *fileSystemPath = [self filesystemPathForURL:localURI];+ return [self doRemove:fileSystemPath];+}++/*+ * IN+ * NSString localURI+ * OUT+ * NSString full local filesystem path for the represented file or directory, or nil if no such path is possible+ * The file or directory does not necessarily have to exist. nil is returned if the filesystem type is not recognized,+ * or if the URL is malformed.+ * The incoming URI should be properly escaped (no raw spaces, etc. URI percent-encoding is expected).+ */+- (NSString *)fullPathForFileSystemPath:(NSString *)fsPath+{+ if ([fsPath hasPrefix:self.fsRoot]) {+ return [fsPath substringFromIndex:[self.fsRoot length]];+ }+ return nil;+}+++- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI+{+ NSFileManager* fileMgr = [[NSFileManager alloc] init];+ NSError* __autoreleasing error = nil;+ NSString *fileSystemPath = [self filesystemPathForURL:localURI];++ NSArray* contents = [fileMgr contentsOfDirectoryAtPath:fileSystemPath error:&error];++ if (contents) {+ NSMutableArray* entries = [NSMutableArray arrayWithCapacity:1];+ if ([contents count] > 0) {+ // create an Entry (as JSON) for each file/dir+ for (NSString* name in contents) {+ // see if is dir or file+ NSString* entryPath = [fileSystemPath stringByAppendingPathComponent:name];+ BOOL bIsDir = NO;+ [fileMgr fileExistsAtPath:entryPath isDirectory:&bIsDir];+ NSDictionary* entryDict = [self makeEntryForPath:[self fullPathForFileSystemPath:entryPath] isDirectory:bIsDir];+ [entries addObject:entryDict];+ }+ }+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:entries];+ } else {+ // assume not found but could check error for more specific error conditions+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];+ }+}++- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos+{+ unsigned long long newPos = 0UL;++ NSFileHandle* file = [NSFileHandle fileHandleForWritingAtPath:filePath];++ if (file) {+ [file truncateFileAtOffset:(unsigned long long)pos];+ newPos = [file offsetInFile];+ [file synchronizeFile];+ [file closeFile];+ }+ return newPos;+}++- (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos+{+ unsigned long long newPos = [self truncateFile:[self filesystemPathForURL:localURI] atPosition:pos];+ return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)newPos];+}++- (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend+{+ NSString *filePath = [self filesystemPathForURL:localURL];++ CDVPluginResult* result = nil;+ CDVFileError errCode = INVALID_MODIFICATION_ERR;+ int bytesWritten = 0;++ if (filePath) {+ NSOutputStream* fileStream = [NSOutputStream outputStreamToFileAtPath:filePath append:shouldAppend];+ if (fileStream) {+ NSUInteger len = [encData length];+ if (len == 0) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:(double)len];+ } else {+ [fileStream open];++ bytesWritten = (int)[fileStream write:[encData bytes] maxLength:len];++ [fileStream close];+ if (bytesWritten > 0) {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];+ // } else {+ // can probably get more detailed error info via [fileStream streamError]+ // errCode already set to INVALID_MODIFICATION_ERR;+ // bytesWritten = 0; // may be set to -1 on error+ }+ }+ } // else fileStream not created return INVALID_MODIFICATION_ERR+ } else {+ // invalid filePath+ errCode = NOT_FOUND_ERR;+ }+ if (!result) {+ // was an error+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];+ }+ return result;+}++/**+ * Helper function to check to see if the user attempted to copy an entry into its parent without changing its name,+ * or attempted to copy a directory into a directory that it contains directly or indirectly.+ *+ * IN:+ * NSString* srcDir+ * NSString* destinationDir+ * OUT:+ * YES copy/ move is allows+ * NO move is onto itself+ */+- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest+{+ // This weird test is to determine if we are copying or moving a directory into itself.+ // Copy /Documents/myDir to /Documents/myDir-backup is okay but+ // Copy /Documents/myDir to /Documents/myDir/backup not okay+ BOOL copyOK = YES;+ NSRange range = [dest rangeOfString:src];++ if (range.location != NSNotFound) {+ NSRange testRange = {range.length - 1, ([dest length] - range.length)};+ NSRange resultRange = [dest rangeOfString:@"/" options:0 range:testRange];+ if (resultRange.location != NSNotFound) {+ copyOK = NO;+ }+ }+ return copyOK;+}++- (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback+{+ NSFileManager *fileMgr = [[NSFileManager alloc] init];+ NSString *destRootPath = [self filesystemPathForURL:destURL];+ BOOL bDestIsDir = NO;+ BOOL bDestExists = [fileMgr fileExistsAtPath:destRootPath isDirectory:&bDestIsDir];++ NSString *newFileSystemPath = [destRootPath stringByAppendingPathComponent:newName];+ NSString *newFullPath = [self fullPathForFileSystemPath:newFileSystemPath];++ BOOL bNewIsDir = NO;+ BOOL bNewExists = [fileMgr fileExistsAtPath:newFileSystemPath isDirectory:&bNewIsDir];++ CDVPluginResult *result = nil;+ int errCode = 0;++ if (!bDestExists) {+ // the destination root does not exist+ errCode = NOT_FOUND_ERR;+ }++ else if ([srcFs isKindOfClass:[CDVLocalFilesystem class]]) {+ /* Same FS, we can shortcut with NSFileManager operations */+ NSString *srcFullPath = [srcFs filesystemPathForURL:srcURL];++ BOOL bSrcIsDir = NO;+ BOOL bSrcExists = [fileMgr fileExistsAtPath:srcFullPath isDirectory:&bSrcIsDir];++ if (!bSrcExists) {+ // the source does not exist+ errCode = NOT_FOUND_ERR;+ } else if ([newFileSystemPath isEqualToString:srcFullPath]) {+ // source and destination can not be the same+ errCode = INVALID_MODIFICATION_ERR;+ } else if (bSrcIsDir && (bNewExists && !bNewIsDir)) {+ // can't copy/move dir to file+ errCode = INVALID_MODIFICATION_ERR;+ } else { // no errors yet+ NSError* __autoreleasing error = nil;+ BOOL bSuccess = NO;+ if (bCopy) {+ if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFileSystemPath]) {+ // can't copy dir into self+ errCode = INVALID_MODIFICATION_ERR;+ } else if (bNewExists) {+ // the full destination should NOT already exist if a copy+ errCode = PATH_EXISTS_ERR;+ } else {+ bSuccess = [fileMgr copyItemAtPath:srcFullPath toPath:newFileSystemPath error:&error];+ }+ } else { // move+ // iOS requires that destination must not exist before calling moveTo+ // is W3C INVALID_MODIFICATION_ERR error if destination dir exists and has contents+ //+ if (!bSrcIsDir && (bNewExists && bNewIsDir)) {+ // can't move a file to directory+ errCode = INVALID_MODIFICATION_ERR;+ } else if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFileSystemPath]) {+ // can't move a dir into itself+ errCode = INVALID_MODIFICATION_ERR;+ } else if (bNewExists) {+ if (bNewIsDir && ([[fileMgr contentsOfDirectoryAtPath:newFileSystemPath error:NULL] count] != 0)) {+ // can't move dir to a dir that is not empty+ errCode = INVALID_MODIFICATION_ERR;+ newFileSystemPath = nil; // so we won't try to move+ } else {+ // remove destination so can perform the moveItemAtPath+ bSuccess = [fileMgr removeItemAtPath:newFileSystemPath error:NULL];+ if (!bSuccess) {+ errCode = INVALID_MODIFICATION_ERR; // is this the correct error?+ newFileSystemPath = nil;+ }+ }+ } else if (bNewIsDir && [newFileSystemPath hasPrefix:srcFullPath]) {+ // can't move a directory inside itself or to any child at any depth;+ errCode = INVALID_MODIFICATION_ERR;+ newFileSystemPath = nil;+ }++ if (newFileSystemPath != nil) {+ bSuccess = [fileMgr moveItemAtPath:srcFullPath toPath:newFileSystemPath error:&error];+ }+ }+ if (bSuccess) {+ // should verify it is there and of the correct type???+ NSDictionary* newEntry = [self makeEntryForPath:newFullPath isDirectory:bSrcIsDir];+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];+ } else {+ if (error) {+ if (([error code] == NSFileReadUnknownError) || ([error code] == NSFileReadTooLargeError)) {+ errCode = NOT_READABLE_ERR;+ } else if ([error code] == NSFileWriteOutOfSpaceError) {+ errCode = QUOTA_EXCEEDED_ERR;+ } else if ([error code] == NSFileWriteNoPermissionError) {+ errCode = NO_MODIFICATION_ALLOWED_ERR;+ }+ }+ }+ }+ } else {+ // Need to copy the hard way+ [srcFs readFileAtURL:srcURL start:0 end:-1 callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {+ CDVPluginResult* result = nil;+ if (data != nil) {+ BOOL bSuccess = [data writeToFile:newFileSystemPath atomically:YES];+ if (bSuccess) {+ // should verify it is there and of the correct type???+ NSDictionary* newEntry = [self makeEntryForPath:newFullPath isDirectory:NO];+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ABORT_ERR];+ }+ } else {+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];+ }+ callback(result);+ }];+ return; // Async IO; return without callback.+ }+ if (result == nil) {+ if (!errCode) {+ errCode = INVALID_MODIFICATION_ERR; // Catch-all default+ }+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errCode];+ }+ callback(result);+}++/* helper function to get the mimeType from the file extension+ * IN:+ * NSString* fullPath - filename (may include path)+ * OUT:+ * NSString* the mime type as type/subtype. nil if not able to determine+ */++ (NSString*)getMimeTypeFromPath:(NSString*)fullPath+{+ NSString* mimeType = nil;++ if (fullPath) {+ CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);+ if (typeId) {+ mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);+ if (!mimeType) {+ // special case for m4a+ if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {+ mimeType = @"audio/mp4";+ } else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {+ mimeType = @"audio/wav";+ } else if ([[fullPath pathExtension] rangeOfString:@"css"].location != NSNotFound) {+ mimeType = @"text/css";+ }+ }+ CFRelease(typeId);+ }+ }+ return mimeType;+}++- (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback+{+ NSString *path = [self filesystemPathForURL:localURL];++ NSString* mimeType = [CDVLocalFilesystem getMimeTypeFromPath:path];+ if (mimeType == nil) {+ mimeType = @"*/*";+ }+ NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:path];+ if (start > 0) {+ [file seekToFileOffset:start];+ }++ NSData* readData;+ if (end < 0) {+ readData = [file readDataToEndOfFile];+ } else {+ readData = [file readDataOfLength:(end - start)];+ }+ [file closeFile];++ callback(readData, mimeType, readData != nil ? NO_ERROR : NOT_FOUND_ERR);+}++- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback+{+ NSString *path = [self filesystemPathForURL:localURL];+ CDVPluginResult *result;+ NSFileManager* fileMgr = [[NSFileManager alloc] init];++ NSError* __autoreleasing error = nil;+ NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:path error:&error];++ if (fileAttrs) {++ // create dictionary of file info+ NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];++ [fileInfo setObject:localURL.fullPath forKey:@"fullPath"];+ [fileInfo setObject:[self mimeTypeForFileAtPath: path] forKey:@"type"];+ [fileInfo setObject:[path lastPathComponent] forKey:@"name"];++ // Ensure that directories (and other non-regular files) report size of 0+ unsigned long long size = ([fileAttrs fileType] == NSFileTypeRegular ? [fileAttrs fileSize] : 0);+ [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:size] forKey:@"size"];++ NSDate* modDate = [fileAttrs fileModificationDate];+ if (modDate) {+ [fileInfo setObject:[NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000] forKey:@"lastModifiedDate"];+ }++ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];++ } else {+ // didn't get fileAttribs+ CDVFileError errorCode = ABORT_ERR;+ NSLog(@"error getting metadata: %@", [error localizedDescription]);+ if ([error code] == NSFileNoSuchFileError || [error code] == NSFileReadNoSuchFileError) {+ errorCode = NOT_FOUND_ERR;+ }+ // log [NSNumber numberWithDouble: theMessage] objCtype to see what it returns+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode];+ }++ callback(result);+}++// fix errors that base on Alexsander Akers from http://stackoverflow.com/a/5998683/2613194+- (NSString*) mimeTypeForFileAtPath: (NSString *) path {+ if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {+ return nil;+ }++ CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[path pathExtension], NULL);+ CFStringRef mimeType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);+ CFRelease(UTI);++ if (!mimeType) {+ return @"application/octet-stream";+ }+ return (__bridge NSString *)mimeType;+}++@enddiff --git a/cordova/platforms/ios/TagSpaces/config.xml b/cordova/platforms/ios/TagSpaces/config.xmlindex 58650aa63..337e6475d 100644--- a/cordova/platforms/ios/TagSpaces/config.xml+++ b/cordova/platforms/ios/TagSpaces/config.xml@@ -28,6 +28,10 @@<feature name="Downloader"><param name="ios-package" value="Downloader" /></feature>+ <feature name="File">+ <param name="ios-package" value="CDVFile" />+ <param name="onload" value="true" />+ </feature><name>TagSpaces</name><description>Offline file organizer and browser with tagging support.diff --git a/cordova/platforms/ios/ios.json b/cordova/platforms/ios/ios.jsonindex 70525d143..b4a43f97c 100644--- a/cordova/platforms/ios/ios.json+++ b/cordova/platforms/ios/ios.json@@ -11,6 +11,10 @@{"xml": "<feature name=\"Downloader\"><param name=\"ios-package\" value=\"Downloader\" /></feature>","count": 1+ },+ {+ "xml": "<feature name=\"File\"><param name=\"ios-package\" value=\"CDVFile\" /><param name=\"onload\" value=\"true\" /></feature>",+ "count": 1}]}@@ -23,6 +27,9 @@},"cordova-plugin-androidx": {"PACKAGE_NAME": "org.tagspaces.mobile"+ },+ "cordova-plugin-file": {+ "PACKAGE_NAME": "org.tagspaces.mobile"}},"dependent_plugins": {},@@ -34,10 +41,184 @@"clobbers": ["plugins.Downloader"]+ },+ {+ "id": "cordova-plugin-file.DirectoryEntry",+ "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.DirectoryEntry"+ ]+ },+ {+ "id": "cordova-plugin-file.DirectoryReader",+ "file": "plugins/cordova-plugin-file/www/DirectoryReader.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.DirectoryReader"+ ]+ },+ {+ "id": "cordova-plugin-file.Entry",+ "file": "plugins/cordova-plugin-file/www/Entry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Entry"+ ]+ },+ {+ "id": "cordova-plugin-file.File",+ "file": "plugins/cordova-plugin-file/www/File.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.File"+ ]+ },+ {+ "id": "cordova-plugin-file.FileEntry",+ "file": "plugins/cordova-plugin-file/www/FileEntry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileEntry"+ ]+ },+ {+ "id": "cordova-plugin-file.FileError",+ "file": "plugins/cordova-plugin-file/www/FileError.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileError"+ ]+ },+ {+ "id": "cordova-plugin-file.FileReader",+ "file": "plugins/cordova-plugin-file/www/FileReader.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileReader"+ ]+ },+ {+ "id": "cordova-plugin-file.FileSystem",+ "file": "plugins/cordova-plugin-file/www/FileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.FileUploadOptions",+ "file": "plugins/cordova-plugin-file/www/FileUploadOptions.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileUploadOptions"+ ]+ },+ {+ "id": "cordova-plugin-file.FileUploadResult",+ "file": "plugins/cordova-plugin-file/www/FileUploadResult.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileUploadResult"+ ]+ },+ {+ "id": "cordova-plugin-file.FileWriter",+ "file": "plugins/cordova-plugin-file/www/FileWriter.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileWriter"+ ]+ },+ {+ "id": "cordova-plugin-file.Flags",+ "file": "plugins/cordova-plugin-file/www/Flags.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Flags"+ ]+ },+ {+ "id": "cordova-plugin-file.LocalFileSystem",+ "file": "plugins/cordova-plugin-file/www/LocalFileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.LocalFileSystem"+ ],+ "merges": [+ "window"+ ]+ },+ {+ "id": "cordova-plugin-file.Metadata",+ "file": "plugins/cordova-plugin-file/www/Metadata.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Metadata"+ ]+ },+ {+ "id": "cordova-plugin-file.ProgressEvent",+ "file": "plugins/cordova-plugin-file/www/ProgressEvent.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.ProgressEvent"+ ]+ },+ {+ "id": "cordova-plugin-file.fileSystems",+ "file": "plugins/cordova-plugin-file/www/fileSystems.js",+ "pluginId": "cordova-plugin-file"+ },+ {+ "id": "cordova-plugin-file.requestFileSystem",+ "file": "plugins/cordova-plugin-file/www/requestFileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.requestFileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.resolveLocalFileSystemURI",+ "file": "plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "window"+ ]+ },+ {+ "id": "cordova-plugin-file.isChrome",+ "file": "plugins/cordova-plugin-file/www/browser/isChrome.js",+ "pluginId": "cordova-plugin-file",+ "runs": true+ },+ {+ "id": "cordova-plugin-file.iosFileSystem",+ "file": "plugins/cordova-plugin-file/www/ios/FileSystem.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "FileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.fileSystems-roots",+ "file": "plugins/cordova-plugin-file/www/fileSystems-roots.js",+ "pluginId": "cordova-plugin-file",+ "runs": true+ },+ {+ "id": "cordova-plugin-file.fileSystemPaths",+ "file": "plugins/cordova-plugin-file/www/fileSystemPaths.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "cordova"+ ],+ "runs": true}],"plugin_metadata": {"com.whebcraft.cordova.plugin.downloader": "0.1.0",- "cordova-plugin-androidx": "3.0.0"+ "cordova-plugin-androidx": "3.0.0",+ "cordova-plugin-file": "7.0.0-dev"}}diff --git a/cordova/platforms/ios/platform_www/cordova_plugins.js b/cordova/platforms/ios/platform_www/cordova_plugins.jsindex 9c6193ed3..5d457dc9c 100644--- a/cordova/platforms/ios/platform_www/cordova_plugins.js+++ b/cordova/platforms/ios/platform_www/cordova_plugins.js@@ -7,10 +7,184 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {"clobbers": ["plugins.Downloader"]+ },+ {+ "id": "cordova-plugin-file.DirectoryEntry",+ "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.DirectoryEntry"+ ]+ },+ {+ "id": "cordova-plugin-file.DirectoryReader",+ "file": "plugins/cordova-plugin-file/www/DirectoryReader.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.DirectoryReader"+ ]+ },+ {+ "id": "cordova-plugin-file.Entry",+ "file": "plugins/cordova-plugin-file/www/Entry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Entry"+ ]+ },+ {+ "id": "cordova-plugin-file.File",+ "file": "plugins/cordova-plugin-file/www/File.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.File"+ ]+ },+ {+ "id": "cordova-plugin-file.FileEntry",+ "file": "plugins/cordova-plugin-file/www/FileEntry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileEntry"+ ]+ },+ {+ "id": "cordova-plugin-file.FileError",+ "file": "plugins/cordova-plugin-file/www/FileError.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileError"+ ]+ },+ {+ "id": "cordova-plugin-file.FileReader",+ "file": "plugins/cordova-plugin-file/www/FileReader.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileReader"+ ]+ },+ {+ "id": "cordova-plugin-file.FileSystem",+ "file": "plugins/cordova-plugin-file/www/FileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.FileUploadOptions",+ "file": "plugins/cordova-plugin-file/www/FileUploadOptions.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileUploadOptions"+ ]+ },+ {+ "id": "cordova-plugin-file.FileUploadResult",+ "file": "plugins/cordova-plugin-file/www/FileUploadResult.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileUploadResult"+ ]+ },+ {+ "id": "cordova-plugin-file.FileWriter",+ "file": "plugins/cordova-plugin-file/www/FileWriter.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileWriter"+ ]+ },+ {+ "id": "cordova-plugin-file.Flags",+ "file": "plugins/cordova-plugin-file/www/Flags.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Flags"+ ]+ },+ {+ "id": "cordova-plugin-file.LocalFileSystem",+ "file": "plugins/cordova-plugin-file/www/LocalFileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.LocalFileSystem"+ ],+ "merges": [+ "window"+ ]+ },+ {+ "id": "cordova-plugin-file.Metadata",+ "file": "plugins/cordova-plugin-file/www/Metadata.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Metadata"+ ]+ },+ {+ "id": "cordova-plugin-file.ProgressEvent",+ "file": "plugins/cordova-plugin-file/www/ProgressEvent.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.ProgressEvent"+ ]+ },+ {+ "id": "cordova-plugin-file.fileSystems",+ "file": "plugins/cordova-plugin-file/www/fileSystems.js",+ "pluginId": "cordova-plugin-file"+ },+ {+ "id": "cordova-plugin-file.requestFileSystem",+ "file": "plugins/cordova-plugin-file/www/requestFileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.requestFileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.resolveLocalFileSystemURI",+ "file": "plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "window"+ ]+ },+ {+ "id": "cordova-plugin-file.isChrome",+ "file": "plugins/cordova-plugin-file/www/browser/isChrome.js",+ "pluginId": "cordova-plugin-file",+ "runs": true+ },+ {+ "id": "cordova-plugin-file.iosFileSystem",+ "file": "plugins/cordova-plugin-file/www/ios/FileSystem.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "FileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.fileSystems-roots",+ "file": "plugins/cordova-plugin-file/www/fileSystems-roots.js",+ "pluginId": "cordova-plugin-file",+ "runs": true+ },+ {+ "id": "cordova-plugin-file.fileSystemPaths",+ "file": "plugins/cordova-plugin-file/www/fileSystemPaths.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "cordova"+ ],+ "runs": true}];module.exports.metadata = {"com.whebcraft.cordova.plugin.downloader": "0.1.0",- "cordova-plugin-androidx": "3.0.0"+ "cordova-plugin-androidx": "3.0.0",+ "cordova-plugin-file": "7.0.0-dev"};-});\ No newline at end of file+});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/DirectoryEntry.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/DirectoryEntry.jsnew file mode 100644index 000000000..fcd620c74--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/DirectoryEntry.js@@ -0,0 +1,119 @@+cordova.define("cordova-plugin-file.DirectoryEntry", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var argscheck = require('cordova/argscheck');+var utils = require('cordova/utils');+var exec = require('cordova/exec');+var Entry = require('./Entry');+var FileError = require('./FileError');+var DirectoryReader = require('./DirectoryReader');++/**+ * An interface representing a directory on the file system.+ *+ * {boolean} isFile always false (readonly)+ * {boolean} isDirectory always true (readonly)+ * {DOMString} name of the directory, excluding the path leading to it (readonly)+ * {DOMString} fullPath the absolute full path to the directory (readonly)+ * {FileSystem} filesystem on which the directory resides (readonly)+ */+var DirectoryEntry = function (name, fullPath, fileSystem, nativeURL) {+ // add trailing slash if it is missing+ if ((fullPath) && !/\/$/.test(fullPath)) {+ fullPath += '/';+ }+ // add trailing slash if it is missing+ if (nativeURL && !/\/$/.test(nativeURL)) {+ nativeURL += '/';+ }+ DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem, nativeURL);+};++utils.extend(DirectoryEntry, Entry);++/**+ * Creates a new DirectoryReader to read entries from this directory+ */+DirectoryEntry.prototype.createReader = function () {+ return new DirectoryReader(this.toInternalURL());+};++/**+ * Creates or looks up a directory+ *+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory+ * @param {Flags} options to create or exclusively create the directory+ * @param {Function} successCallback is called with the new entry+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {+ argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);+ var fs = this.filesystem;+ var win = successCallback && function (result) {+ var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);+ successCallback(entry);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getDirectory', [this.toInternalURL(), path, options]);+};++/**+ * Deletes a directory and all of it's contents+ *+ * @param {Function} successCallback is called with no parameters+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(successCallback, fail, 'File', 'removeRecursively', [this.toInternalURL()]);+};++/**+ * Creates or looks up a file+ *+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file+ * @param {Flags} options to create or exclusively create the file+ * @param {Function} successCallback is called with the new entry+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {+ argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);+ var fs = this.filesystem;+ var win = successCallback && function (result) {+ var FileEntry = require('./FileEntry');+ var entry = new FileEntry(result.name, result.fullPath, fs, result.nativeURL);+ successCallback(entry);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getFile', [this.toInternalURL(), path, options]);+};++module.exports = DirectoryEntry;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/DirectoryReader.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/DirectoryReader.jsnew file mode 100644index 000000000..417c85f10--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/DirectoryReader.js@@ -0,0 +1,75 @@+cordova.define("cordova-plugin-file.DirectoryReader", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var FileError = require('./FileError');++/**+ * An interface that lists the files and directories in a directory.+ */+function DirectoryReader (localURL) {+ this.localURL = localURL || null;+ this.hasReadEntries = false;+}++/**+ * Returns a list of entries from a directory.+ *+ * @param {Function} successCallback is called with a list of entries+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) {+ // If we've already read and passed on this directory's entries, return an empty list.+ if (this.hasReadEntries) {+ successCallback([]);+ return;+ }+ var reader = this;+ var win = typeof successCallback !== 'function' ? null : function (result) {+ var retVal = [];+ for (var i = 0; i < result.length; i++) {+ var entry = null;+ if (result[i].isDirectory) {+ entry = new (require('./DirectoryEntry'))();+ } else if (result[i].isFile) {+ entry = new (require('./FileEntry'))();+ }+ entry.isDirectory = result[i].isDirectory;+ entry.isFile = result[i].isFile;+ entry.name = result[i].name;+ entry.fullPath = result[i].fullPath;+ entry.filesystem = new (require('./FileSystem'))(result[i].filesystemName);+ entry.nativeURL = result[i].nativeURL;+ retVal.push(entry);+ }+ reader.hasReadEntries = true;+ successCallback(retVal);+ };+ var fail = typeof errorCallback !== 'function' ? null : function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'readEntries', [this.localURL]);+};++module.exports = DirectoryReader;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Entry.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Entry.jsnew file mode 100644index 000000000..5db846cfa--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Entry.js@@ -0,0 +1,263 @@+cordova.define("cordova-plugin-file.Entry", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var argscheck = require('cordova/argscheck');+var exec = require('cordova/exec');+var FileError = require('./FileError');+var Metadata = require('./Metadata');++/**+ * Represents a file or directory on the local file system.+ *+ * @param isFile+ * {boolean} true if Entry is a file (readonly)+ * @param isDirectory+ * {boolean} true if Entry is a directory (readonly)+ * @param name+ * {DOMString} name of the file or directory, excluding the path+ * leading to it (readonly)+ * @param fullPath+ * {DOMString} the absolute full path to the file or directory+ * (readonly)+ * @param fileSystem+ * {FileSystem} the filesystem on which this entry resides+ * (readonly)+ * @param nativeURL+ * {DOMString} an alternate URL which can be used by native+ * webview controls, for example media players.+ * (optional, readonly)+ */+function Entry (isFile, isDirectory, name, fullPath, fileSystem, nativeURL) {+ this.isFile = !!isFile;+ this.isDirectory = !!isDirectory;+ this.name = name || '';+ this.fullPath = fullPath || '';+ this.filesystem = fileSystem || null;+ this.nativeURL = nativeURL || null;+}++/**+ * Look up the metadata of the entry.+ *+ * @param successCallback+ * {Function} is called with a Metadata object+ * @param errorCallback+ * {Function} is called with a FileError+ */+Entry.prototype.getMetadata = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);+ var success = successCallback && function (entryMetadata) {+ var metadata = new Metadata({+ size: entryMetadata.size,+ modificationTime: entryMetadata.lastModifiedDate+ });+ successCallback(metadata);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(success, fail, 'File', 'getFileMetadata', [this.toInternalURL()]);+};++/**+ * Set the metadata of the entry.+ *+ * @param successCallback+ * {Function} is called with a Metadata object+ * @param errorCallback+ * {Function} is called with a FileError+ * @param metadataObject+ * {Object} keys and values to set+ */+Entry.prototype.setMetadata = function (successCallback, errorCallback, metadataObject) {+ argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);+ exec(successCallback, errorCallback, 'File', 'setMetadata', [this.toInternalURL(), metadataObject]);+};++/**+ * Move a file or directory to a new location.+ *+ * @param parent+ * {DirectoryEntry} the directory to which to move this entry+ * @param newName+ * {DOMString} new name of the entry, defaults to the current name+ * @param successCallback+ * {Function} called with the new DirectoryEntry object+ * @param errorCallback+ * {Function} called with a FileError+ */+Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallback) {+ argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ var srcURL = this.toInternalURL();+ // entry name+ var name = newName || this.name;+ var success = function (entry) {+ if (entry) {+ if (successCallback) {+ // create appropriate Entry object+ var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);+ var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef+ var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);+ successCallback(result);+ }+ } else {+ // no Entry object returned+ if (fail) {+ fail(FileError.NOT_FOUND_ERR);+ }+ }+ };++ // copy+ exec(success, fail, 'File', 'moveTo', [srcURL, parent.toInternalURL(), name]);+};++/**+ * Copy a directory to a different location.+ *+ * @param parent+ * {DirectoryEntry} the directory to which to copy the entry+ * @param newName+ * {DOMString} new name of the entry, defaults to the current name+ * @param successCallback+ * {Function} called with the new Entry object+ * @param errorCallback+ * {Function} called with a FileError+ */+Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallback) {+ argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ var srcURL = this.toInternalURL();+ // entry name+ var name = newName || this.name;+ // success callback+ var success = function (entry) {+ if (entry) {+ if (successCallback) {+ // create appropriate Entry object+ var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);+ var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef+ var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);+ successCallback(result);+ }+ } else {+ // no Entry object returned+ if (fail) {+ fail(FileError.NOT_FOUND_ERR);+ }+ }+ };++ // copy+ exec(success, fail, 'File', 'copyTo', [srcURL, parent.toInternalURL(), name]);+};++/**+ * Return a URL that can be passed across the bridge to identify this entry.+ */+Entry.prototype.toInternalURL = function () {+ if (this.filesystem && this.filesystem.__format__) {+ return this.filesystem.__format__(this.fullPath, this.nativeURL);+ }+};++/**+ * Return a URL that can be used to identify this entry.+ * Use a URL that can be used to as the src attribute of a <video> or+ * <audio> tag. If that is not possible, construct a cdvfile:// URL.+ */+Entry.prototype.toURL = function () {+ if (this.nativeURL) {+ return this.nativeURL;+ }+ // fullPath attribute may contain the full URL in the case that+ // toInternalURL fails.+ return this.toInternalURL() || 'file://localhost' + this.fullPath;+};++/**+ * Backwards-compatibility: In v1.0.0 - 1.0.2, .toURL would only return a+ * cdvfile:// URL, and this method was necessary to obtain URLs usable by the+ * webview.+ * See CB-6051, CB-6106, CB-6117, CB-6152, CB-6199, CB-6201, CB-6243, CB-6249,+ * and CB-6300.+ */+Entry.prototype.toNativeURL = function () {+ console.log("DEPRECATED: Update your code to use 'toURL'");+ return this.toURL();+};++/**+ * Returns a URI that can be used to identify this entry.+ *+ * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.+ * @return uri+ */+Entry.prototype.toURI = function (mimeType) {+ console.log("DEPRECATED: Update your code to use 'toURL'");+ return this.toURL();+};++/**+ * Remove a file or directory. It is an error to attempt to delete a+ * directory that is not empty. It is an error to attempt to delete a+ * root directory of a file system.+ *+ * @param successCallback {Function} called with no parameters+ * @param errorCallback {Function} called with a FileError+ */+Entry.prototype.remove = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'Entry.remove', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(successCallback, fail, 'File', 'remove', [this.toInternalURL()]);+};++/**+ * Look up the parent DirectoryEntry of this entry.+ *+ * @param successCallback {Function} called with the parent DirectoryEntry object+ * @param errorCallback {Function} called with a FileError+ */+Entry.prototype.getParent = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'Entry.getParent', arguments);+ var fs = this.filesystem;+ var win = successCallback && function (result) {+ var DirectoryEntry = require('./DirectoryEntry');+ var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);+ successCallback(entry);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getParent', [this.toInternalURL()]);+};++module.exports = Entry;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/File.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/File.jsnew file mode 100644index 000000000..c77178653--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/File.js@@ -0,0 +1,81 @@+cordova.define("cordova-plugin-file.File", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Constructor.+ * name {DOMString} name of the file, without path information+ * fullPath {DOMString} the full path of the file, including the name+ * type {DOMString} mime type+ * lastModifiedDate {Date} last modified date+ * size {Number} size of the file in bytes+ */++var File = function (name, localURL, type, lastModifiedDate, size) {+ this.name = name || '';+ this.localURL = localURL || null;+ this.type = type || null;+ this.lastModified = lastModifiedDate || null;+ // For backwards compatibility, store the timestamp in lastModifiedDate as well+ this.lastModifiedDate = lastModifiedDate || null;+ this.size = size || 0;++ // These store the absolute start and end for slicing the file.+ this.start = 0;+ this.end = this.size;+};++/**+ * Returns a "slice" of the file. Since Cordova Files don't contain the actual+ * content, this really returns a File with adjusted start and end.+ * Slices of slices are supported.+ * start {Number} The index at which to start the slice (inclusive).+ * end {Number} The index at which to end the slice (exclusive).+ */+File.prototype.slice = function (start, end) {+ var size = this.end - this.start;+ var newStart = 0;+ var newEnd = size;+ if (arguments.length) {+ if (start < 0) {+ newStart = Math.max(size + start, 0);+ } else {+ newStart = Math.min(size, start);+ }+ }++ if (arguments.length >= 2) {+ if (end < 0) {+ newEnd = Math.max(size + end, 0);+ } else {+ newEnd = Math.min(end, size);+ }+ }++ var newFile = new File(this.name, this.localURL, this.type, this.lastModified, this.size);+ newFile.start = this.start + newStart;+ newFile.end = this.start + newEnd;+ return newFile;+};++module.exports = File;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileEntry.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileEntry.jsnew file mode 100644index 000000000..6651b5542--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileEntry.js@@ -0,0 +1,95 @@+cordova.define("cordova-plugin-file.FileEntry", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var utils = require('cordova/utils');+var exec = require('cordova/exec');+var Entry = require('./Entry');+var FileWriter = require('./FileWriter');+var File = require('./File');+var FileError = require('./FileError');++/**+ * An interface representing a file on the file system.+ *+ * {boolean} isFile always true (readonly)+ * {boolean} isDirectory always false (readonly)+ * {DOMString} name of the file, excluding the path leading to it (readonly)+ * {DOMString} fullPath the absolute full path to the file (readonly)+ * {FileSystem} filesystem on which the file resides (readonly)+ */+var FileEntry = function (name, fullPath, fileSystem, nativeURL) {+ // remove trailing slash if it is present+ if (fullPath && /\/$/.test(fullPath)) {+ fullPath = fullPath.substring(0, fullPath.length - 1);+ }+ if (nativeURL && /\/$/.test(nativeURL)) {+ nativeURL = nativeURL.substring(0, nativeURL.length - 1);+ }++ FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem, nativeURL]);+};++utils.extend(FileEntry, Entry);++/**+ * Creates a new FileWriter associated with the file that this FileEntry represents.+ *+ * @param {Function} successCallback is called with the new FileWriter+ * @param {Function} errorCallback is called with a FileError+ */+FileEntry.prototype.createWriter = function (successCallback, errorCallback) {+ this.file(function (filePointer) {+ var writer = new FileWriter(filePointer);++ if (writer.localURL === null || writer.localURL === '') {+ if (errorCallback) {+ errorCallback(new FileError(FileError.INVALID_STATE_ERR));+ }+ } else {+ if (successCallback) {+ successCallback(writer);+ }+ }+ }, errorCallback);+};++/**+ * Returns a File that represents the current state of the file that this FileEntry represents.+ *+ * @param {Function} successCallback is called with the new File object+ * @param {Function} errorCallback is called with a FileError+ */+FileEntry.prototype.file = function (successCallback, errorCallback) {+ var localURL = this.toInternalURL();+ var win = successCallback && function (f) {+ var file = new File(f.name, localURL, f.type, f.lastModifiedDate, f.size);+ successCallback(file);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getFileMetadata', [localURL]);+};++module.exports = FileEntry;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileError.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileError.jsnew file mode 100644index 000000000..f378c3874--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileError.js@@ -0,0 +1,49 @@+cordova.define("cordova-plugin-file.FileError", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * FileError+ */+function FileError (error) {+ this.code = error || null;+}++// File error codes+// Found in DOMException+FileError.NOT_FOUND_ERR = 1;+FileError.SECURITY_ERR = 2;+FileError.ABORT_ERR = 3;++// Added by File API specification+FileError.NOT_READABLE_ERR = 4;+FileError.ENCODING_ERR = 5;+FileError.NO_MODIFICATION_ALLOWED_ERR = 6;+FileError.INVALID_STATE_ERR = 7;+FileError.SYNTAX_ERR = 8;+FileError.INVALID_MODIFICATION_ERR = 9;+FileError.QUOTA_EXCEEDED_ERR = 10;+FileError.TYPE_MISMATCH_ERR = 11;+FileError.PATH_EXISTS_ERR = 12;++module.exports = FileError;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileReader.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileReader.jsnew file mode 100644index 000000000..36d4dd4e6--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileReader.js@@ -0,0 +1,315 @@+cordova.define("cordova-plugin-file.FileReader", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var modulemapper = require('cordova/modulemapper');+var utils = require('cordova/utils');+var FileError = require('./FileError');+var ProgressEvent = require('./ProgressEvent');+var origFileReader = modulemapper.getOriginalSymbol(window, 'FileReader');++/**+ * This class reads the mobile device file system.+ *+ * For Android:+ * The root directory is the root of the file system.+ * To read from the SD card, the file name is "sdcard/my_file.txt"+ * @constructor+ */+var FileReader = function () {+ this._readyState = 0;+ this._error = null;+ this._result = null;+ this._progress = null;+ this._localURL = '';+ this._realReader = origFileReader ? new origFileReader() : {}; // eslint-disable-line new-cap+};++/**+ * Defines the maximum size to read at a time via the native API. The default value is a compromise between+ * minimizing the overhead of many exec() calls while still reporting progress frequently enough for large files.+ * (Note attempts to allocate more than a few MB of contiguous memory on the native side are likely to cause+ * OOM exceptions, while the JS engine seems to have fewer problems managing large strings or ArrayBuffers.)+ */+FileReader.READ_CHUNK_SIZE = 256 * 1024;++// States+FileReader.EMPTY = 0;+FileReader.LOADING = 1;+FileReader.DONE = 2;++utils.defineGetter(FileReader.prototype, 'readyState', function () {+ return this._localURL ? this._readyState : this._realReader.readyState;+});++utils.defineGetter(FileReader.prototype, 'error', function () {+ return this._localURL ? this._error : this._realReader.error;+});++utils.defineGetter(FileReader.prototype, 'result', function () {+ return this._localURL ? this._result : this._realReader.result;+});++function defineEvent (eventName) {+ utils.defineGetterSetter(FileReader.prototype, eventName, function () {+ return this._realReader[eventName] || null;+ }, function (value) {+ this._realReader[eventName] = value;+ });+}++// When the read starts.+defineEvent('onloadstart');++// While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)+defineEvent('onprogress');++// When the read has successfully completed.+defineEvent('onload');++// When the read has failed (see errors).+defineEvent('onerror');++// When the request has completed (either in success or failure).+defineEvent('onloadend');++// When the read has been aborted. For instance, by invoking the abort() method.+defineEvent('onabort');++function initRead (reader, file) {+ // Already loading something+ if (reader.readyState === FileReader.LOADING) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ reader._result = null;+ reader._error = null;+ reader._progress = 0;+ reader._readyState = FileReader.LOADING;++ if (typeof file.localURL === 'string') {+ reader._localURL = file.localURL;+ } else {+ reader._localURL = '';+ return true;+ }++ if (reader.onloadstart) {+ reader.onloadstart(new ProgressEvent('loadstart', { target: reader }));+ }+}++/**+ * Callback used by the following read* functions to handle incremental or final success.+ * Must be bound to the FileReader's this along with all but the last parameter,+ * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate)+ * @param readType The name of the read function to call.+ * @param encoding Text encoding, or null if this is not a text type read.+ * @param offset Starting offset of the read.+ * @param totalSize Total number of bytes or chars to read.+ * @param accumulate A function that takes the callback result and accumulates it in this._result.+ * @param r Callback result returned by the last read exec() call, or null to begin reading.+ */+function readSuccessCallback (readType, encoding, offset, totalSize, accumulate, r) {+ if (this._readyState === FileReader.DONE) {+ return;+ }++ var CHUNK_SIZE = FileReader.READ_CHUNK_SIZE;+ if (readType === 'readAsDataURL') {+ // Windows proxy does not support reading file slices as Data URLs+ // so read the whole file at once.+ CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize // eslint-disable-line no-undef+ : (+ // Calculate new chunk size for data URLs to be multiply of 3+ // Otherwise concatenated base64 chunks won't be valid base64 data+ FileReader.READ_CHUNK_SIZE - (FileReader.READ_CHUNK_SIZE % 3) + 3+ );+ }++ if (typeof r !== 'undefined') {+ accumulate(r);+ this._progress = Math.min(this._progress + CHUNK_SIZE, totalSize);++ if (typeof this.onprogress === 'function') {+ this.onprogress(new ProgressEvent('progress', { loaded: this._progress, total: totalSize }));+ }+ }++ if (typeof r === 'undefined' || this._progress < totalSize) {+ var execArgs = [+ this._localURL,+ offset + this._progress,+ offset + this._progress + Math.min(totalSize - this._progress, CHUNK_SIZE)];+ if (encoding) {+ execArgs.splice(1, 0, encoding);+ }+ exec(+ readSuccessCallback.bind(this, readType, encoding, offset, totalSize, accumulate),+ readFailureCallback.bind(this),+ 'File', readType, execArgs);+ } else {+ this._readyState = FileReader.DONE;++ if (typeof this.onload === 'function') {+ this.onload(new ProgressEvent('load', { target: this }));+ }++ if (typeof this.onloadend === 'function') {+ this.onloadend(new ProgressEvent('loadend', { target: this }));+ }+ }+}++/**+ * Callback used by the following read* functions to handle errors.+ * Must be bound to the FileReader's this, e.g. readFailureCallback.bind(this)+ */+function readFailureCallback (e) {+ if (this._readyState === FileReader.DONE) {+ return;+ }++ this._readyState = FileReader.DONE;+ this._result = null;+ this._error = new FileError(e);++ if (typeof this.onerror === 'function') {+ this.onerror(new ProgressEvent('error', { target: this }));+ }++ if (typeof this.onloadend === 'function') {+ this.onloadend(new ProgressEvent('loadend', { target: this }));+ }+}++/**+ * Abort reading file.+ */+FileReader.prototype.abort = function () {+ if (origFileReader && !this._localURL) {+ return this._realReader.abort();+ }+ this._result = null;++ if (this._readyState === FileReader.DONE || this._readyState === FileReader.EMPTY) {+ return;+ }++ this._readyState = FileReader.DONE;++ // If abort callback+ if (typeof this.onabort === 'function') {+ this.onabort(new ProgressEvent('abort', { target: this }));+ }+ // If load end callback+ if (typeof this.onloadend === 'function') {+ this.onloadend(new ProgressEvent('loadend', { target: this }));+ }+};++/**+ * Read text file.+ *+ * @param file {File} File object containing file properties+ * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)+ */+FileReader.prototype.readAsText = function (file, encoding) {+ if (initRead(this, file)) {+ return this._realReader.readAsText(file, encoding);+ }++ // Default encoding is UTF-8+ var enc = encoding || 'UTF-8';++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsText', enc, file.start, totalSize, function (r) {+ if (this._progress === 0) {+ this._result = '';+ }+ this._result += r;+ }.bind(this));+};++/**+ * Read file and return data as a base64 encoded data url.+ * A data url is of the form:+ * data:[<mediatype>][;base64],<data>+ *+ * @param file {File} File object containing file properties+ */+FileReader.prototype.readAsDataURL = function (file) {+ if (initRead(this, file)) {+ return this._realReader.readAsDataURL(file);+ }++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsDataURL', null, file.start, totalSize, function (r) {+ var commaIndex = r.indexOf(',');+ if (this._progress === 0) {+ this._result = r;+ } else {+ this._result += r.substring(commaIndex + 1);+ }+ }.bind(this));+};++/**+ * Read file and return data as a binary data.+ *+ * @param file {File} File object containing file properties+ */+FileReader.prototype.readAsBinaryString = function (file) {+ if (initRead(this, file)) {+ return this._realReader.readAsBinaryString(file);+ }++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsBinaryString', null, file.start, totalSize, function (r) {+ if (this._progress === 0) {+ this._result = '';+ }+ this._result += r;+ }.bind(this));+};++/**+ * Read file and return data as a binary data.+ *+ * @param file {File} File object containing file properties+ */+FileReader.prototype.readAsArrayBuffer = function (file) {+ if (initRead(this, file)) {+ return this._realReader.readAsArrayBuffer(file);+ }++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsArrayBuffer', null, file.start, totalSize, function (r) {+ var resultArray = (this._progress === 0 ? new Uint8Array(totalSize) : new Uint8Array(this._result));+ resultArray.set(new Uint8Array(r), this._progress);+ this._result = resultArray.buffer;+ }.bind(this));+};++module.exports = FileReader;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileSystem.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileSystem.jsnew file mode 100644index 000000000..ad9ea7859--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileSystem.js@@ -0,0 +1,58 @@+cordova.define("cordova-plugin-file.FileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var DirectoryEntry = require('./DirectoryEntry');++/**+ * An interface representing a file system+ *+ * @constructor+ * {DOMString} name the unique name of the file system (readonly)+ * {DirectoryEntry} root directory of the file system (readonly)+ */+var FileSystem = function (name, root) {+ this.name = name;+ if (root) {+ this.root = new DirectoryEntry(root.name, root.fullPath, this, root.nativeURL);+ } else {+ this.root = new DirectoryEntry(this.name, '/', this);+ }+};++FileSystem.prototype.__format__ = function (fullPath, nativeUrl) {+ return fullPath;+};++FileSystem.prototype.toJSON = function () {+ return '<FileSystem: ' + this.name + '>';+};++// Use instead of encodeURI() when encoding just the path part of a URI rather than an entire URI.+FileSystem.encodeURIPath = function (path) {+ // Because # is a valid filename character, it must be encoded to prevent part of the+ // path from being parsed as a URI fragment.+ return encodeURI(path).replace(/#/g, '%23');+};++module.exports = FileSystem;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileUploadOptions.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileUploadOptions.jsnew file mode 100644index 000000000..6acd09334--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileUploadOptions.js@@ -0,0 +1,44 @@+cordova.define("cordova-plugin-file.FileUploadOptions", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Options to customize the HTTP request used to upload files.+ * @constructor+ * @param fileKey {String} Name of file request parameter.+ * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.+ * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.+ * @param params {Object} Object with key: value params to send to the server.+ * @param headers {Object} Keys are header names, values are header values. Multiple+ * headers of the same name are not supported.+ */+var FileUploadOptions = function (fileKey, fileName, mimeType, params, headers, httpMethod) {+ this.fileKey = fileKey || null;+ this.fileName = fileName || null;+ this.mimeType = mimeType || null;+ this.params = params || null;+ this.headers = headers || null;+ this.httpMethod = httpMethod || null;+};++module.exports = FileUploadOptions;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileUploadResult.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileUploadResult.jsnew file mode 100644index 000000000..e3c3a7431--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileUploadResult.js@@ -0,0 +1,33 @@+cordova.define("cordova-plugin-file.FileUploadResult", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * FileUploadResult+ * @constructor+ */+module.exports = function FileUploadResult (size, code, content) {+ this.bytesSent = size;+ this.responseCode = code;+ this.response = content;+};++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileWriter.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileWriter.jsnew file mode 100644index 000000000..9f141e085--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/FileWriter.js@@ -0,0 +1,338 @@+cordova.define("cordova-plugin-file.FileWriter", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var FileError = require('./FileError');+var FileReader = require('./FileReader');+var ProgressEvent = require('./ProgressEvent');++/**+ * This class writes to the mobile device file system.+ *+ * For Android:+ * The root directory is the root of the file system.+ * To write to the SD card, the file name is "sdcard/my_file.txt"+ *+ * @constructor+ * @param file {File} File object containing file properties+ * @param append if true write to the end of the file, otherwise overwrite the file+ */+var FileWriter = function (file) {+ this.fileName = '';+ this.length = 0;+ if (file) {+ this.localURL = file.localURL || file;+ this.length = file.size || 0;+ }+ // default is to write at the beginning of the file+ this.position = 0;++ this.readyState = 0; // EMPTY++ this.result = null;++ // Error+ this.error = null;++ // Event handlers+ // When writing starts+ this.onwritestart = null;++ // While writing the file, and reporting partial file data+ this.onprogress = null;++ // When the write has successfully completed.+ this.onwrite = null;++ // When the request has completed (either in success or failure).+ this.onwriteend = null;++ // When the write has been aborted. For instance, by invoking the abort() method.+ this.onabort = null;++ // When the write has failed (see errors).+ this.onerror = null;+};++// States+FileWriter.INIT = 0;+FileWriter.WRITING = 1;+FileWriter.DONE = 2;++/**+ * Abort writing file.+ */+FileWriter.prototype.abort = function () {+ // check for invalid state+ if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ // set error+ this.error = new FileError(FileError.ABORT_ERR);++ this.readyState = FileWriter.DONE;++ // If abort callback+ if (typeof this.onabort === 'function') {+ this.onabort(new ProgressEvent('abort', { target: this }));+ }++ // If write end callback+ if (typeof this.onwriteend === 'function') {+ this.onwriteend(new ProgressEvent('writeend', { target: this }));+ }+};++/**+ * Writes data to the file+ *+ * @param data text or blob to be written+ * @param isPendingBlobReadResult {Boolean} true if the data is the pending blob read operation result+ */+FileWriter.prototype.write = function (data, isPendingBlobReadResult) {+ var that = this;+ var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');+ /* eslint-disable no-undef */+ var isProxySupportBlobNatively = (cordova.platformId === 'windows8' || cordova.platformId === 'windows');+ var isBinary;++ // Check to see if the incoming data is a blob+ if (data instanceof File || (!isProxySupportBlobNatively && supportsBinary && data instanceof Blob)) {+ var fileReader = new FileReader();+ /* eslint-enable no-undef */+ fileReader.onload = function () {+ // Call this method again, with the arraybuffer as argument+ FileWriter.prototype.write.call(that, this.result, true /* isPendingBlobReadResult */);+ };+ fileReader.onerror = function () {+ // DONE state+ that.readyState = FileWriter.DONE;++ // Save error+ that.error = this.error;++ // If onerror callback+ if (typeof that.onerror === 'function') {+ that.onerror(new ProgressEvent('error', { target: that }));+ }++ // If onwriteend callback+ if (typeof that.onwriteend === 'function') {+ that.onwriteend(new ProgressEvent('writeend', { target: that }));+ }+ };++ // WRITING state+ this.readyState = FileWriter.WRITING;++ if (supportsBinary) {+ fileReader.readAsArrayBuffer(data);+ } else {+ fileReader.readAsText(data);+ }+ return;+ }++ // Mark data type for safer transport over the binary bridge+ isBinary = supportsBinary && (data instanceof ArrayBuffer);+ if (isBinary && cordova.platformId === 'windowsphone') { // eslint-disable-line no-undef+ // create a plain array, using the keys from the Uint8Array view so that we can serialize it+ data = Array.apply(null, new Uint8Array(data));+ }++ // Throw an exception if we are already writing a file+ if (this.readyState === FileWriter.WRITING && !isPendingBlobReadResult) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ // WRITING state+ this.readyState = FileWriter.WRITING;++ var me = this;++ // If onwritestart callback+ if (typeof me.onwritestart === 'function') {+ me.onwritestart(new ProgressEvent('writestart', { target: me }));+ }++ // Write file+ exec(+ // Success callback+ function (r) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // position always increases by bytes written because file would be extended+ me.position += r;+ // The length of the file is now where we are done writing.++ me.length = me.position;++ // DONE state+ me.readyState = FileWriter.DONE;++ // If onwrite callback+ if (typeof me.onwrite === 'function') {+ me.onwrite(new ProgressEvent('write', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ },+ // Error callback+ function (e) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // DONE state+ me.readyState = FileWriter.DONE;++ // Save error+ me.error = new FileError(e);++ // If onerror callback+ if (typeof me.onerror === 'function') {+ me.onerror(new ProgressEvent('error', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ }, 'File', 'write', [this.localURL, data, this.position, isBinary]);+};++/**+ * Moves the file pointer to the location specified.+ *+ * If the offset is a negative number the position of the file+ * pointer is rewound. If the offset is greater than the file+ * size the position is set to the end of the file.+ *+ * @param offset is the location to move the file pointer to.+ */+FileWriter.prototype.seek = function (offset) {+ // Throw an exception if we are already writing a file+ if (this.readyState === FileWriter.WRITING) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ if (!offset && offset !== 0) {+ return;+ }++ // See back from end of file.+ if (offset < 0) {+ this.position = Math.max(offset + this.length, 0);+ // Offset is bigger than file size so set position+ // to the end of the file.+ } else if (offset > this.length) {+ this.position = this.length;+ // Offset is between 0 and file size so set the position+ // to start writing.+ } else {+ this.position = offset;+ }+};++/**+ * Truncates the file to the size specified.+ *+ * @param size to chop the file at.+ */+FileWriter.prototype.truncate = function (size) {+ // Throw an exception if we are already writing a file+ if (this.readyState === FileWriter.WRITING) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ // WRITING state+ this.readyState = FileWriter.WRITING;++ var me = this;++ // If onwritestart callback+ if (typeof me.onwritestart === 'function') {+ me.onwritestart(new ProgressEvent('writestart', { target: this }));+ }++ // Write file+ exec(+ // Success callback+ function (r) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // DONE state+ me.readyState = FileWriter.DONE;++ // Update the length of the file+ me.length = r;+ me.position = Math.min(me.position, r);++ // If onwrite callback+ if (typeof me.onwrite === 'function') {+ me.onwrite(new ProgressEvent('write', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ },+ // Error callback+ function (e) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // DONE state+ me.readyState = FileWriter.DONE;++ // Save error+ me.error = new FileError(e);++ // If onerror callback+ if (typeof me.onerror === 'function') {+ me.onerror(new ProgressEvent('error', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ }, 'File', 'truncate', [this.localURL, size]);+};++module.exports = FileWriter;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Flags.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Flags.jsnew file mode 100644index 000000000..cdb12bb73--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Flags.js@@ -0,0 +1,39 @@+cordova.define("cordova-plugin-file.Flags", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Supplies arguments to methods that lookup or create files and directories.+ *+ * @param create+ * {boolean} file or directory if it doesn't exist+ * @param exclusive+ * {boolean} used with create; if true the command will fail if+ * target path exists+ */+function Flags (create, exclusive) {+ this.create = create || false;+ this.exclusive = exclusive || false;+}++module.exports = Flags;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/LocalFileSystem.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/LocalFileSystem.jsnew file mode 100644index 000000000..4ce684812--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/LocalFileSystem.js@@ -0,0 +1,26 @@+cordova.define("cordova-plugin-file.LocalFileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++exports.TEMPORARY = 0;+exports.PERSISTENT = 1;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Metadata.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Metadata.jsnew file mode 100644index 000000000..22366e167--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/Metadata.js@@ -0,0 +1,43 @@+cordova.define("cordova-plugin-file.Metadata", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Information about the state of the file or directory+ *+ * {Date} modificationTime (readonly)+ */+var Metadata = function (metadata) {+ if (typeof metadata === 'object') {+ this.modificationTime = new Date(metadata.modificationTime);+ this.size = metadata.size || 0;+ } else if (typeof metadata === 'undefined') {+ this.modificationTime = null;+ this.size = 0;+ } else {+ /* Backwards compatiblity with platforms that only return a timestamp */+ this.modificationTime = new Date(metadata);+ }+};++module.exports = Metadata;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/ProgressEvent.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/ProgressEvent.jsnew file mode 100644index 000000000..cbecdb12b--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/ProgressEvent.js@@ -0,0 +1,70 @@+cordova.define("cordova-plugin-file.ProgressEvent", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill+// Feature test: See if we can instantiate a native ProgressEvent;+// if so, use that approach,+// otherwise fill-in with our own implementation.+//+// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.+var ProgressEvent = (function () {+ /*+ var createEvent = function(data) {+ var event = document.createEvent('Events');+ event.initEvent('ProgressEvent', false, false);+ if (data) {+ for (var i in data) {+ if (data.hasOwnProperty(i)) {+ event[i] = data[i];+ }+ }+ if (data.target) {+ // TODO: cannot call <some_custom_object>.dispatchEvent+ // need to first figure out how to implement EventTarget+ }+ }+ return event;+ };+ try {+ var ev = createEvent({type:"abort",target:document});+ return function ProgressEvent(type, data) {+ data.type = type;+ return createEvent(data);+ };+ } catch(e){+ */+ return function ProgressEvent (type, dict) {+ this.type = type;+ this.bubbles = false;+ this.cancelBubble = false;+ this.cancelable = false;+ this.lengthComputable = false;+ this.loaded = dict && dict.loaded ? dict.loaded : 0;+ this.total = dict && dict.total ? dict.total : 0;+ this.target = dict && dict.target ? dict.target : null;+ };+ // }+})();++module.exports = ProgressEvent;++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.jsnew file mode 100644index 000000000..90450d862--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/browser/isChrome.js@@ -0,0 +1,29 @@+cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+ */++module.exports = function () {+ // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and+ // possibly a good flag to indicate that we're running in Chrome+ return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;+};++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystemPaths.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystemPaths.jsnew file mode 100644index 000000000..4bfc0f629--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystemPaths.js@@ -0,0 +1,65 @@+cordova.define("cordova-plugin-file.fileSystemPaths", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var channel = require('cordova/channel');++exports.file = {+ // Read-only directory where the application is installed.+ applicationDirectory: null,+ // Root of app's private writable storage+ applicationStorageDirectory: null,+ // Where to put app-specific data files.+ dataDirectory: null,+ // Cached files that should survive app restarts.+ // Apps should not rely on the OS to delete files in here.+ cacheDirectory: null,+ // Android: the application space on external storage.+ externalApplicationStorageDirectory: null,+ // Android: Where to put app-specific data files on external storage.+ externalDataDirectory: null,+ // Android: the application cache on external storage.+ externalCacheDirectory: null,+ // Android: the external storage (SD card) root.+ externalRootDirectory: null,+ // iOS: Temp directory that the OS can clear at will.+ tempDirectory: null,+ // iOS: Holds app-specific files that should be synced (e.g. to iCloud).+ syncedDataDirectory: null,+ // iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)+ documentsDirectory: null,+ // BlackBerry10: Files globally available to all apps+ sharedDirectory: null+};++channel.waitForInitialization('onFileSystemPathsReady');+channel.onCordovaReady.subscribe(function () {+ function after (paths) {+ for (var k in paths) {+ exports.file[k] = paths[k];+ }+ channel.initializationComplete('onFileSystemPathsReady');+ }+ exec(after, null, 'File', 'requestAllPaths', []);+});++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystems-roots.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystems-roots.jsnew file mode 100644index 000000000..6e02953e8--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystems-roots.js@@ -0,0 +1,49 @@+cordova.define("cordova-plugin-file.fileSystems-roots", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++// Map of fsName -> FileSystem.+var fsMap = null;+var FileSystem = require('./FileSystem');+var exec = require('cordova/exec');++// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.+require('./fileSystems').getFs = function (name, callback) {+ function success (response) {+ fsMap = {};+ for (var i = 0; i < response.length; ++i) {+ var fsRoot = response[i];+ if (fsRoot) {+ var fs = new FileSystem(fsRoot.filesystemName, fsRoot);+ fsMap[fs.name] = fs;+ }+ }+ callback(fsMap[name]);+ }++ if (fsMap) {+ callback(fsMap[name]);+ } else {+ exec(success, null, 'File', 'requestAllFileSystems', []);+ }+};++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystems.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystems.jsnew file mode 100644index 000000000..e61ceafc8--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/fileSystems.js@@ -0,0 +1,28 @@+cordova.define("cordova-plugin-file.fileSystems", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.+module.exports.getFs = function (name, callback) {+ callback(null);+};++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/ios/FileSystem.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/ios/FileSystem.jsnew file mode 100644index 000000000..551b51545--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/ios/FileSystem.js@@ -0,0 +1,32 @@+cordova.define("cordova-plugin-file.iosFileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/+/* eslint no-undef : 0 */+FILESYSTEM_PROTOCOL = 'cdvfile';++module.exports = {+ __format__: function (fullPath) {+ var path = ('/' + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath)).replace('//', '/');+ return FILESYSTEM_PROTOCOL + '://localhost' + path;+ }+};++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/requestFileSystem.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/requestFileSystem.jsnew file mode 100644index 000000000..7f652193c--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/requestFileSystem.js@@ -0,0 +1,84 @@+cordova.define("cordova-plugin-file.requestFileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++(function () {+ // For browser platform: not all browsers use this file.+ function checkBrowser () {+ if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef+ module.exports = window.requestFileSystem || window.webkitRequestFileSystem;+ return true;+ }+ return false;+ }+ if (checkBrowser()) {+ return;+ }++ var argscheck = require('cordova/argscheck');+ var FileError = require('./FileError');+ var FileSystem = require('./FileSystem');+ var exec = require('cordova/exec');+ var fileSystems = require('./fileSystems');++ /**+ * Request a file system in which to store application data.+ * @param type local file system type+ * @param size indicates how much storage space, in bytes, the application expects to need+ * @param successCallback invoked with a FileSystem object+ * @param errorCallback invoked if error occurs retrieving file system+ */+ var requestFileSystem = function (type, size, successCallback, errorCallback) {+ argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);+ var fail = function (code) {+ if (errorCallback) {+ errorCallback(new FileError(code));+ }+ };++ if (type < 0) {+ fail(FileError.SYNTAX_ERR);+ } else {+ // if successful, return a FileSystem object+ var success = function (file_system) {+ if (file_system) {+ if (successCallback) {+ fileSystems.getFs(file_system.name, function (fs) {+ // This should happen only on platforms that haven't implemented requestAllFileSystems (windows)+ if (!fs) {+ fs = new FileSystem(file_system.name, file_system.root);+ }+ successCallback(fs);+ });+ }+ } else {+ // no FileSystem object returned+ fail(FileError.NOT_FOUND_ERR);+ }+ };+ exec(success, fail, 'File', 'requestFileSystem', [type, size]);+ }+ };++ module.exports = requestFileSystem;+})();++});diff --git a/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.jsnew file mode 100644index 000000000..494de62ff--- /dev/null+++ b/cordova/platforms/ios/platform_www/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js@@ -0,0 +1,94 @@+cordova.define("cordova-plugin-file.resolveLocalFileSystemURI", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/+(function () {+ // For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.+ function checkBrowser () {+ if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef+ module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;+ return true;+ }+ return false;+ }+ if (checkBrowser()) {+ return;+ }++ var argscheck = require('cordova/argscheck');+ var DirectoryEntry = require('./DirectoryEntry');+ var FileEntry = require('./FileEntry');+ var FileError = require('./FileError');+ var exec = require('cordova/exec');+ var fileSystems = require('./fileSystems');++ /**+ * Look up file system Entry referred to by local URI.+ * @param {DOMString} uri URI referring to a local file or directory+ * @param successCallback invoked with Entry object corresponding to URI+ * @param errorCallback invoked if error occurs retrieving file system entry+ */+ module.exports.resolveLocalFileSystemURL = module.exports.resolveLocalFileSystemURL || function (uri, successCallback, errorCallback) {+ argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);+ // error callback+ var fail = function (error) {+ if (errorCallback) {+ errorCallback(new FileError(error));+ }+ };+ // sanity check for 'not:valid:filename' or '/not:valid:filename'+ // file.spec.12 window.resolveLocalFileSystemURI should error (ENCODING_ERR) when resolving invalid URI with leading /.+ if (!uri || uri.split(':').length > 2) {+ setTimeout(function () {+ fail(FileError.ENCODING_ERR);+ }, 0);+ return;+ }+ // if successful, return either a file or directory entry+ var success = function (entry) {+ if (entry) {+ if (successCallback) {+ // create appropriate Entry object+ var fsName = entry.filesystemName || (entry.filesystem && entry.filesystem.name) || (entry.filesystem === window.PERSISTENT ? 'persistent' : 'temporary'); // eslint-disable-line no-undef+ fileSystems.getFs(fsName, function (fs) {+ // This should happen only on platforms that haven't implemented requestAllFileSystems (windows)+ if (!fs) {+ fs = new FileSystem(fsName, { name: '', fullPath: '/' }); // eslint-disable-line no-undef+ }+ var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath, fs, entry.nativeURL) : new FileEntry(entry.name, entry.fullPath, fs, entry.nativeURL);+ successCallback(result);+ });+ }+ } else {+ // no Entry object returned+ fail(FileError.NOT_FOUND_ERR);+ }+ };++ exec(success, fail, 'File', 'resolveLocalFileSystemURI', [uri]);+ };++ module.exports.resolveLocalFileSystemURI = function () {+ console.log('resolveLocalFileSystemURI is deprecated. Please call resolveLocalFileSystemURL instead.');+ module.exports.resolveLocalFileSystemURL.apply(this, arguments);+ };+})();++});diff --git a/cordova/platforms/ios/www/cordova_plugins.js b/cordova/platforms/ios/www/cordova_plugins.jsindex 9c6193ed3..5d457dc9c 100644--- a/cordova/platforms/ios/www/cordova_plugins.js+++ b/cordova/platforms/ios/www/cordova_plugins.js@@ -7,10 +7,184 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {"clobbers": ["plugins.Downloader"]+ },+ {+ "id": "cordova-plugin-file.DirectoryEntry",+ "file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.DirectoryEntry"+ ]+ },+ {+ "id": "cordova-plugin-file.DirectoryReader",+ "file": "plugins/cordova-plugin-file/www/DirectoryReader.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.DirectoryReader"+ ]+ },+ {+ "id": "cordova-plugin-file.Entry",+ "file": "plugins/cordova-plugin-file/www/Entry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Entry"+ ]+ },+ {+ "id": "cordova-plugin-file.File",+ "file": "plugins/cordova-plugin-file/www/File.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.File"+ ]+ },+ {+ "id": "cordova-plugin-file.FileEntry",+ "file": "plugins/cordova-plugin-file/www/FileEntry.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileEntry"+ ]+ },+ {+ "id": "cordova-plugin-file.FileError",+ "file": "plugins/cordova-plugin-file/www/FileError.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileError"+ ]+ },+ {+ "id": "cordova-plugin-file.FileReader",+ "file": "plugins/cordova-plugin-file/www/FileReader.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileReader"+ ]+ },+ {+ "id": "cordova-plugin-file.FileSystem",+ "file": "plugins/cordova-plugin-file/www/FileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.FileUploadOptions",+ "file": "plugins/cordova-plugin-file/www/FileUploadOptions.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileUploadOptions"+ ]+ },+ {+ "id": "cordova-plugin-file.FileUploadResult",+ "file": "plugins/cordova-plugin-file/www/FileUploadResult.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileUploadResult"+ ]+ },+ {+ "id": "cordova-plugin-file.FileWriter",+ "file": "plugins/cordova-plugin-file/www/FileWriter.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.FileWriter"+ ]+ },+ {+ "id": "cordova-plugin-file.Flags",+ "file": "plugins/cordova-plugin-file/www/Flags.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Flags"+ ]+ },+ {+ "id": "cordova-plugin-file.LocalFileSystem",+ "file": "plugins/cordova-plugin-file/www/LocalFileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.LocalFileSystem"+ ],+ "merges": [+ "window"+ ]+ },+ {+ "id": "cordova-plugin-file.Metadata",+ "file": "plugins/cordova-plugin-file/www/Metadata.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.Metadata"+ ]+ },+ {+ "id": "cordova-plugin-file.ProgressEvent",+ "file": "plugins/cordova-plugin-file/www/ProgressEvent.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.ProgressEvent"+ ]+ },+ {+ "id": "cordova-plugin-file.fileSystems",+ "file": "plugins/cordova-plugin-file/www/fileSystems.js",+ "pluginId": "cordova-plugin-file"+ },+ {+ "id": "cordova-plugin-file.requestFileSystem",+ "file": "plugins/cordova-plugin-file/www/requestFileSystem.js",+ "pluginId": "cordova-plugin-file",+ "clobbers": [+ "window.requestFileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.resolveLocalFileSystemURI",+ "file": "plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "window"+ ]+ },+ {+ "id": "cordova-plugin-file.isChrome",+ "file": "plugins/cordova-plugin-file/www/browser/isChrome.js",+ "pluginId": "cordova-plugin-file",+ "runs": true+ },+ {+ "id": "cordova-plugin-file.iosFileSystem",+ "file": "plugins/cordova-plugin-file/www/ios/FileSystem.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "FileSystem"+ ]+ },+ {+ "id": "cordova-plugin-file.fileSystems-roots",+ "file": "plugins/cordova-plugin-file/www/fileSystems-roots.js",+ "pluginId": "cordova-plugin-file",+ "runs": true+ },+ {+ "id": "cordova-plugin-file.fileSystemPaths",+ "file": "plugins/cordova-plugin-file/www/fileSystemPaths.js",+ "pluginId": "cordova-plugin-file",+ "merges": [+ "cordova"+ ],+ "runs": true}];module.exports.metadata = {"com.whebcraft.cordova.plugin.downloader": "0.1.0",- "cordova-plugin-androidx": "3.0.0"+ "cordova-plugin-androidx": "3.0.0",+ "cordova-plugin-file": "7.0.0-dev"};-});\ No newline at end of file+});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/DirectoryEntry.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/DirectoryEntry.jsnew file mode 100644index 000000000..fcd620c74--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/DirectoryEntry.js@@ -0,0 +1,119 @@+cordova.define("cordova-plugin-file.DirectoryEntry", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var argscheck = require('cordova/argscheck');+var utils = require('cordova/utils');+var exec = require('cordova/exec');+var Entry = require('./Entry');+var FileError = require('./FileError');+var DirectoryReader = require('./DirectoryReader');++/**+ * An interface representing a directory on the file system.+ *+ * {boolean} isFile always false (readonly)+ * {boolean} isDirectory always true (readonly)+ * {DOMString} name of the directory, excluding the path leading to it (readonly)+ * {DOMString} fullPath the absolute full path to the directory (readonly)+ * {FileSystem} filesystem on which the directory resides (readonly)+ */+var DirectoryEntry = function (name, fullPath, fileSystem, nativeURL) {+ // add trailing slash if it is missing+ if ((fullPath) && !/\/$/.test(fullPath)) {+ fullPath += '/';+ }+ // add trailing slash if it is missing+ if (nativeURL && !/\/$/.test(nativeURL)) {+ nativeURL += '/';+ }+ DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem, nativeURL);+};++utils.extend(DirectoryEntry, Entry);++/**+ * Creates a new DirectoryReader to read entries from this directory+ */+DirectoryEntry.prototype.createReader = function () {+ return new DirectoryReader(this.toInternalURL());+};++/**+ * Creates or looks up a directory+ *+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory+ * @param {Flags} options to create or exclusively create the directory+ * @param {Function} successCallback is called with the new entry+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {+ argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);+ var fs = this.filesystem;+ var win = successCallback && function (result) {+ var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);+ successCallback(entry);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getDirectory', [this.toInternalURL(), path, options]);+};++/**+ * Deletes a directory and all of it's contents+ *+ * @param {Function} successCallback is called with no parameters+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(successCallback, fail, 'File', 'removeRecursively', [this.toInternalURL()]);+};++/**+ * Creates or looks up a file+ *+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file+ * @param {Flags} options to create or exclusively create the file+ * @param {Function} successCallback is called with the new entry+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {+ argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);+ var fs = this.filesystem;+ var win = successCallback && function (result) {+ var FileEntry = require('./FileEntry');+ var entry = new FileEntry(result.name, result.fullPath, fs, result.nativeURL);+ successCallback(entry);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getFile', [this.toInternalURL(), path, options]);+};++module.exports = DirectoryEntry;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/DirectoryReader.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/DirectoryReader.jsnew file mode 100644index 000000000..417c85f10--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/DirectoryReader.js@@ -0,0 +1,75 @@+cordova.define("cordova-plugin-file.DirectoryReader", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var FileError = require('./FileError');++/**+ * An interface that lists the files and directories in a directory.+ */+function DirectoryReader (localURL) {+ this.localURL = localURL || null;+ this.hasReadEntries = false;+}++/**+ * Returns a list of entries from a directory.+ *+ * @param {Function} successCallback is called with a list of entries+ * @param {Function} errorCallback is called with a FileError+ */+DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) {+ // If we've already read and passed on this directory's entries, return an empty list.+ if (this.hasReadEntries) {+ successCallback([]);+ return;+ }+ var reader = this;+ var win = typeof successCallback !== 'function' ? null : function (result) {+ var retVal = [];+ for (var i = 0; i < result.length; i++) {+ var entry = null;+ if (result[i].isDirectory) {+ entry = new (require('./DirectoryEntry'))();+ } else if (result[i].isFile) {+ entry = new (require('./FileEntry'))();+ }+ entry.isDirectory = result[i].isDirectory;+ entry.isFile = result[i].isFile;+ entry.name = result[i].name;+ entry.fullPath = result[i].fullPath;+ entry.filesystem = new (require('./FileSystem'))(result[i].filesystemName);+ entry.nativeURL = result[i].nativeURL;+ retVal.push(entry);+ }+ reader.hasReadEntries = true;+ successCallback(retVal);+ };+ var fail = typeof errorCallback !== 'function' ? null : function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'readEntries', [this.localURL]);+};++module.exports = DirectoryReader;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Entry.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Entry.jsnew file mode 100644index 000000000..5db846cfa--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Entry.js@@ -0,0 +1,263 @@+cordova.define("cordova-plugin-file.Entry", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var argscheck = require('cordova/argscheck');+var exec = require('cordova/exec');+var FileError = require('./FileError');+var Metadata = require('./Metadata');++/**+ * Represents a file or directory on the local file system.+ *+ * @param isFile+ * {boolean} true if Entry is a file (readonly)+ * @param isDirectory+ * {boolean} true if Entry is a directory (readonly)+ * @param name+ * {DOMString} name of the file or directory, excluding the path+ * leading to it (readonly)+ * @param fullPath+ * {DOMString} the absolute full path to the file or directory+ * (readonly)+ * @param fileSystem+ * {FileSystem} the filesystem on which this entry resides+ * (readonly)+ * @param nativeURL+ * {DOMString} an alternate URL which can be used by native+ * webview controls, for example media players.+ * (optional, readonly)+ */+function Entry (isFile, isDirectory, name, fullPath, fileSystem, nativeURL) {+ this.isFile = !!isFile;+ this.isDirectory = !!isDirectory;+ this.name = name || '';+ this.fullPath = fullPath || '';+ this.filesystem = fileSystem || null;+ this.nativeURL = nativeURL || null;+}++/**+ * Look up the metadata of the entry.+ *+ * @param successCallback+ * {Function} is called with a Metadata object+ * @param errorCallback+ * {Function} is called with a FileError+ */+Entry.prototype.getMetadata = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);+ var success = successCallback && function (entryMetadata) {+ var metadata = new Metadata({+ size: entryMetadata.size,+ modificationTime: entryMetadata.lastModifiedDate+ });+ successCallback(metadata);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(success, fail, 'File', 'getFileMetadata', [this.toInternalURL()]);+};++/**+ * Set the metadata of the entry.+ *+ * @param successCallback+ * {Function} is called with a Metadata object+ * @param errorCallback+ * {Function} is called with a FileError+ * @param metadataObject+ * {Object} keys and values to set+ */+Entry.prototype.setMetadata = function (successCallback, errorCallback, metadataObject) {+ argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);+ exec(successCallback, errorCallback, 'File', 'setMetadata', [this.toInternalURL(), metadataObject]);+};++/**+ * Move a file or directory to a new location.+ *+ * @param parent+ * {DirectoryEntry} the directory to which to move this entry+ * @param newName+ * {DOMString} new name of the entry, defaults to the current name+ * @param successCallback+ * {Function} called with the new DirectoryEntry object+ * @param errorCallback+ * {Function} called with a FileError+ */+Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallback) {+ argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ var srcURL = this.toInternalURL();+ // entry name+ var name = newName || this.name;+ var success = function (entry) {+ if (entry) {+ if (successCallback) {+ // create appropriate Entry object+ var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);+ var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef+ var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);+ successCallback(result);+ }+ } else {+ // no Entry object returned+ if (fail) {+ fail(FileError.NOT_FOUND_ERR);+ }+ }+ };++ // copy+ exec(success, fail, 'File', 'moveTo', [srcURL, parent.toInternalURL(), name]);+};++/**+ * Copy a directory to a different location.+ *+ * @param parent+ * {DirectoryEntry} the directory to which to copy the entry+ * @param newName+ * {DOMString} new name of the entry, defaults to the current name+ * @param successCallback+ * {Function} called with the new Entry object+ * @param errorCallback+ * {Function} called with a FileError+ */+Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallback) {+ argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ var srcURL = this.toInternalURL();+ // entry name+ var name = newName || this.name;+ // success callback+ var success = function (entry) {+ if (entry) {+ if (successCallback) {+ // create appropriate Entry object+ var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);+ var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef+ var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);+ successCallback(result);+ }+ } else {+ // no Entry object returned+ if (fail) {+ fail(FileError.NOT_FOUND_ERR);+ }+ }+ };++ // copy+ exec(success, fail, 'File', 'copyTo', [srcURL, parent.toInternalURL(), name]);+};++/**+ * Return a URL that can be passed across the bridge to identify this entry.+ */+Entry.prototype.toInternalURL = function () {+ if (this.filesystem && this.filesystem.__format__) {+ return this.filesystem.__format__(this.fullPath, this.nativeURL);+ }+};++/**+ * Return a URL that can be used to identify this entry.+ * Use a URL that can be used to as the src attribute of a <video> or+ * <audio> tag. If that is not possible, construct a cdvfile:// URL.+ */+Entry.prototype.toURL = function () {+ if (this.nativeURL) {+ return this.nativeURL;+ }+ // fullPath attribute may contain the full URL in the case that+ // toInternalURL fails.+ return this.toInternalURL() || 'file://localhost' + this.fullPath;+};++/**+ * Backwards-compatibility: In v1.0.0 - 1.0.2, .toURL would only return a+ * cdvfile:// URL, and this method was necessary to obtain URLs usable by the+ * webview.+ * See CB-6051, CB-6106, CB-6117, CB-6152, CB-6199, CB-6201, CB-6243, CB-6249,+ * and CB-6300.+ */+Entry.prototype.toNativeURL = function () {+ console.log("DEPRECATED: Update your code to use 'toURL'");+ return this.toURL();+};++/**+ * Returns a URI that can be used to identify this entry.+ *+ * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.+ * @return uri+ */+Entry.prototype.toURI = function (mimeType) {+ console.log("DEPRECATED: Update your code to use 'toURL'");+ return this.toURL();+};++/**+ * Remove a file or directory. It is an error to attempt to delete a+ * directory that is not empty. It is an error to attempt to delete a+ * root directory of a file system.+ *+ * @param successCallback {Function} called with no parameters+ * @param errorCallback {Function} called with a FileError+ */+Entry.prototype.remove = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'Entry.remove', arguments);+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(successCallback, fail, 'File', 'remove', [this.toInternalURL()]);+};++/**+ * Look up the parent DirectoryEntry of this entry.+ *+ * @param successCallback {Function} called with the parent DirectoryEntry object+ * @param errorCallback {Function} called with a FileError+ */+Entry.prototype.getParent = function (successCallback, errorCallback) {+ argscheck.checkArgs('FF', 'Entry.getParent', arguments);+ var fs = this.filesystem;+ var win = successCallback && function (result) {+ var DirectoryEntry = require('./DirectoryEntry');+ var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);+ successCallback(entry);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getParent', [this.toInternalURL()]);+};++module.exports = Entry;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/File.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/File.jsnew file mode 100644index 000000000..c77178653--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/File.js@@ -0,0 +1,81 @@+cordova.define("cordova-plugin-file.File", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Constructor.+ * name {DOMString} name of the file, without path information+ * fullPath {DOMString} the full path of the file, including the name+ * type {DOMString} mime type+ * lastModifiedDate {Date} last modified date+ * size {Number} size of the file in bytes+ */++var File = function (name, localURL, type, lastModifiedDate, size) {+ this.name = name || '';+ this.localURL = localURL || null;+ this.type = type || null;+ this.lastModified = lastModifiedDate || null;+ // For backwards compatibility, store the timestamp in lastModifiedDate as well+ this.lastModifiedDate = lastModifiedDate || null;+ this.size = size || 0;++ // These store the absolute start and end for slicing the file.+ this.start = 0;+ this.end = this.size;+};++/**+ * Returns a "slice" of the file. Since Cordova Files don't contain the actual+ * content, this really returns a File with adjusted start and end.+ * Slices of slices are supported.+ * start {Number} The index at which to start the slice (inclusive).+ * end {Number} The index at which to end the slice (exclusive).+ */+File.prototype.slice = function (start, end) {+ var size = this.end - this.start;+ var newStart = 0;+ var newEnd = size;+ if (arguments.length) {+ if (start < 0) {+ newStart = Math.max(size + start, 0);+ } else {+ newStart = Math.min(size, start);+ }+ }++ if (arguments.length >= 2) {+ if (end < 0) {+ newEnd = Math.max(size + end, 0);+ } else {+ newEnd = Math.min(end, size);+ }+ }++ var newFile = new File(this.name, this.localURL, this.type, this.lastModified, this.size);+ newFile.start = this.start + newStart;+ newFile.end = this.start + newEnd;+ return newFile;+};++module.exports = File;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileEntry.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileEntry.jsnew file mode 100644index 000000000..6651b5542--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileEntry.js@@ -0,0 +1,95 @@+cordova.define("cordova-plugin-file.FileEntry", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var utils = require('cordova/utils');+var exec = require('cordova/exec');+var Entry = require('./Entry');+var FileWriter = require('./FileWriter');+var File = require('./File');+var FileError = require('./FileError');++/**+ * An interface representing a file on the file system.+ *+ * {boolean} isFile always true (readonly)+ * {boolean} isDirectory always false (readonly)+ * {DOMString} name of the file, excluding the path leading to it (readonly)+ * {DOMString} fullPath the absolute full path to the file (readonly)+ * {FileSystem} filesystem on which the file resides (readonly)+ */+var FileEntry = function (name, fullPath, fileSystem, nativeURL) {+ // remove trailing slash if it is present+ if (fullPath && /\/$/.test(fullPath)) {+ fullPath = fullPath.substring(0, fullPath.length - 1);+ }+ if (nativeURL && /\/$/.test(nativeURL)) {+ nativeURL = nativeURL.substring(0, nativeURL.length - 1);+ }++ FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem, nativeURL]);+};++utils.extend(FileEntry, Entry);++/**+ * Creates a new FileWriter associated with the file that this FileEntry represents.+ *+ * @param {Function} successCallback is called with the new FileWriter+ * @param {Function} errorCallback is called with a FileError+ */+FileEntry.prototype.createWriter = function (successCallback, errorCallback) {+ this.file(function (filePointer) {+ var writer = new FileWriter(filePointer);++ if (writer.localURL === null || writer.localURL === '') {+ if (errorCallback) {+ errorCallback(new FileError(FileError.INVALID_STATE_ERR));+ }+ } else {+ if (successCallback) {+ successCallback(writer);+ }+ }+ }, errorCallback);+};++/**+ * Returns a File that represents the current state of the file that this FileEntry represents.+ *+ * @param {Function} successCallback is called with the new File object+ * @param {Function} errorCallback is called with a FileError+ */+FileEntry.prototype.file = function (successCallback, errorCallback) {+ var localURL = this.toInternalURL();+ var win = successCallback && function (f) {+ var file = new File(f.name, localURL, f.type, f.lastModifiedDate, f.size);+ successCallback(file);+ };+ var fail = errorCallback && function (code) {+ errorCallback(new FileError(code));+ };+ exec(win, fail, 'File', 'getFileMetadata', [localURL]);+};++module.exports = FileEntry;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileError.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileError.jsnew file mode 100644index 000000000..f378c3874--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileError.js@@ -0,0 +1,49 @@+cordova.define("cordova-plugin-file.FileError", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * FileError+ */+function FileError (error) {+ this.code = error || null;+}++// File error codes+// Found in DOMException+FileError.NOT_FOUND_ERR = 1;+FileError.SECURITY_ERR = 2;+FileError.ABORT_ERR = 3;++// Added by File API specification+FileError.NOT_READABLE_ERR = 4;+FileError.ENCODING_ERR = 5;+FileError.NO_MODIFICATION_ALLOWED_ERR = 6;+FileError.INVALID_STATE_ERR = 7;+FileError.SYNTAX_ERR = 8;+FileError.INVALID_MODIFICATION_ERR = 9;+FileError.QUOTA_EXCEEDED_ERR = 10;+FileError.TYPE_MISMATCH_ERR = 11;+FileError.PATH_EXISTS_ERR = 12;++module.exports = FileError;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileReader.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileReader.jsnew file mode 100644index 000000000..36d4dd4e6--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileReader.js@@ -0,0 +1,315 @@+cordova.define("cordova-plugin-file.FileReader", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var modulemapper = require('cordova/modulemapper');+var utils = require('cordova/utils');+var FileError = require('./FileError');+var ProgressEvent = require('./ProgressEvent');+var origFileReader = modulemapper.getOriginalSymbol(window, 'FileReader');++/**+ * This class reads the mobile device file system.+ *+ * For Android:+ * The root directory is the root of the file system.+ * To read from the SD card, the file name is "sdcard/my_file.txt"+ * @constructor+ */+var FileReader = function () {+ this._readyState = 0;+ this._error = null;+ this._result = null;+ this._progress = null;+ this._localURL = '';+ this._realReader = origFileReader ? new origFileReader() : {}; // eslint-disable-line new-cap+};++/**+ * Defines the maximum size to read at a time via the native API. The default value is a compromise between+ * minimizing the overhead of many exec() calls while still reporting progress frequently enough for large files.+ * (Note attempts to allocate more than a few MB of contiguous memory on the native side are likely to cause+ * OOM exceptions, while the JS engine seems to have fewer problems managing large strings or ArrayBuffers.)+ */+FileReader.READ_CHUNK_SIZE = 256 * 1024;++// States+FileReader.EMPTY = 0;+FileReader.LOADING = 1;+FileReader.DONE = 2;++utils.defineGetter(FileReader.prototype, 'readyState', function () {+ return this._localURL ? this._readyState : this._realReader.readyState;+});++utils.defineGetter(FileReader.prototype, 'error', function () {+ return this._localURL ? this._error : this._realReader.error;+});++utils.defineGetter(FileReader.prototype, 'result', function () {+ return this._localURL ? this._result : this._realReader.result;+});++function defineEvent (eventName) {+ utils.defineGetterSetter(FileReader.prototype, eventName, function () {+ return this._realReader[eventName] || null;+ }, function (value) {+ this._realReader[eventName] = value;+ });+}++// When the read starts.+defineEvent('onloadstart');++// While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)+defineEvent('onprogress');++// When the read has successfully completed.+defineEvent('onload');++// When the read has failed (see errors).+defineEvent('onerror');++// When the request has completed (either in success or failure).+defineEvent('onloadend');++// When the read has been aborted. For instance, by invoking the abort() method.+defineEvent('onabort');++function initRead (reader, file) {+ // Already loading something+ if (reader.readyState === FileReader.LOADING) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ reader._result = null;+ reader._error = null;+ reader._progress = 0;+ reader._readyState = FileReader.LOADING;++ if (typeof file.localURL === 'string') {+ reader._localURL = file.localURL;+ } else {+ reader._localURL = '';+ return true;+ }++ if (reader.onloadstart) {+ reader.onloadstart(new ProgressEvent('loadstart', { target: reader }));+ }+}++/**+ * Callback used by the following read* functions to handle incremental or final success.+ * Must be bound to the FileReader's this along with all but the last parameter,+ * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate)+ * @param readType The name of the read function to call.+ * @param encoding Text encoding, or null if this is not a text type read.+ * @param offset Starting offset of the read.+ * @param totalSize Total number of bytes or chars to read.+ * @param accumulate A function that takes the callback result and accumulates it in this._result.+ * @param r Callback result returned by the last read exec() call, or null to begin reading.+ */+function readSuccessCallback (readType, encoding, offset, totalSize, accumulate, r) {+ if (this._readyState === FileReader.DONE) {+ return;+ }++ var CHUNK_SIZE = FileReader.READ_CHUNK_SIZE;+ if (readType === 'readAsDataURL') {+ // Windows proxy does not support reading file slices as Data URLs+ // so read the whole file at once.+ CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize // eslint-disable-line no-undef+ : (+ // Calculate new chunk size for data URLs to be multiply of 3+ // Otherwise concatenated base64 chunks won't be valid base64 data+ FileReader.READ_CHUNK_SIZE - (FileReader.READ_CHUNK_SIZE % 3) + 3+ );+ }++ if (typeof r !== 'undefined') {+ accumulate(r);+ this._progress = Math.min(this._progress + CHUNK_SIZE, totalSize);++ if (typeof this.onprogress === 'function') {+ this.onprogress(new ProgressEvent('progress', { loaded: this._progress, total: totalSize }));+ }+ }++ if (typeof r === 'undefined' || this._progress < totalSize) {+ var execArgs = [+ this._localURL,+ offset + this._progress,+ offset + this._progress + Math.min(totalSize - this._progress, CHUNK_SIZE)];+ if (encoding) {+ execArgs.splice(1, 0, encoding);+ }+ exec(+ readSuccessCallback.bind(this, readType, encoding, offset, totalSize, accumulate),+ readFailureCallback.bind(this),+ 'File', readType, execArgs);+ } else {+ this._readyState = FileReader.DONE;++ if (typeof this.onload === 'function') {+ this.onload(new ProgressEvent('load', { target: this }));+ }++ if (typeof this.onloadend === 'function') {+ this.onloadend(new ProgressEvent('loadend', { target: this }));+ }+ }+}++/**+ * Callback used by the following read* functions to handle errors.+ * Must be bound to the FileReader's this, e.g. readFailureCallback.bind(this)+ */+function readFailureCallback (e) {+ if (this._readyState === FileReader.DONE) {+ return;+ }++ this._readyState = FileReader.DONE;+ this._result = null;+ this._error = new FileError(e);++ if (typeof this.onerror === 'function') {+ this.onerror(new ProgressEvent('error', { target: this }));+ }++ if (typeof this.onloadend === 'function') {+ this.onloadend(new ProgressEvent('loadend', { target: this }));+ }+}++/**+ * Abort reading file.+ */+FileReader.prototype.abort = function () {+ if (origFileReader && !this._localURL) {+ return this._realReader.abort();+ }+ this._result = null;++ if (this._readyState === FileReader.DONE || this._readyState === FileReader.EMPTY) {+ return;+ }++ this._readyState = FileReader.DONE;++ // If abort callback+ if (typeof this.onabort === 'function') {+ this.onabort(new ProgressEvent('abort', { target: this }));+ }+ // If load end callback+ if (typeof this.onloadend === 'function') {+ this.onloadend(new ProgressEvent('loadend', { target: this }));+ }+};++/**+ * Read text file.+ *+ * @param file {File} File object containing file properties+ * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)+ */+FileReader.prototype.readAsText = function (file, encoding) {+ if (initRead(this, file)) {+ return this._realReader.readAsText(file, encoding);+ }++ // Default encoding is UTF-8+ var enc = encoding || 'UTF-8';++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsText', enc, file.start, totalSize, function (r) {+ if (this._progress === 0) {+ this._result = '';+ }+ this._result += r;+ }.bind(this));+};++/**+ * Read file and return data as a base64 encoded data url.+ * A data url is of the form:+ * data:[<mediatype>][;base64],<data>+ *+ * @param file {File} File object containing file properties+ */+FileReader.prototype.readAsDataURL = function (file) {+ if (initRead(this, file)) {+ return this._realReader.readAsDataURL(file);+ }++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsDataURL', null, file.start, totalSize, function (r) {+ var commaIndex = r.indexOf(',');+ if (this._progress === 0) {+ this._result = r;+ } else {+ this._result += r.substring(commaIndex + 1);+ }+ }.bind(this));+};++/**+ * Read file and return data as a binary data.+ *+ * @param file {File} File object containing file properties+ */+FileReader.prototype.readAsBinaryString = function (file) {+ if (initRead(this, file)) {+ return this._realReader.readAsBinaryString(file);+ }++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsBinaryString', null, file.start, totalSize, function (r) {+ if (this._progress === 0) {+ this._result = '';+ }+ this._result += r;+ }.bind(this));+};++/**+ * Read file and return data as a binary data.+ *+ * @param file {File} File object containing file properties+ */+FileReader.prototype.readAsArrayBuffer = function (file) {+ if (initRead(this, file)) {+ return this._realReader.readAsArrayBuffer(file);+ }++ var totalSize = file.end - file.start;+ readSuccessCallback.bind(this)('readAsArrayBuffer', null, file.start, totalSize, function (r) {+ var resultArray = (this._progress === 0 ? new Uint8Array(totalSize) : new Uint8Array(this._result));+ resultArray.set(new Uint8Array(r), this._progress);+ this._result = resultArray.buffer;+ }.bind(this));+};++module.exports = FileReader;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileSystem.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileSystem.jsnew file mode 100644index 000000000..ad9ea7859--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileSystem.js@@ -0,0 +1,58 @@+cordova.define("cordova-plugin-file.FileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var DirectoryEntry = require('./DirectoryEntry');++/**+ * An interface representing a file system+ *+ * @constructor+ * {DOMString} name the unique name of the file system (readonly)+ * {DirectoryEntry} root directory of the file system (readonly)+ */+var FileSystem = function (name, root) {+ this.name = name;+ if (root) {+ this.root = new DirectoryEntry(root.name, root.fullPath, this, root.nativeURL);+ } else {+ this.root = new DirectoryEntry(this.name, '/', this);+ }+};++FileSystem.prototype.__format__ = function (fullPath, nativeUrl) {+ return fullPath;+};++FileSystem.prototype.toJSON = function () {+ return '<FileSystem: ' + this.name + '>';+};++// Use instead of encodeURI() when encoding just the path part of a URI rather than an entire URI.+FileSystem.encodeURIPath = function (path) {+ // Because # is a valid filename character, it must be encoded to prevent part of the+ // path from being parsed as a URI fragment.+ return encodeURI(path).replace(/#/g, '%23');+};++module.exports = FileSystem;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileUploadOptions.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileUploadOptions.jsnew file mode 100644index 000000000..6acd09334--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileUploadOptions.js@@ -0,0 +1,44 @@+cordova.define("cordova-plugin-file.FileUploadOptions", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Options to customize the HTTP request used to upload files.+ * @constructor+ * @param fileKey {String} Name of file request parameter.+ * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.+ * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.+ * @param params {Object} Object with key: value params to send to the server.+ * @param headers {Object} Keys are header names, values are header values. Multiple+ * headers of the same name are not supported.+ */+var FileUploadOptions = function (fileKey, fileName, mimeType, params, headers, httpMethod) {+ this.fileKey = fileKey || null;+ this.fileName = fileName || null;+ this.mimeType = mimeType || null;+ this.params = params || null;+ this.headers = headers || null;+ this.httpMethod = httpMethod || null;+};++module.exports = FileUploadOptions;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileUploadResult.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileUploadResult.jsnew file mode 100644index 000000000..e3c3a7431--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileUploadResult.js@@ -0,0 +1,33 @@+cordova.define("cordova-plugin-file.FileUploadResult", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * FileUploadResult+ * @constructor+ */+module.exports = function FileUploadResult (size, code, content) {+ this.bytesSent = size;+ this.responseCode = code;+ this.response = content;+};++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileWriter.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileWriter.jsnew file mode 100644index 000000000..9f141e085--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/FileWriter.js@@ -0,0 +1,338 @@+cordova.define("cordova-plugin-file.FileWriter", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var FileError = require('./FileError');+var FileReader = require('./FileReader');+var ProgressEvent = require('./ProgressEvent');++/**+ * This class writes to the mobile device file system.+ *+ * For Android:+ * The root directory is the root of the file system.+ * To write to the SD card, the file name is "sdcard/my_file.txt"+ *+ * @constructor+ * @param file {File} File object containing file properties+ * @param append if true write to the end of the file, otherwise overwrite the file+ */+var FileWriter = function (file) {+ this.fileName = '';+ this.length = 0;+ if (file) {+ this.localURL = file.localURL || file;+ this.length = file.size || 0;+ }+ // default is to write at the beginning of the file+ this.position = 0;++ this.readyState = 0; // EMPTY++ this.result = null;++ // Error+ this.error = null;++ // Event handlers+ // When writing starts+ this.onwritestart = null;++ // While writing the file, and reporting partial file data+ this.onprogress = null;++ // When the write has successfully completed.+ this.onwrite = null;++ // When the request has completed (either in success or failure).+ this.onwriteend = null;++ // When the write has been aborted. For instance, by invoking the abort() method.+ this.onabort = null;++ // When the write has failed (see errors).+ this.onerror = null;+};++// States+FileWriter.INIT = 0;+FileWriter.WRITING = 1;+FileWriter.DONE = 2;++/**+ * Abort writing file.+ */+FileWriter.prototype.abort = function () {+ // check for invalid state+ if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ // set error+ this.error = new FileError(FileError.ABORT_ERR);++ this.readyState = FileWriter.DONE;++ // If abort callback+ if (typeof this.onabort === 'function') {+ this.onabort(new ProgressEvent('abort', { target: this }));+ }++ // If write end callback+ if (typeof this.onwriteend === 'function') {+ this.onwriteend(new ProgressEvent('writeend', { target: this }));+ }+};++/**+ * Writes data to the file+ *+ * @param data text or blob to be written+ * @param isPendingBlobReadResult {Boolean} true if the data is the pending blob read operation result+ */+FileWriter.prototype.write = function (data, isPendingBlobReadResult) {+ var that = this;+ var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');+ /* eslint-disable no-undef */+ var isProxySupportBlobNatively = (cordova.platformId === 'windows8' || cordova.platformId === 'windows');+ var isBinary;++ // Check to see if the incoming data is a blob+ if (data instanceof File || (!isProxySupportBlobNatively && supportsBinary && data instanceof Blob)) {+ var fileReader = new FileReader();+ /* eslint-enable no-undef */+ fileReader.onload = function () {+ // Call this method again, with the arraybuffer as argument+ FileWriter.prototype.write.call(that, this.result, true /* isPendingBlobReadResult */);+ };+ fileReader.onerror = function () {+ // DONE state+ that.readyState = FileWriter.DONE;++ // Save error+ that.error = this.error;++ // If onerror callback+ if (typeof that.onerror === 'function') {+ that.onerror(new ProgressEvent('error', { target: that }));+ }++ // If onwriteend callback+ if (typeof that.onwriteend === 'function') {+ that.onwriteend(new ProgressEvent('writeend', { target: that }));+ }+ };++ // WRITING state+ this.readyState = FileWriter.WRITING;++ if (supportsBinary) {+ fileReader.readAsArrayBuffer(data);+ } else {+ fileReader.readAsText(data);+ }+ return;+ }++ // Mark data type for safer transport over the binary bridge+ isBinary = supportsBinary && (data instanceof ArrayBuffer);+ if (isBinary && cordova.platformId === 'windowsphone') { // eslint-disable-line no-undef+ // create a plain array, using the keys from the Uint8Array view so that we can serialize it+ data = Array.apply(null, new Uint8Array(data));+ }++ // Throw an exception if we are already writing a file+ if (this.readyState === FileWriter.WRITING && !isPendingBlobReadResult) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ // WRITING state+ this.readyState = FileWriter.WRITING;++ var me = this;++ // If onwritestart callback+ if (typeof me.onwritestart === 'function') {+ me.onwritestart(new ProgressEvent('writestart', { target: me }));+ }++ // Write file+ exec(+ // Success callback+ function (r) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // position always increases by bytes written because file would be extended+ me.position += r;+ // The length of the file is now where we are done writing.++ me.length = me.position;++ // DONE state+ me.readyState = FileWriter.DONE;++ // If onwrite callback+ if (typeof me.onwrite === 'function') {+ me.onwrite(new ProgressEvent('write', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ },+ // Error callback+ function (e) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // DONE state+ me.readyState = FileWriter.DONE;++ // Save error+ me.error = new FileError(e);++ // If onerror callback+ if (typeof me.onerror === 'function') {+ me.onerror(new ProgressEvent('error', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ }, 'File', 'write', [this.localURL, data, this.position, isBinary]);+};++/**+ * Moves the file pointer to the location specified.+ *+ * If the offset is a negative number the position of the file+ * pointer is rewound. If the offset is greater than the file+ * size the position is set to the end of the file.+ *+ * @param offset is the location to move the file pointer to.+ */+FileWriter.prototype.seek = function (offset) {+ // Throw an exception if we are already writing a file+ if (this.readyState === FileWriter.WRITING) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ if (!offset && offset !== 0) {+ return;+ }++ // See back from end of file.+ if (offset < 0) {+ this.position = Math.max(offset + this.length, 0);+ // Offset is bigger than file size so set position+ // to the end of the file.+ } else if (offset > this.length) {+ this.position = this.length;+ // Offset is between 0 and file size so set the position+ // to start writing.+ } else {+ this.position = offset;+ }+};++/**+ * Truncates the file to the size specified.+ *+ * @param size to chop the file at.+ */+FileWriter.prototype.truncate = function (size) {+ // Throw an exception if we are already writing a file+ if (this.readyState === FileWriter.WRITING) {+ throw new FileError(FileError.INVALID_STATE_ERR);+ }++ // WRITING state+ this.readyState = FileWriter.WRITING;++ var me = this;++ // If onwritestart callback+ if (typeof me.onwritestart === 'function') {+ me.onwritestart(new ProgressEvent('writestart', { target: this }));+ }++ // Write file+ exec(+ // Success callback+ function (r) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // DONE state+ me.readyState = FileWriter.DONE;++ // Update the length of the file+ me.length = r;+ me.position = Math.min(me.position, r);++ // If onwrite callback+ if (typeof me.onwrite === 'function') {+ me.onwrite(new ProgressEvent('write', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ },+ // Error callback+ function (e) {+ // If DONE (cancelled), then don't do anything+ if (me.readyState === FileWriter.DONE) {+ return;+ }++ // DONE state+ me.readyState = FileWriter.DONE;++ // Save error+ me.error = new FileError(e);++ // If onerror callback+ if (typeof me.onerror === 'function') {+ me.onerror(new ProgressEvent('error', { target: me }));+ }++ // If onwriteend callback+ if (typeof me.onwriteend === 'function') {+ me.onwriteend(new ProgressEvent('writeend', { target: me }));+ }+ }, 'File', 'truncate', [this.localURL, size]);+};++module.exports = FileWriter;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Flags.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Flags.jsnew file mode 100644index 000000000..cdb12bb73--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Flags.js@@ -0,0 +1,39 @@+cordova.define("cordova-plugin-file.Flags", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Supplies arguments to methods that lookup or create files and directories.+ *+ * @param create+ * {boolean} file or directory if it doesn't exist+ * @param exclusive+ * {boolean} used with create; if true the command will fail if+ * target path exists+ */+function Flags (create, exclusive) {+ this.create = create || false;+ this.exclusive = exclusive || false;+}++module.exports = Flags;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/LocalFileSystem.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/LocalFileSystem.jsnew file mode 100644index 000000000..4ce684812--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/LocalFileSystem.js@@ -0,0 +1,26 @@+cordova.define("cordova-plugin-file.LocalFileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++exports.TEMPORARY = 0;+exports.PERSISTENT = 1;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Metadata.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Metadata.jsnew file mode 100644index 000000000..22366e167--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/Metadata.js@@ -0,0 +1,43 @@+cordova.define("cordova-plugin-file.Metadata", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++/**+ * Information about the state of the file or directory+ *+ * {Date} modificationTime (readonly)+ */+var Metadata = function (metadata) {+ if (typeof metadata === 'object') {+ this.modificationTime = new Date(metadata.modificationTime);+ this.size = metadata.size || 0;+ } else if (typeof metadata === 'undefined') {+ this.modificationTime = null;+ this.size = 0;+ } else {+ /* Backwards compatiblity with platforms that only return a timestamp */+ this.modificationTime = new Date(metadata);+ }+};++module.exports = Metadata;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/ProgressEvent.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/ProgressEvent.jsnew file mode 100644index 000000000..cbecdb12b--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/ProgressEvent.js@@ -0,0 +1,70 @@+cordova.define("cordova-plugin-file.ProgressEvent", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill+// Feature test: See if we can instantiate a native ProgressEvent;+// if so, use that approach,+// otherwise fill-in with our own implementation.+//+// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.+var ProgressEvent = (function () {+ /*+ var createEvent = function(data) {+ var event = document.createEvent('Events');+ event.initEvent('ProgressEvent', false, false);+ if (data) {+ for (var i in data) {+ if (data.hasOwnProperty(i)) {+ event[i] = data[i];+ }+ }+ if (data.target) {+ // TODO: cannot call <some_custom_object>.dispatchEvent+ // need to first figure out how to implement EventTarget+ }+ }+ return event;+ };+ try {+ var ev = createEvent({type:"abort",target:document});+ return function ProgressEvent(type, data) {+ data.type = type;+ return createEvent(data);+ };+ } catch(e){+ */+ return function ProgressEvent (type, dict) {+ this.type = type;+ this.bubbles = false;+ this.cancelBubble = false;+ this.cancelable = false;+ this.lengthComputable = false;+ this.loaded = dict && dict.loaded ? dict.loaded : 0;+ this.total = dict && dict.total ? dict.total : 0;+ this.target = dict && dict.target ? dict.target : null;+ };+ // }+})();++module.exports = ProgressEvent;++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/browser/isChrome.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/browser/isChrome.jsnew file mode 100644index 000000000..90450d862--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/browser/isChrome.js@@ -0,0 +1,29 @@+cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+ */++module.exports = function () {+ // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and+ // possibly a good flag to indicate that we're running in Chrome+ return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;+};++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystemPaths.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystemPaths.jsnew file mode 100644index 000000000..4bfc0f629--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystemPaths.js@@ -0,0 +1,65 @@+cordova.define("cordova-plugin-file.fileSystemPaths", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++var exec = require('cordova/exec');+var channel = require('cordova/channel');++exports.file = {+ // Read-only directory where the application is installed.+ applicationDirectory: null,+ // Root of app's private writable storage+ applicationStorageDirectory: null,+ // Where to put app-specific data files.+ dataDirectory: null,+ // Cached files that should survive app restarts.+ // Apps should not rely on the OS to delete files in here.+ cacheDirectory: null,+ // Android: the application space on external storage.+ externalApplicationStorageDirectory: null,+ // Android: Where to put app-specific data files on external storage.+ externalDataDirectory: null,+ // Android: the application cache on external storage.+ externalCacheDirectory: null,+ // Android: the external storage (SD card) root.+ externalRootDirectory: null,+ // iOS: Temp directory that the OS can clear at will.+ tempDirectory: null,+ // iOS: Holds app-specific files that should be synced (e.g. to iCloud).+ syncedDataDirectory: null,+ // iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)+ documentsDirectory: null,+ // BlackBerry10: Files globally available to all apps+ sharedDirectory: null+};++channel.waitForInitialization('onFileSystemPathsReady');+channel.onCordovaReady.subscribe(function () {+ function after (paths) {+ for (var k in paths) {+ exports.file[k] = paths[k];+ }+ channel.initializationComplete('onFileSystemPathsReady');+ }+ exec(after, null, 'File', 'requestAllPaths', []);+});++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystems-roots.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystems-roots.jsnew file mode 100644index 000000000..6e02953e8--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystems-roots.js@@ -0,0 +1,49 @@+cordova.define("cordova-plugin-file.fileSystems-roots", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++// Map of fsName -> FileSystem.+var fsMap = null;+var FileSystem = require('./FileSystem');+var exec = require('cordova/exec');++// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.+require('./fileSystems').getFs = function (name, callback) {+ function success (response) {+ fsMap = {};+ for (var i = 0; i < response.length; ++i) {+ var fsRoot = response[i];+ if (fsRoot) {+ var fs = new FileSystem(fsRoot.filesystemName, fsRoot);+ fsMap[fs.name] = fs;+ }+ }+ callback(fsMap[name]);+ }++ if (fsMap) {+ callback(fsMap[name]);+ } else {+ exec(success, null, 'File', 'requestAllFileSystems', []);+ }+};++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystems.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystems.jsnew file mode 100644index 000000000..e61ceafc8--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/fileSystems.js@@ -0,0 +1,28 @@+cordova.define("cordova-plugin-file.fileSystems", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.+module.exports.getFs = function (name, callback) {+ callback(null);+};++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/ios/FileSystem.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/ios/FileSystem.jsnew file mode 100644index 000000000..551b51545--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/ios/FileSystem.js@@ -0,0 +1,32 @@+cordova.define("cordova-plugin-file.iosFileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/+/* eslint no-undef : 0 */+FILESYSTEM_PROTOCOL = 'cdvfile';++module.exports = {+ __format__: function (fullPath) {+ var path = ('/' + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath)).replace('//', '/');+ return FILESYSTEM_PROTOCOL + '://localhost' + path;+ }+};++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/requestFileSystem.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/requestFileSystem.jsnew file mode 100644index 000000000..7f652193c--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/requestFileSystem.js@@ -0,0 +1,84 @@+cordova.define("cordova-plugin-file.requestFileSystem", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/++(function () {+ // For browser platform: not all browsers use this file.+ function checkBrowser () {+ if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef+ module.exports = window.requestFileSystem || window.webkitRequestFileSystem;+ return true;+ }+ return false;+ }+ if (checkBrowser()) {+ return;+ }++ var argscheck = require('cordova/argscheck');+ var FileError = require('./FileError');+ var FileSystem = require('./FileSystem');+ var exec = require('cordova/exec');+ var fileSystems = require('./fileSystems');++ /**+ * Request a file system in which to store application data.+ * @param type local file system type+ * @param size indicates how much storage space, in bytes, the application expects to need+ * @param successCallback invoked with a FileSystem object+ * @param errorCallback invoked if error occurs retrieving file system+ */+ var requestFileSystem = function (type, size, successCallback, errorCallback) {+ argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);+ var fail = function (code) {+ if (errorCallback) {+ errorCallback(new FileError(code));+ }+ };++ if (type < 0) {+ fail(FileError.SYNTAX_ERR);+ } else {+ // if successful, return a FileSystem object+ var success = function (file_system) {+ if (file_system) {+ if (successCallback) {+ fileSystems.getFs(file_system.name, function (fs) {+ // This should happen only on platforms that haven't implemented requestAllFileSystems (windows)+ if (!fs) {+ fs = new FileSystem(file_system.name, file_system.root);+ }+ successCallback(fs);+ });+ }+ } else {+ // no FileSystem object returned+ fail(FileError.NOT_FOUND_ERR);+ }+ };+ exec(success, fail, 'File', 'requestFileSystem', [type, size]);+ }+ };++ module.exports = requestFileSystem;+})();++});diff --git a/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.jsnew file mode 100644index 000000000..494de62ff--- /dev/null+++ b/cordova/platforms/ios/www/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js@@ -0,0 +1,94 @@+cordova.define("cordova-plugin-file.resolveLocalFileSystemURI", function(require, exports, module) {+/*+ *+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ *+*/+(function () {+ // For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.+ function checkBrowser () {+ if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef+ module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;+ return true;+ }+ return false;+ }+ if (checkBrowser()) {+ return;+ }++ var argscheck = require('cordova/argscheck');+ var DirectoryEntry = require('./DirectoryEntry');+ var FileEntry = require('./FileEntry');+ var FileError = require('./FileError');+ var exec = require('cordova/exec');+ var fileSystems = require('./fileSystems');++ /**+ * Look up file system Entry referred to by local URI.+ * @param {DOMString} uri URI referring to a local file or directory+ * @param successCallback invoked with Entry object corresponding to URI+ * @param errorCallback invoked if error occurs retrieving file system entry+ */+ module.exports.resolveLocalFileSystemURL = module.exports.resolveLocalFileSystemURL || function (uri, successCallback, errorCallback) {+ argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);+ // error callback+ var fail = function (error) {+ if (errorCallback) {+ errorCallback(new FileError(error));+ }+ };+ // sanity check for 'not:valid:filename' or '/not:valid:filename'+ // file.spec.12 window.resolveLocalFileSystemURI should error (ENCODING_ERR) when resolving invalid URI with leading /.+ if (!uri || uri.split(':').length > 2) {+ setTimeout(function () {+ fail(FileError.ENCODING_ERR);+ }, 0);+ return;+ }+ // if successful, return either a file or directory entry+ var success = function (entry) {+ if (entry) {+ if (successCallback) {+ // create appropriate Entry object+ var fsName = entry.filesystemName || (entry.filesystem && entry.filesystem.name) || (entry.filesystem === window.PERSISTENT ? 'persistent' : 'temporary'); // eslint-disable-line no-undef+ fileSystems.getFs(fsName, function (fs) {+ // This should happen only on platforms that haven't implemented requestAllFileSystems (windows)+ if (!fs) {+ fs = new FileSystem(fsName, { name: '', fullPath: '/' }); // eslint-disable-line no-undef+ }+ var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath, fs, entry.nativeURL) : new FileEntry(entry.name, entry.fullPath, fs, entry.nativeURL);+ successCallback(result);+ });+ }+ } else {+ // no Entry object returned+ fail(FileError.NOT_FOUND_ERR);+ }+ };++ exec(success, fail, 'File', 'resolveLocalFileSystemURI', [uri]);+ };++ module.exports.resolveLocalFileSystemURI = function () {+ console.log('resolveLocalFileSystemURI is deprecated. Please call resolveLocalFileSystemURL instead.');+ module.exports.resolveLocalFileSystemURL.apply(this, arguments);+ };+})();++});