fileSystemPaths.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. var exec = require('cordova/exec');
  22. var channel = require('cordova/channel');
  23. exports.file = {
  24. // Read-only directory where the application is installed.
  25. applicationDirectory: null,
  26. // Root of app's private writable storage
  27. applicationStorageDirectory: null,
  28. // Where to put app-specific data files.
  29. dataDirectory: null,
  30. // Cached files that should survive app restarts.
  31. // Apps should not rely on the OS to delete files in here.
  32. cacheDirectory: null,
  33. // Android: the application space on external storage.
  34. externalApplicationStorageDirectory: null,
  35. // Android: Where to put app-specific data files on external storage.
  36. externalDataDirectory: null,
  37. // Android: the application cache on external storage.
  38. externalCacheDirectory: null,
  39. // Android: the external storage (SD card) root.
  40. externalRootDirectory: null,
  41. // iOS: Temp directory that the OS can clear at will.
  42. tempDirectory: null,
  43. // iOS: Holds app-specific files that should be synced (e.g. to iCloud).
  44. syncedDataDirectory: null,
  45. // iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
  46. documentsDirectory: null,
  47. // BlackBerry10: Files globally available to all apps
  48. sharedDirectory: null
  49. };
  50. channel.waitForInitialization('onFileSystemPathsReady');
  51. channel.onCordovaReady.subscribe(function() {
  52. function after(paths) {
  53. for (var k in paths) {
  54. exports.file[k] = paths[k];
  55. }
  56. channel.initializationComplete('onFileSystemPathsReady');
  57. }
  58. exec(after, null, 'File', 'requestAllPaths', []);
  59. });