From 29995227be7473fc99174f95a4ad233e13c07d5f Mon Sep 17 00:00:00 2001 From: Gilbert Schwaab Date: Wed, 3 Oct 2018 22:47:22 +0200 Subject: [PATCH 1/6] Windows known folders support Access to known user folders: documentsDirectory: Documents, picturesDirectory: Pictures, musicDirectory: Music, videoDirectory: Videos --- src/windows/FileProxy.js | 24 ++++++++++++++++++++++++ www/fileSystemPaths.js | 9 ++++++++- www/resolveLocalFileSystemURI.js | 3 ++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js index d829d7755..d522d5d11 100644 --- a/src/windows/FileProxy.js +++ b/src/windows/FileProxy.js @@ -181,6 +181,30 @@ var windowsPaths = { applicationStorageDirectory: 'ms-appx:///' }; +if (Windows.Storage.UserDataPaths) { + var userDataPaths = null; + if (typeof Windows.Storage.UserDataPaths.getDefault === "function") { + userDataPaths = Windows.Storage.UserDataPaths.getDefault(); + } + if (!userDataPaths && typeof Windows.Storage.UserDataPaths.getForUser === "function") { + userDataPaths = Windows.Storage.UserDataPaths.getForUser(); + } + if (userDataPaths) { + if (userDataPaths.documents) { + windowsPaths.documentsDirectory = 'file:///' + nativePathToCordova(userDataPaths.documents); + } + if (userDataPaths.music) { + windowsPaths.musicDirectory = 'file:///' + nativePathToCordova(userDataPaths.music); + } + if (userDataPaths.pictures) { + windowsPaths.picturesDirectory = 'file:///' + nativePathToCordova(userDataPaths.pictures); + } + if (userDataPaths.videos) { + windowsPaths.videoDirectory = 'file:///' + nativePathToCordova(userDataPaths.videos); + } + } +} + var AllFileSystems; function getAllFS () { diff --git a/www/fileSystemPaths.js b/www/fileSystemPaths.js index f79794bb0..81ad54fb0 100644 --- a/www/fileSystemPaths.js +++ b/www/fileSystemPaths.js @@ -45,9 +45,16 @@ exports.file = { // 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) + // Windows: Gets the path to a user's Documents folder. documentsDirectory: null, // BlackBerry10: Files globally available to all apps - sharedDirectory: null + sharedDirectory: null, + // Windows: Gets the path to a user's Music folder. + musicDirectory: null, + // Windows: Gets the path to a user's Pictures folder. + picturesDirectory: null, + // Windows: Gets the path to a user's Videos folder. + videoDirectory: null }; channel.waitForInitialization('onFileSystemPathsReady'); diff --git a/www/resolveLocalFileSystemURI.js b/www/resolveLocalFileSystemURI.js index 764662c04..387117bc5 100644 --- a/www/resolveLocalFileSystemURI.js +++ b/www/resolveLocalFileSystemURI.js @@ -54,7 +54,8 @@ }; // 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) { + // now, better no check than bad check! + if (!uri /*|| uri.split(':').length > 2*/) { setTimeout(function () { fail(FileError.ENCODING_ERR); }, 0); From 8a845c3429ce026946f2c37e1a3826a88a60476a Mon Sep 17 00:00:00 2001 From: Gilbert Schwaab Date: Wed, 3 Oct 2018 23:08:38 +0200 Subject: [PATCH 2/6] Comment deleted Has no effect --- www/resolveLocalFileSystemURI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/resolveLocalFileSystemURI.js b/www/resolveLocalFileSystemURI.js index 387117bc5..cc88ff7ea 100644 --- a/www/resolveLocalFileSystemURI.js +++ b/www/resolveLocalFileSystemURI.js @@ -55,7 +55,7 @@ // 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 /. // now, better no check than bad check! - if (!uri /*|| uri.split(':').length > 2*/) { + if (!uri) { setTimeout(function () { fail(FileError.ENCODING_ERR); }, 0); From 2f97eae49590ac6ae488b4f92e82c63e4775ef5c Mon Sep 17 00:00:00 2001 From: Gilbert Schwaab Date: Thu, 4 Oct 2018 16:11:09 +0200 Subject: [PATCH 3/6] Typo videosDirectory and replaced tab with spaces --- src/windows/FileProxy.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js index d522d5d11..1e878ecd2 100644 --- a/src/windows/FileProxy.js +++ b/src/windows/FileProxy.js @@ -183,26 +183,26 @@ var windowsPaths = { if (Windows.Storage.UserDataPaths) { var userDataPaths = null; - if (typeof Windows.Storage.UserDataPaths.getDefault === "function") { - userDataPaths = Windows.Storage.UserDataPaths.getDefault(); - } - if (!userDataPaths && typeof Windows.Storage.UserDataPaths.getForUser === "function") { - userDataPaths = Windows.Storage.UserDataPaths.getForUser(); - } - if (userDataPaths) { - if (userDataPaths.documents) { - windowsPaths.documentsDirectory = 'file:///' + nativePathToCordova(userDataPaths.documents); - } - if (userDataPaths.music) { - windowsPaths.musicDirectory = 'file:///' + nativePathToCordova(userDataPaths.music); - } - if (userDataPaths.pictures) { - windowsPaths.picturesDirectory = 'file:///' + nativePathToCordova(userDataPaths.pictures); - } - if (userDataPaths.videos) { - windowsPaths.videoDirectory = 'file:///' + nativePathToCordova(userDataPaths.videos); - } - } + if (typeof Windows.Storage.UserDataPaths.getDefault === "function") { + userDataPaths = Windows.Storage.UserDataPaths.getDefault(); + } + if (!userDataPaths && typeof Windows.Storage.UserDataPaths.getForUser === "function") { + userDataPaths = Windows.Storage.UserDataPaths.getForUser(); + } + if (userDataPaths) { + if (userDataPaths.documents) { + windowsPaths.documentsDirectory = 'file:///' + nativePathToCordova(userDataPaths.documents); + } + if (userDataPaths.music) { + windowsPaths.musicDirectory = 'file:///' + nativePathToCordova(userDataPaths.music); + } + if (userDataPaths.pictures) { + windowsPaths.picturesDirectory = 'file:///' + nativePathToCordova(userDataPaths.pictures); + } + if (userDataPaths.videos) { + windowsPaths.videosDirectory = 'file:///' + nativePathToCordova(userDataPaths.videos); + } + } } var AllFileSystems; From ed1f86cfcdd050efad68ad50cabbb2eab23b8b10 Mon Sep 17 00:00:00 2001 From: Gilbert Schwaab Date: Mon, 8 Oct 2018 14:39:55 +0200 Subject: [PATCH 4/6] Android: Decreased version requirements --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 90ff927d4..9d4f7e732 100644 --- a/plugin.xml +++ b/plugin.xml @@ -30,7 +30,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" https://issues.apache.org/jira/browse/CB/component/12320651 - + From 9e51810be05679901078544b1009168574bfa296 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Tue, 30 Oct 2018 15:27:44 +0100 Subject: [PATCH 5/6] Fix "Strings must use singlequote" eslint --- src/windows/FileProxy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js index 1e878ecd2..fdb13f496 100644 --- a/src/windows/FileProxy.js +++ b/src/windows/FileProxy.js @@ -183,10 +183,10 @@ var windowsPaths = { if (Windows.Storage.UserDataPaths) { var userDataPaths = null; - if (typeof Windows.Storage.UserDataPaths.getDefault === "function") { + if (typeof Windows.Storage.UserDataPaths.getDefault === 'function') { userDataPaths = Windows.Storage.UserDataPaths.getDefault(); } - if (!userDataPaths && typeof Windows.Storage.UserDataPaths.getForUser === "function") { + if (!userDataPaths && typeof Windows.Storage.UserDataPaths.getForUser === 'function') { userDataPaths = Windows.Storage.UserDataPaths.getForUser(); } if (userDataPaths) { From dcd9e44622f46269015fe313302298b866730286 Mon Sep 17 00:00:00 2001 From: Hung Date: Fri, 1 Jul 2022 09:51:47 +0200 Subject: [PATCH 6/6] get path/location of local sqlite db --- src/android/FileUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java index 1d6e61fa3..2fa180c02 100644 --- a/src/android/FileUtils.java +++ b/src/android/FileUtils.java @@ -992,6 +992,8 @@ private JSONObject requestAllPaths() throws JSONException { ret.put("applicationStorageDirectory", toDirUrl(context.getFilesDir().getParentFile())); ret.put("dataDirectory", toDirUrl(context.getFilesDir())); ret.put("cacheDirectory", toDirUrl(context.getCacheDir())); + // databasepath + ret.put("databaseDirectory", toDirUrl(context.getDatabasePath("dummy").getParentFile())); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { try { ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile()));